SankethBK / diaryvault

A personal diary application written in Flutter
https://play.google.com/store/apps/details?id=me.sankethbk.dairyapp
MIT License
95 stars 66 forks source link

Fix image size in PDF #226

Open SankethBK opened 2 days ago

SankethBK commented 2 days ago

Currently when a note containing image is exported into PDF, the image dimensions are retained from uploaded image and it fills up 2-3 pages in PDF.

For example this is the note

Pdf will be something like this

PDF is generated from exportNotesToPDF function which eventually calls preprocessDeltaForPDFExport function in lib/features/notes/data/repositories/export_notes_repository.dart. This function first converts delta format to HTML and then to PDF. We can access each delta element and its attributes inside this function. We need to edit the img tags generated in HTML to and add suitable height, width attributes so that the image doesn't span over multiple pages in PDF.

Relevant widgets

- packages/flutter_html_to_pdf/lib/flutter_html_to_pdf.dart