PdfPageExport class

Exports PDF pages to PNG/JPEG image bytes.

This is the public, documented entry point for the "PDF → image" side of the conversion pipeline. It wraps the existing rasterizer (PdfPageRenderer.renderImage) so a host can turn a page - or a whole document - into image files at a chosen resolution and colour, without touching dart:ui directly.

Resolution is given as dpi (dots per inch); a PDF point is 1/72 inch, so the raster is dpi / 72 pixels per point. Pass scale to override that with an explicit pixels-per-point ratio instead (150 dpi == 2.083×).

final doc = PdfDocument.open(bytes);
final png = await PdfPageExport.exportPage(doc.page(0), dpi: 200);
// write `png` to disk / upload it - these bytes are a complete PNG file.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

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

Static Methods

exportPage(PdfPage page, {PdfRasterFormat format = PdfRasterFormat.png, double dpi = 150, double? scale, Color pageColor = const Color(0xFFFFFFFF), bool annotations = true, int? rotation, int jpegQuality = 90}) Future<Uint8List>
Renders page and encodes it as format bytes.
exportPages(PdfDocument document, {int start = 0, int? count, PdfRasterFormat format = PdfRasterFormat.png, double dpi = 150, double? scale, Color pageColor = const Color(0xFFFFFFFF), bool annotations = true, int jpegQuality = 90}) Future<List<Uint8List>>
Exports a contiguous run of pages from document, starting at start (inclusive) for count pages (default: to the end). Returns the encoded bytes in page order. See exportPage for the parameters.