getPdf method

Future<Uint8List?> getPdf({
  1. PdfPageMode pageMode = PdfPageMode.thumbs,
  2. bool compress = false,
  3. PdfVersion pdfVersion = PdfVersion.pdf_1_5,
  4. PdfPageFormat pageFormat = PdfPageFormat.undefined,
  5. PageOrientation? pageOrientation,
  6. String? title,
  7. String? author,
  8. String? creator,
  9. String? subject,
  10. String? keywords,
  11. String? producer,
})

This method outputs a nullable Uint8List representing the Widget wrapped by CaptureBox in the form of a PDF mime type.

If there is no Widget attached or if an error occurs during the convertion, this method returns null.

Implementation

Future<Uint8List?> getPdf({
  PdfPageMode pageMode = PdfPageMode.thumbs,
  bool compress = false,
  PdfVersion pdfVersion = PdfVersion.pdf_1_5,
  PdfPageFormat pageFormat = PdfPageFormat.undefined,
  pdf_widgets.PageOrientation? pageOrientation,
  String? title,
  String? author,
  String? creator,
  String? subject,
  String? keywords,
  String? producer,
}) async {
  Uint8List? pngByteList = await getPng();

  if(pngByteList != null) {
    return await _pngToPdf(
      pngByteList,
      pageMode: pageMode,
      compress: compress,
      pdfVersion: pdfVersion,
      pageFormat: pageFormat,
      pageOrientation: pageOrientation,
      title: title,
      author: author,
      creator: creator,
      subject: subject,
      keywords: keywords,
      producer: producer
    );
  }

  return null;
}