PdfGenerator class

Generates PDF files from DocxDocument without external dependencies.

Implements DocumentGenerator interface for interchangeable use with DocxGenerator.

PDF is built manually by creating the required objects:

  • Catalog (document root)
  • Pages tree
  • Page objects
  • Font resources
  • Content streams
Implemented types

Constructors

PdfGenerator({String fontName = 'Helvetica', int fontSize = 12, double pageWidth = 612, double pageHeight = 792, double marginTop = 72, double marginBottom = 72, double marginLeft = 72, double marginRight = 72})

Properties

fontName String
Font name (PDF base 14 fonts: Helvetica, Times-Roman, Courier).
final
fontSize int
Default font size in points.
final
hashCode int
The hash code for this object.
no setterinherited
marginBottom double
Bottom margin in points.
final
marginLeft double
Left margin in points.
final
marginRight double
Right margin in points.
final
marginTop double
Top margin in points.
final
pageHeight double
Page height in points (792 = 11 inches).
final
pageWidth double
Page width in points (612 = 8.5 inches).
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

generate(DocxDocument document) Uint8List
Generates a PDF document and returns it as bytes.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

defaultExtension → const String
Default file extension for PDF files.