flutter_quill_to_pdf 2.0.0 copy "flutter_quill_to_pdf: ^2.0.0" to clipboard
flutter_quill_to_pdf: ^2.0.0 copied to clipboard

Create PDF'S using deltas from Quill, with configurable attributes, fonts, and custom pdf widgets

Flutter Quill to PDF #

This package allow us create PDF's using Deltas from Quill.

Some options that can be configured:

  • DeltaAttributesOptions (this attributes will be applied to whole delta)
  • We can use custom fonts. Using onRequest functions in PDFConverter we can detect the font family detected, and use a custom implementation to return a Font valid to pdf package Just works automatically with the default library implementation
  • CustomConverter, which helps you create custom PDF widgets using custom regular expressions. By now is not working
  • Optional front matter and back matter
  • Page format using PDFPageFormat class
  • CustomPDFWidget functions in PDFConverter that let us customize the detected style, and create a custom pdf widget implementation By now is not working
  • ThemeData optional theme data that let us changes the theme for to pdf document

By default, the delta is processed by a local implementation that uses DeltaAttributesOptions to apply custom attributes (if it is not null), making it easier to add an attribute to the entire delta. If you want to create your own implementation or simply use a default delta, use PDFConverter(...params).createDocument(shouldProcessDeltas: false).

Tap to show/hide screenshots
Delta in editor Delta converted in PDF

Add dependencies #

dependencies:
  flutter_quill_to_pdf: ^2.0.0

Import package #

import 'package:flutter_quill_to_pdf/flutter_quill_to_pdf.dart':

Personalize the settings of the page (height, width and margins) #

We can use two types differents constructors of the same PDFPageFormat class

The common, with all set params:
final PDFPageFormat pageFormat = PDFPageFormat(
   width: ..., //max width of the page
   height: ..., //max height of the page,
   marginTop: ...,
   marginBottom: ...,
   marginLeft: ...,
   marginRight: ...,
);
The factory to marginize all PDFPageFormat
final PDFPageFormat pageFormat = PDFPageFormat.all(
   width: ..., //max width of the page
   height: ..., //max height of the page,
   margin: ..., //will set the property to the others margins
);

Using PDFConverter to create finally our document #

PDFConverter pdfConverter = PDFConverter(
    backMatterDelta: null,
    frontMatterDelta: null,
    document: QuillController.basic().document.toDelta(),
    fallbacks: [...your global fonts],
    onRequestBoldFont: (String fontFamily) async {
       ...your local font implementation
    },
    onRequestBoldItalicFont: (String fontFamily) async {
       ...your local font implementation
    },
    onRequestFallbackFont: (String fontFamily) async {
       ...your local font implementation
    },
    onRequestItalicFont: (String fontFamily) async {
       ...your local font implementation
    },
    onRequestFont: (String fontFamily) async {
       ...your local font implementation
    },
    params: pageFormat,
);

To create it, we have two options : #

createDocument returns the PDF document associated

final pw.Document? document = await pdfConverter.createDocument();

createDocumentFile makes the same of the before one, write in the selected file path

await pdfConverter.createDocumentFile(path: filepath, ...other optional params);

Supported #

  • Font family
  • Size
  • Bold
  • Italic
  • Strikethrough
  • Underline
  • Link
  • Color
  • Background Color
  • Line-height (custom attribute used from this package)
  • Code block
  • Blockquote
  • Align
  • Embed image
  • Header
  • List
  • Indent

No supported #

  • Superscript/Subscript (Working on it)
  • Embed formula (Not planned)
  • Embed video (Not planned)

You can contribute reporting issues or requesting to add new features in: https://github.com/CatHood0/flutter_quill_to_pdf

10
likes
0
points
1.36k
downloads

Publisher

unverified uploader

Weekly Downloads

Create PDF'S using deltas from Quill, with configurable attributes, fonts, and custom pdf widgets

Repository (GitHub)
View/report issues

Topics

#pdf #quill-delta #pdf-widgets #converter #pdf-converter

License

unknown (license)

Dependencies

collection, cross_file, dart_quill_delta, dio, flutter_quill_delta_easy_parser, html, html_unescape, meta, path_provider, pdf, universal_html

More

Packages that depend on flutter_quill_to_pdf