dpdf 1.0.0
dpdf: ^1.0.0 copied to clipboard
Pure Dart PDF library: creation, reading, editing, text layout, HTML conversion, forms, digital signatures and PDF/A conformance.
Changelog #
1.0.0 #
Initial release. dpdf is implemented in pure Dart, uses no FFI or external
binaries, and targets the Dart VM, dart2js, and dart2wasm.
Added #
- PDF kernel with parsing, serialization, xref streams, object streams, incremental updates, encryption, fonts, forms, and annotations.
- High-level document layout and HTML-to-PDF conversion using embedded metrics for the 14 standard PDF fonts.
- SVG-to-PDF conversion for basic shapes and paths, transforms,
viewBox, fill/stroke styling, opacity, and inline inheritance. - PDF-to-PNG rendering through the web-safe
dgfxrasterizer, including paths, arbitrary clipping, color spaces, images, masks, Form XObjects, and embedded TrueType/CFF glyph outlines. Rendering reports expose skipped work. - A reusable
PdfContentParser, including inline-image boundaries, and aPdfImageDecoderwith 1-16-bit samples,/Decode, palettes, and masks. - PDF function types 0, 2, 3, and 4 and RGB conversion for Device, calibrated, ICCBased, Lab, Indexed, Separation, and DeviceN color spaces.
- Pure-Dart PNG encoding, baseline/progressive JPEG decoding, baseline JPEG encoding, image resizing, and optional lossy image recompression.
- Structural PDF compression, deduplication, unreachable-object removal, and lossless bi-level image recompression using the smaller JBIG2 or Flate result.
- Integrity inspection and explicit PDF/A-1 through PDF/A-4 and PDF/UA-1 verification reports.
- Text extraction, text and area redaction, page overlays and assembly, form merging, digital signatures, timestamps, OCSP, CRL, and JKS/BKS support.
- Text extraction reads the documents that real producers write:
gswhose/ExtGStatecarries no/Fontis ignored rather than refused,DP,BXandEXare stepped over, encodings named without a ToUnicode are honoured, and a ToUnicode is read at the code width the font imposes rather than at the width itscodespacerangeclaims. Where a document draws a glyph it never identifies anywhere, extraction now yields U+FFFD instead of failing the page — an observable change of contract. Area redaction accepts the samegs, refusing only when the graphics state could change the current font. - Fonts resolve by object rather than by resource name. A producer may reuse one short name for different fonts in different Form XObjects, and the old cache drew every one of them with whichever font it met first.
- Images drawn smaller than their source integrate the area they cover instead
of point-sampling it;
/Interpolategoverns magnification, and minification without filtering drops one-pixel detail outright. - The fourteen standard PDF fonts are drawn from bundled URW Core 35 faces when a document references them without embedding a program, so such a page is no longer blank; substitutions are named in the render report. Standard-font advance widths resolve by glyph name, so accented text under WinAnsiEncoding or MacRomanEncoding keeps its spacing instead of collapsing into one point.
- Clipping of filled vector artwork against a redaction area: curves are split
at the parameters where they cross the edge and the hole is reclosed along
the edge itself, preserving the winding rule for both
fandf*. A stroked path that crosses an edge is still refused with an explicit message, because the pen paints half the width to either side of the geometry. - Code 39, Code 128, EAN/UPC, and QR Code generation.
Fixed #
- Axial and radial shadings resampled their function at 257 points before
handing it to the rasterizer, which builds a lookup table of up to 1024
entries. A function that changes colour abruptly — a type 4
ifelse, or a type 3 stitching boundary — fell between two samples, the gap was interpolated, and the page got a ramp where the document asked for an edge: 10 px wide on an A4 page at 300 dpi. The sampling now matches the table. - Prevented xref-stream rewrites from copying a stale
/Indexentry from the source trailer and corrupting externally produced or signed documents. - Rejected append mode combined with full compression with a clear error.
- Corrected asynchronous dash-array serialization that could corrupt a content stream, and applied filter chains before JPEG decoding.
- Added MacRomanEncoding, embedded CMap support, standard-font AFM metrics, and an application font-fallback hook.
- Added complete progressive Huffman JPEG scans and made over-subscribed Huffman
tables throw
JpegDecodeExceptioninstead of a range error. - Corrected PNG chunk CRCs and replaced
/JBIG2Decodebyte passthrough with real decoding. - Removed a duplicate Pattern color-space stub and corrected ICC component counts.
- Awaited the futures that the new
discarded_futuresandunawaited_futureslints exposed. A form-field flag setter returned before the flag was written,PdfArray.removereturned before the element was gone — so removing a field from an AcroForm left the widget in the page's/Annotsand the field in its parent's/Kids— the signature appearance layer was attached after the field had already been added to the form,TransparentColorcould emit its/ExtGStateafter the operators it governs,setRenderingIntentwrote therioperator before the name it consumes, and the filter benchmark timed the creation of futures rather than the decoding.
Breaking changes #
-
Document.add,Canvas.add,showTextAlignedandshowTextAlignedParagraphare synchronous and return the root element instead of aFuture. They queue the element; the layout runs inclose, which was already mandatory to await. Forgetting to awaitaddused to drop the content with no error, no warning and no exception.// Before await document.add(Paragraph('First page.')); await document.add(AreaBreak(AreaBreakType.NEXT_PAGE)); await document.close(); // After document.add(Paragraph('First page.')); document.add(AreaBreak(AreaBreakType.NEXT_PAGE)); await document.close();Three observable consequences. A layout error now reaches the caller from
close, not fromadd; the queue is discarded when that happens, so the error is reported once. An element must not be mutated after it is added, because it is laid out as it stands atclose. AndPdfDocument.closerefuses to run while aDocumentorCanvasbuilt on it still holds queued content, replacing the silently empty file with an explicit error; the newPendingLayoutContentcontract is what that check reads. -
Form-field flag setters return
Future<void>instead ofvoid, matchingsetReadOnlyand the other setters onPdfFormFieldthat already did:setRadio,setToggleOff,setPushButton,setRadiosInUnison,setCombo,setEdit,setSort,setMultiSelect,setSpellCheck,setCommitOnSelChange,setTopIndex,setFileSelect,setScroll,setComb,setRichText,setBackgroundLayerandsetSignatureAppearanceLayer. They write the flag asynchronously, and thevoidsignature hid that the write had not happened yet when they returned.PdfCanvas.setRenderingIntentandTransparentColor.applyFillTransparency/applyStrokeTransparencybecame asynchronous for the same reason. -
Removed the legacy
Craftprefix from 481 API identifiers before the first publication. For example,CraftPdfDocument,CraftPdfName, andCraftSvgConverterbecamePdfDocument,PdfName, andSvgConverter. -
Renamed
CraftListtoPdfListinstead ofListto avoid shadowing Dart's core collection type.