Hi Marlon,
Flutter PDF allows you to add an image to the PDF document. You can load image data
in PdfBitmap object to draw
the images using the drawImage method of
the PdfGraphics class.
Please refer to the below documentation,
https://help.syncfusion.com/flutter/pdf/working-with-images
https://www.syncfusion.com/kb/11965/how-to-convert-image-to-pdf-in-syncfusion-flutter-pdf-library
Please find the below code snippet to draw an image in a PDF
document without losing quality,
|
//Create a new
PDF document
PdfDocument
document = PdfDocument();
//Adds a page
to the document
PdfPage page = document.pages.add();
//Draw the
image
page.graphics.drawImage(
PdfBitmap(File('image.jpg').readAsBytesSync()),
Rect.fromLTWH(
0, 0, page.getClientSize().width,
page.getClientSize().height));
//Saves the
document
File('Output.pdf').writeAsBytes(document.save());
//Disposes the
document
document.dispose();
|
Please let us know if you need any further assistance in this.
Regards,
Gowthamraj K