From d5c16857e347c389f5a337c154e331e927e961d2 Mon Sep 17 00:00:00 2001 From: SurendarSuri30 Date: Sat, 8 Aug 2026 12:08:24 +0530 Subject: [PATCH] pdf blur issue fix --- .../claims_overview_pdf_export.dart | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/presentation/claims_overview/claims_overview_pdf_export.dart b/lib/presentation/claims_overview/claims_overview_pdf_export.dart index 859a860..c2495a8 100644 --- a/lib/presentation/claims_overview/claims_overview_pdf_export.dart +++ b/lib/presentation/claims_overview/claims_overview_pdf_export.dart @@ -47,8 +47,10 @@ const _capturePadding = 16.0; const _maxMeasureHeight = 1400.0; const _enrollmentMaxMeasureHeight = 1020.0; const _minCaptureHeight = 360.0; -const _captureTimeout = Duration(seconds: 20); -const _pdfEmbedMaxWidth = 960; +const _captureTimeout = Duration(seconds: 30); +/// Target embed width (~200 DPI on A4 landscape content area) for sharp text. +const _pdfEmbedMaxWidth = 1800; +const _pdfJpegQuality = 92; const _logoAsset = 'assets/Nhance-Logo-Final 1.png'; const _pdfLogoHeight = 28.0; const _pdfPageMargin = pw.EdgeInsets.fromLTRB(10, 14, 10, 14); @@ -101,7 +103,8 @@ Future _preloadFonts() async { } } -/// Shrinks and JPEG-encodes tab screenshots so [doc.save] stays fast. +/// Optionally downscales and JPEG-encodes tab screenshots for PDF embed. +/// Keeps high resolution so dashboard text/charts stay sharp when zoomed. Uint8List _compressTabImageForPdf(Uint8List pngBytes) { try { final decoded = img.decodePng(pngBytes); @@ -112,11 +115,13 @@ Uint8List _compressTabImageForPdf(Uint8List pngBytes) { processed = img.copyResize( decoded, width: _pdfEmbedMaxWidth, - interpolation: img.Interpolation.average, + interpolation: img.Interpolation.cubic, ); } - return Uint8List.fromList(img.encodeJpg(processed, quality: 82)); + return Uint8List.fromList( + img.encodeJpg(processed, quality: _pdfJpegQuality), + ); } catch (e) { debugPrint('PDF export: image compress skipped ($e)'); return pngBytes; @@ -293,10 +298,12 @@ Future _waitForPaint() async { } double _capturePixelRatio({required bool isEnrollmentTab}) { + // 2x+ capture is required for crisp text when screenshots are + // scaled into A4 landscape PDF pages (especially on Flutter web). if (kIsWeb) { - return isEnrollmentTab ? 0.85 : 1.0; + return isEnrollmentTab ? 1.75 : 2.0; } - return isEnrollmentTab ? 1.1 : 1.35; + return isEnrollmentTab ? 1.75 : 2.25; } Future _rasterizeBoundary(