Skip to content

pdf_manipulator 6.0.0-dev.0

Pre-release
Pre-release

Choose a tag to compare

@github-actions github-actions released this 08 Nov 20:33
· 0 commits to b774fc69ac86df6cae1d3d746023960e2c748c42 since this release

6.0.0 runs every operation in bounded engine memory: a 10,000-page file opens, saves, merges and extracts its text in under 16 MB, where it took up to 163 MB. Redaction removes everything under the box, not only the text; compress and every full save write smaller files; and the API is rebuilt around one input type, one page-set type, one error family and three ways to call it. Migrating from 5.0.1: the migration guide has the before and after code for every breaking change below.

  • Action: engine updated — web: re-run flutter pub run pdf_manipulator:setup --force web (native updates itself)
  • Breaking: DataSource has a new close(), and DataSink has new abort(Object reason) and close(), where the library calls abort on the sink of an operation that ends cancelled or failed → implement all three in your own sources and sinks (clear a buffer, truncate a file, cancel an upload); the built-in ones do
  • Breaking: FileSource and FileSink.create are await FileSource.open(file) and await FileSink.open(file), and whoever opens a source or sink closes it → await the factory and call close() when the job is over
  • Breaking: open, edit, merge, split, compress, sign and every other call that opens a PDF take a PdfInput where they took a DataSource and a password: → write PdfInput(source, password: 'x'); PdfFile(file) and PdfInput.owning open and close the source for the job
  • Breaking: PdfDoc is PdfDocument, and pdf.open, pdf.edit and pdf.build return the owning PdfDocumentHandle, PdfEditorHandle and PdfBuilderHandle, the only types with dispose and save → rename the type; pdf.read, pdf.rewrite and pdf.buildTo dispose for you
  • Breaking: the one-shots deletePages, reorderPages, movePage, rotatePages, rotateAllPages, flattenForms, embedFile, watermark, addStamp, addImageStamp and convertToPdfA are removed → call the edit on pdf.editOnce(input, output), for example .removePages(PdfPages.single(0)), or put several edits in one pdf.rewrite
  • Breaking: the applyRedactions one-shot is removed → call applyRedactions() in a pdf.rewrite body
  • Breaking: eraseRegions and clearEraseRegions, on the editor and as a one-shot, are removed → call redact(page, regions, overlay: const PdfRedactionOverlay.none()), or clearRedactions() to drop queued marks
  • Breaking: the encrypt and decrypt one-shots are removed → call pdf.resave(input, output, save: PdfSave.full(encryption: PdfEncryption.password(ownerPassword: 'x'))), or PdfEncryption.remove() with PdfInput(source, password: 'x') to decrypt
  • Breaking: extractPages is removed → call pdf.editOnce(input, output).keepPages(PdfPages.list([0, 2])) to keep pages in document order, or reorderPages(PdfPageOrder([2, 0])) for another order
  • Breaking: split, splitBySize and splitByBookmarks are one split(input, sinkFor, by: ...) with PdfSplitRule.every(n), .maxBytes(n) or .bookmarks(), and sinkFor takes the PdfSplitPart it is for → rename the call; it returns the parts (index, first page, end page, bookmark title) and no byte sizes
  • Breaking: compress has no garbageCollect parameter, since it always collects garbage, and its images default is PdfImagePolicy.lossless where it was ebook → drop the argument, and pass images: PdfImagePolicy.ebook for the old result
  • Breaking: imagesToPdf gives every page the image's own size, one point per pixel, where it drew each image on an A4 page → pass page: const PdfImagePage(size: PdfImagePageSize.fixed(PdfPageSize.a4())) to keep A4 pages
  • Breaking: convertTo and convertToPdf are convertToOffice(input, output, format:) and convertFromOffice(document, output, format:), and PdfDocumentFormat is PdfOfficeFormat → rename the calls and the type
  • Breaking: registerFallbackFont takes the font as a DataSource, which it reads whole, where it took Uint8List bytes → wrap the bytes: MemorySource(bytes)
  • Breaking: the title, author, subject, keywords, creator, producer and creationDate of PdfDoc are fields of doc.metadata (PdfMetadata), and creationDate is a UTC DateTime? where it was a raw PDF date string → read doc.metadata.title
  • Breaking: the isEncrypted, requiresPassword, encryptionAlgorithm and permissions of PdfDoc are fields of doc.encryption (PdfEncryptionInfo), which is null when the document is not encrypted → read doc.encryption?.permissions
  • Breaking: PdfDoc.pages is gone, and opening a document no longer reads the pages → call await doc.pageInfo(), or doc.pageInfo(pages: PdfPages.single(0)) for one page
  • Breaking: PdfPageInfo has page, mediaBox, cropBox and a PdfRotation rotation, where it had index, an int rotation and width and height as fields (they stay as getters) → read info.page, and compare info.rotation with PdfRotation.r90
  • Breaking: extract({pages, format}) is text({pages, format}), which returns the string, and extractText(output, {pages, format}), which writes it to a sink as the engine produces it → call await doc.text(); pages is optional
  • Breaking: search(query:, pages:) is search(query, {pages}), and SearchResult is PdfSearchHit with the same fields → drop the label and rename the type
  • Breaking: render returns a Future of the PdfRenderedPage descriptors and writes each page to the sink that sinkFor returns, where it returned a Stream of RenderedPage with the bytes; pages is optional → pass (page) => MemorySink(), or call doc.bitmap(0) for one page's bytes
  • Breaking: extractImages returns a Future of PdfImageInfo and writes each image to the sink that sinkFor returns, where it returned a Stream of PdfImage with the bytes; pages is optional → pass (image) => sink
  • Breaking: PdfRenderSize(maxWidth:, maxHeight:) and PdfRenderSize.thumbnail(n) are PdfRenderSize.fit(maxWidth:, maxHeight:), and PdfRenderSize.dpi(n) is new → rename the constructor; thumbnail(n) is fit(maxWidth: n, maxHeight: n)
  • Breaking: the document's signatures, formFields, xfa and attachments and the editor's pageCount, version and isModified are methods, where they were getters → add the parentheses: await editor.pageCount()
  • Breaking: PdfDoc.formField(name) is gone → find the field in await doc.formFields()
  • Breaking: validatePdfA and validatePdfUa answer a PdfValidationReport (isCompliant, errorCount, warningCount) and take a PdfALevel or PdfUaLevel, where PdfValidationResult had compliant, errors and warnings, validatePdfUa answered a bool and level was an int → read report.isCompliant
  • Breaking: convertToPdfA takes a PdfALevel (a1, a2, a3) and defaults to a2, where it took an int and defaulted to level 1 → pass level: PdfALevel.a1 for the old default
  • Breaking: planSplitByBookmarks is bookmarkRanges(), and PdfBookmarkSplit with startPage and endPage is PdfBookmarkRange with start and end → rename the call and the fields
  • Breaking: classifyPage is classifyPages({pages}), a page's type string and confidence are a kind (PdfPageKind), and classifyDocument answers a PdfDocumentKind where it answered a PdfDocumentClassification → read result.first.kind
  • Breaking: PdfFormField has kind (PdfFormFieldKind, with textField, pushButton and signatureField), isReadOnly and isRequired, where it had type (PdfFormFieldType), readOnly and required; PdfCheckedValue.checked is isChecked → rename the fields and the type
  • Breaking: the value of a radio group, combo box or list box reads as PdfChoiceValue with the selected option (PdfMultiChoiceValue for several, PdfNoValue for none), where a radio group read as PdfCheckedValue and the others as PdfTextValue → match on PdfChoiceValue
  • Breaking: size of PdfAttachment is sizeBytes, serial of PdfCertificateInfo is serialNumber, and regions of PdfRedactionReport is regionCount → rename the fields
  • Breaking: PdfSignatureInfo has a required coversWholeDocument parameter → pass it where you construct one, in test fakes for example
  • Breaking: the fields of PdfPermissions are canPrint, canPrintHighQuality, canModify, canCopy, canAnnotate, canFillForms, canExtractForAccessibility and canAssemble, where they were print, printHq, modify, copy, annotate, fillForms, accessibility and assemble, and toBits is gone → rename the arguments and the fields
  • Breaking: monoPpi and minSavings of PdfImagePolicy are bilevelPpi and minSavingsRatio, and PdfImageOutcome has bitsPerComponent, isIndexed, minPpi and placementCount where it had bits, indexed, ppiMin and uses → rename the fields
  • Breaking: rotation of PdfWatermarkStyle is angleDegrees → rename the argument
  • Breaking: PdfExtractionFormat.plainText is plain and .text is layout, and PdfEncryptionAlgorithm has rc4Key40, rc4Key128, aesKey128 and aesKey256 where it had rc4_40, rc4_128, aes128 and aes256 → rename the values
  • Breaking: PdfConfig(webLaneWorkerUrl:, maxLanes:) is PdfConfig(webWorkerUrl:, concurrency:) → rename the arguments; concurrency defaults to max(2, cores / 2) operations at once
  • Breaking: the setTitle, setAuthor, setSubject, setKeywords, setProducer and setCreationDate of the editor and the builder are one setMetadata(PdfMetadata), which replaces the standard fields, and the editor reads them with metadata() → change one with setMetadata((await editor.metadata()).copyWith(title: 'X'))
  • Breaking: rotatePage, rotateAllPages and setPageRotation are rotatePages(by:, pages:) and setRotation(rotation, pages:), which take a PdfRotation (r0, r90, r180, r270) where they took degrees: → call rotatePages(by: PdfRotation.r90)
  • Breaking: pageMediaBox, pageCropBox, setPageMediaBox and setPageCropBox are pageInfo({pages}) with mediaBox and cropBox, setMediaBox(box, {pages}) and setCropBox(box, {pages}) → a null crop box removes the crop box
  • Breaking: deletePage is removePages(PdfPages), which throws PdfEngineFailed for a page the document does not have, or for every page → call removePages(PdfPages.list([1, 3]))
  • Breaking: selectPages is keepPages(PdfPages), which keeps the pages in document order, and reorderPages(PdfPageOrder), which keeps them in the order given → call reorderPages(PdfPageOrder([2, 0, 1])) to keep the old order
  • Breaking: mergeFrom(source, {pages}) is appendPages(PdfInput, {pages}), and pages is a PdfPages where it was a list of indexes → pass PdfInput(source, password: 'x') for an encrypted source
  • Breaking: addWatermark(page, text) is addWatermark(text, {pages}) with every page as the default, and a page of -1 no longer means every page → pass pages: const PdfPages.all()
  • Breaking: addStamp(page, type:, rect:) and addImageStamp(page, image, rect:) are addStamp(stamp, bounds:, pages:) and addImageStamp(image, bounds:, pages:), and PdfStampType is PdfStamp → write addStamp(PdfStamp.draft, bounds: r)
  • Breaking: embedFile is addAttachment → rename the call
  • Breaking: flattenForms({int? page}) and flattenAnnotations({int? page}) take pages (a PdfPages, every page by default) → write flattenForms(pages: PdfPages.single(0))
  • Breaking: addRedaction is markRedaction(page, regions, {overlay}), since the engine never drew the overlay text → pass PdfRedactionOverlay.fill(color) for a box of that colour, or PdfRedactionOverlay.none()
  • Breaking: the editor's setFormFieldValue, setCheckboxFieldValue, removeFormField and the other setFormField… methods are on editor.field(name) as setValue, setReadOnly, setRequired, setTooltip, setBounds, setMaxLength, setAlignment, setBackgroundColor, setBorderColor, setBorderWidth, setAppearance, setFlags and remove → write editor.field('name').setValue(const PdfFormFieldValue.text('Ada'))
  • Breaking: resizeImage and repositionImage are removed, and pageImages returns PdfImagePlacement where it returned PdfPageImage → call setImageBounds(page, name, bounds) with the size and position you want
  • Breaking: scrubMetadata and sanitize(PdfSanitizeOptions) are sanitize({stripMetadata, stripJavaScript, stripAttachments}), where PdfSanitizeOptions had metadata, javascript and embeddedFiles → call sanitize(stripJavaScript: false) for scrubMetadata()
  • Breaking: PdfSaveOptions is PdfSave, and PdfSaveOptions.fullRewrite(compress:, garbageCollect:, encryption:) is PdfSave.full(deflate:, garbageCollect:, encryption:) with a PdfDeflate level; save(output, options:) is save(output, save:) and exists only on the handles → rename the class and the arguments
  • Breaking: PdfSaveOptions with incremental() now appends the edits to the original bytes, so a signature over them stays valid, and throws PdfIncrementalRefused when an append cannot carry them (pages removed or reordered, redaction, content edits, an encrypted or repaired source) → catch it and save with PdfSave.full()
  • Breaking: PdfEncryption.config is PdfEncryption.password(ownerPassword:, userPassword:, algorithm:, permissions:), whose userPassword is null for a document that opens without one and whose algorithm defaults to aesKey256 → rename the call
  • Breaking: the subclasses PdfPagesAll, PdfPagesSingle, PdfPagesList, PdfPagesRange, PdfEncryptionKeep, PdfEncryptionRemove, PdfEncryptionConfig, PdfSaveFullRewrite, PdfSaveIncremental, PdfWatermarkCenter, PdfWatermarkCorner, PdfWatermarkTiled, PdfWatermarkExact, PdfPkcs12Credentials and PdfPemCredentials are not exported → call the factory, for example PdfPages.single(0) or PdfEncryption.keep()
  • Breaking: PdfColor and every result and options type (PdfPageInfo, PdfImagePolicy, PdfRect and the rest) are final with value == and hashCode → replace an extends or implements of one with a wrapper
  • Breaking: PdfPages.list is not const, sorts the indexes, and throws ArgumentError for an empty list, a negative index or an index given twice, where it kept the list as given; PdfPages.from(start) is new → write PdfPages.list([3, 1])
  • Breaking: the bottom of a PdfRect is its lower edge, y, where it was y + height → read top for the upper edge; PdfRect.fromEdges builds a rectangle from left, bottom, right and top
  • Breaking: PdfInvalidArgument is removed: a programmer mistake (an empty list, a negative page, a second call on a one-shot) throws ArgumentError or StateError before any I/O, and an engine refusal throws PdfEngineFailed → catch PdfError for runtime failures only
  • Breaking: PdfIoError, PdfEngineError, PdfPageRangeError and PdfCryptoError are PdfIoFailed, PdfEngineFailed, PdfPageOutOfRange and PdfCryptoFailed → rename the type in each catch and switch
  • Breaking: PdfSearchError and PdfExtractionFailed are removed, since nothing threw them → delete their catch clauses and switch cases; engine failures arrive as the other PdfError subtypes
  • Breaking: PdfError has two new subtypes, PdfNotFound (a missing attachment or image) and PdfIncrementalRefused → add a case to every exhaustive switch over PdfError
  • Breaking: addA4Page, addLetterPage and addPage(width:, height:) are addPage([PdfPageSize]) → call addPage(), addPage(PdfPageSize.letter()) or addPage(PdfPageSize.points(400, 300))
  • Breaking: the page builder's font and at are setFont(name, size) and moveTo(PdfPoint(x, y)), and done() and newPageSameSize() are removed → a page ends when the next is added or the document is saved
  • Breaking: the page builder's fieldKeystroke, fieldFormat, fieldValidate and fieldCalculate, and its linkUrl and linkPage, are arguments of the call that writes the field or text → pass scripts: const PdfFieldScripts(format: 'x') or link: const PdfLink.url('https://example.com')
  • Breaking: the page builder's textField takes value where it took defaultValue, checkbox takes isChecked where it took checked, and radioGroup takes PdfRadioOption(value, bounds) where options were records → rename the arguments
  • Breaking: PdfTextAlignment is PdfAlignment, and the page builder's image(data, rect, {altText}) is image(data, bounds, {altText}) where a null altText places an artifact → rename the type; pass altText: 'x' for a described image
  • Added redact(page, regions, {overlay}), which marks and applies its own regions in one step and returns the report — marks queued before stay queued, and an error leaves nothing marked or applied
  • Added PdfRedactionOverlay, fill(color) or none(): a redaction with no overlay removes the content and draws no box
  • Added PdfEditor.clearRedactions(), and field(name).setTooltip, setMaxLength, setBackgroundColor and setBorderColor take null to remove the tooltip, the limit or the colour
  • Added PdfFormFieldValue.choice, .choices and .none: field(name).setValue selects an option of a combo box or list box, the options of a multi-select list box, or clears the value, and refuses an option the field does not list
  • Added PdfDocument.annotations(page), which lists a page's annotations (subtype, rectangle, contents, author, form field name) as PdfAnnotationInfo
  • Added the page builder calls the engine already had: appendText, textIn, rect, line, stickyNote(..., at:), stamp(PdfStamp...), freeText, onOpen, onClose and table(columns, rows, {options}) with PdfTableCell and PdfTableOptions, and a PdfTextStyle, PdfMarkup or PdfLink argument on text
  • Added PdfBuilder.addImagePage, a page that holds one picture and takes the picture's own size unless you name one
  • Changed PdfBuilder.save to Flate-compress page content and font streams; save(output, deflate: false) keeps them plain for debugging
  • Added BlobSource (package:pdf_manipulator/web.dart), which the worker reads in place with FileReaderSync in JSPI, Atomics and Asyncify, and copies to OPFS itself in OPFS mode: a File from a picker opens with no main-thread read and O(1) memory at any size
  • Added the web Asyncify mode, asyncify: true under hooks: user_defines: pdf_manipulator:, which ships the Asyncify wasm so a browser with neither JSPI nor SharedArrayBuffer streams instead of copying to storage first — it is 28 MB for the full engine and is fetched only where OPFS cannot run
  • Changed web sources of any other kind that fit in 16 MiB per lane to be copied into the worker once as a snapshot at job start instead of pre-copied to disk or read through the page, and a source past that budget takes the I/O mode's own path
  • Changed the web wasm to ship as parts of 16 MiB listed in pdf_oxide_manifest.json, which the browser joins into one stream as it compiles, so no file reaches the 25 MiB limit of static hosts; apps that list pdf_oxide_bg.wasm re-run setup and list the parts
  • Changed the web mode the package picks by itself to Atomics first where the page has SharedArrayBuffer, then JSPI, OPFS and Asyncify, since Atomics measured faster than JSPI on every source
  • Changed open, edit, split, a full-rewrite save and compress to hold a bounded window of the document instead of all of it: a 38 MB, 10,000-page file now opens and saves in under 16 MB of engine memory, where it took up to 85 MB
  • Changed edit to open the source once; an editor used to hold the document twice
  • Changed opening a damaged file (no cross-reference table, or a wrong one) and reading objects packed in object streams to scan the file in fixed windows: a 64 MB damaged file opens in under 16 MB of engine memory, and the 1 MB and 32 MB caps are gone
  • Changed appendPages to keep the merged file open until the editor is disposed and copy its objects one at a time at save: merging a 10,000-page file takes under 16 MB of engine memory and about 2 seconds, where it took 163 MB and minutes
  • Changed page edits on a document with merged pages: removePages, movePage, keepPages, rotation, media box and crop box apply to a merged page, where they refused, hit the wrong page or crashed the engine; stamps, watermarks and redactions on a merged page throw PdfUnsupported
  • Changed reading a source to fetch it in 64 KB pieces instead of one round trip per read: compressing a 70-page scan takes 18 ms on native, where it took 29 ms, and a third less time on the web
  • Changed text extraction of every page to stream one page at a time from the engine, so a 10,000-page file extracts in under 16 MB of engine memory
  • Changed render and extractImages to deliver each page or image to its sink as the engine produces it, where they held every page until the last; cancelling the task stops the engine
  • Changed addAttachment, extractAttachment, addImageStamp, convertToPdfA, a page's image list, a large rewritten stream and the text of form fields to be read and written in pieces, never whole: a 64 MiB attachment or image goes in or out in under 16 MB of engine memory
  • Changed image decoding for render, reduceImages, extractImages and imagesToPdf (JPEG, fax, interlaced PNG, palettes, raw samples, CIDToGIDMap fonts) to read only what the file declares, from the stream, so a 64 MiB image stays under 16 MB of engine memory; a fax image the engine cannot read is declined at its open
  • Changed a full-rewrite save to copy each unchanged stream from the source in 64 KB pieces, so a page holding a 60 MB image saves in under 1 MB of engine memory
  • Changed applyRedactions to rewrite each page one operator at a time while the document saves: redacting a page with 9 million operators takes under 1 MB of engine memory
  • Changed a full-rewrite save to pack objects into object streams with a cross-reference stream (PDF 1.5), where it unpacked them and could write a file six times larger than its source; PdfSave.full(useObjectStreams: false) writes the classic layout
  • Added PdfSave.full(deflate:), how hard a full save deflates its streams (PdfDeflate.none, fast, balanced or best, default best); a full save re-deflates Flate streams at that level and keeps a stream's source bytes when the result is not smaller
  • Changed compress and every full save to recompress copied page content, pack object streams fuller, drop orphan /Length objects, rewrite LZW as Flate and deflate like native zlib level 9: on 13 public test files a lossless compress is now smaller than pdf_document 12.0.0's on 12 and equal on 1, where it was up to 6 times larger
  • Changed compress to write the source unchanged when its result is not smaller
  • Changed compress to write one copy of identical images, ICC profiles and embedded fonts; PdfSave.full(mergeDuplicates: true) does the same for any full save, across every merged source
  • Changed compress to drop the fonts, images, colour spaces and other resources a page lists but no content of it uses, keeping any resource some content might use; PdfSave.full(pruneResources: true) does the same for any full save
  • Changed compress to subset embedded TrueType and CID CFF fonts: outlines no content shows are emptied, glyph ids and tables kept, fonts of form fields left whole; a subset that is not smaller is not written
  • Changed PdfImagePolicy.screen to re-encode a stored JPEG at its quality even when the image is not downsampled (recompressJpeg: true); ebook and print still keep stored JPEGs
  • Changed verifySignatures to check each signature's digest and signer key, where it returned false for every document; PdfSignatureInfo has isValid, coversWholeDocument and signingTime filled
  • Changed registerFallbackFont so a second registration of a kind replaces the first and reaches only the Pdf that made it, where the font was shared by every instance of the process
  • Changed cancellation to stop text extraction, search, validation, redaction, reduceImages, convertToPdfA, image bounds changes and saves within one page or operator, and to reach merge, split, compress, rendering, bookmarkRanges, classifyPages and the opening of a damaged file, where each ran to its end; on the web this needs a cross-origin isolated page
  • Changed cancel() when the operation finished before the cancel landed: the task resolves with its result, so a finished edit is not reported as cancelled; an open or edit that finished is closed and reports PdfCancelled
  • Changed Pdf instances to lease their web workers and native threads from one shared pool, so creating and disposing instances in a loop reuses them instead of starting a new one each time
  • Changed every engine worker, native and web, to be retired once an operation's heap peaked past 32 MB, where only a web worker past 256 MB of WebAssembly memory was
  • Changed convertFromOffice and convertToOffice to bound hostile .doc, .xls, .ppt and ZIP input, to keep what a cut-off .docx, .pptx or .xlsx holds before the damage, and to write DOCX tables with no widths that Word no longer collapses (office_oxide 0.1.16)
  • Changed the Rust needed to build the engine from source (build: size, build: debug, a trimmed keep:) to 1.93 or newer, since the engine's per-thread memory count needs it on Android; the build says so and names the rustup command
  • Changed the size of the default engine to 25.5 MB native and 9.0 MB gzipped on the web, from 22.7 MB and 7.7 MB, with the code the bounded memory and the fixes need; render now adds 2.4 MB where it added 4.8 MB, and office adds 5.4 MB where it added 2.9 MB
  • Fixed keepPages, split and removePages writing the pages they drop into the output, so the output kept its original size and the dropped pages' text, images and form values — a save now writes nothing only a dropped page reaches, and drops the links, bookmark targets and form fields that pointed at one (#261 reported by @crurui)
  • Fixed sign dropping the document's bookmarks, form fields, page labels and every other catalog entry, and replacing an earlier signature — the signature now appends to the existing form and page (#263)
  • Fixed sign writing a cross-reference table that other readers had to repair — each entry is now 20 bytes
  • Fixed PdfSignatureInfo showing a non-ASCII signer name, reason or location as garbled text — UTF-16 text strings are decoded
  • Fixed a save that keeps an encrypted document's encryption setting its owner password to the password it was opened with, so anyone who could open the result had owner rights and its permissions were void — the save now reuses the source's own encryption dictionary and key
  • Fixed PdfEncryptionInfo.permissions reporting the wrong flags (a print-allowed file read as canPrint: false) — the engine's /P word is read at its spec bit positions
  • Fixed a save after markRedaction without applyRedactions drawing a black box over text it never removed, so the file looked redacted and the text could still be copied — an unapplied redaction is saved as a redaction mark (a /Redact annotation) and the page content is left as it was
  • Fixed applyRedactions leaving the pixels of images under a redacted area in the file — a covered image is removed, a partly covered one is copied with the covered pixels filled (only the 8×8 blocks under the area for a JPEG), masks included, and other pages keep the original
  • Fixed applyRedactions leaving drawings, clip shapes, gradient meshes and form content under a redacted area in the file — they are removed or cut at the area's edge, and a form other pages show is copied for the redacted page only
  • Fixed applyRedactions leaving traces of the removed text in the file: font widths, Unicode mappings, Type 3 glyph procedures (a flattened field's font included) and alt text, in the structure tree or inside page content — entries only the removed text used are cleared
  • Fixed applyRedactions dropping every annotation on a redacted page — only the annotations under a redacted area go, with their form fields
  • Fixed a form field flattened and redacted on one page keeping its value under the box — flattening now runs before redaction
  • Fixed an applyRedactions refused on a later page leaving the earlier pages redacted while the call reported the error — it redacts every page or none
  • Fixed a cancelled or failed reduceImages leaving the images it had already re-encoded staged, so a later save wrote half the reduction — it stages nothing unless every image is done
  • Fixed a cancelled or failed convertToPdfA leaving the editor half converted, or converted while the call reported the error — the editor is as it was before the call
  • Fixed an operation whose last write failed or was cancelled still reporting success with its output cut short — the engine now flushes the final bytes before it answers, and a refusal fails or cancels the operation
  • Fixed page labels shifting onto the wrong pages after keepPages, split, removePages or a reorder — each kept page keeps its label
  • Fixed PdfPageInfo.label always being null — it now holds the page's label when the document has page labels
  • Fixed a merged page losing the resources, page size and rotation it inherited from its source page tree, which could leave it blank
  • Fixed a merge copying the source's whole page tree into the output when a merged page linked to a page that was not merged — such a link's target is written as null
  • Fixed an empty input to merge or any other multi-source op shifting every source after it, so the op read the wrong documents — an empty input now throws PdfCorrupted
  • Fixed compress and every other full-rewrite save dropping the document's title, author, dates and file identifier unless the title was edited — the saved file keeps the source's /Info and /ID, and an edited title replaces the old /Info instead of leaving it behind
  • Fixed the same input saving to different bytes on every run, so compress and every other rewriting save could not be compared or cached by hash — objects are written in id order, so only the random AES IVs of an encrypted save differ
  • Fixed a full-rewrite save of a file with no /Size writing new objects over existing ones, and dropping an object it could not read without a word — it now throws PdfCorrupted
  • Fixed a full-rewrite save of a file holding objects above generation 0 writing references other readers resolve to nothing — each reference now names the generation its object is written at
  • Fixed a full-rewrite save writing an object over 100 MB truncated — it throws instead
  • Fixed rotatePages and other per-page edits slowing down with the square of the page count on large documents
  • Fixed flattenForms() and flattenAnnotations() of every page leaving pages unflattened after a page was deleted or moved, addImageStamp stamping the page the index named before the deletion, and a second image stamp on a page replacing the first
  • Fixed watermarks placed in a corner, tiled or at an exact rectangle all landing at default spots — every position is placed where it says; an unknown corner name is refused
  • Fixed image bounds edits saving the page unchanged without an error when its content could not be rewritten — the save now fails
  • Fixed PdfPageBuilder.radioGroup always failing with "unknown pageOp"
  • Fixed a radio option named Yes, No, On or Off reading back as a checked flag instead of its name
  • Fixed formFields misreading a field whose type, flags or value live on an ancestor field (a radio group read as a checkbox), and reporting a nameless parent as a field with an empty name
  • Fixed page builder calls on a disposed or unknown builder being queued without an error — each call now applies at once and fails where it is made
  • Fixed image() with bytes that are not an image succeeding and drawing nothing — it throws PdfEngineFailed
  • Fixed a page index past the end reaching the engine as a huge number or a generic error — every operation that takes a page throws PdfPageOutOfRange with the page and the page count
  • Fixed a source that fails to read while a document opens throwing PdfCorrupted — it now throws PdfIoFailed, so a broken source is told from a broken file
  • Fixed a source whose read fails once being absorbed, so an open or an op went on and succeeded without the bytes — the op now ends with PdfIoFailed
  • Fixed a web source read past 4 GiB returning the bytes at the offset modulo 4 GiB, with no error — the read offset crosses to the engine as a JS number, not a 32-bit integer
  • Fixed render and extractImages returning an empty stream when the engine failed, a page past the end included — they throw the engine's error
  • Fixed a page tree whose inner nodes each hold one page reporting those nodes as pages — every node is read before it counts as a page
  • Fixed text extraction of a page with many separate text runs on one line taking minutes to hours — a million characters now extract in about three seconds
  • Fixed text extraction of a page that names thousands of fonts holding every font at once (472 MB for 20,000 fonts, now 46 MB): font caches are bounded by bytes and a page reads the fonts it shows as it shows them
  • Fixed text extraction of a tagged document holding its whole structure tree and every page's tagged content at once (1.75 GiB for 600,000 elements) — it walks the tree for the page it reads; XFA forms are parsed as a stream of events instead of read whole
  • Fixed article threads longer than 4,096 beads being cut short and tables wider than 128 columns being missed, and a hostile CMap or xref stream size aborting the engine — XMP metadata is now read as a stream of events
  • Fixed TrueType text rendering letters the PDF never named: "fi" shown as two glyphs drew the "fi" ligature, and other font substitutions changed what was drawn — the renderer draws exactly the glyphs the content names
  • Fixed render ignoring line width, caps, joins, miter limit and dashes set through a graphics state resource (gs), which drew such lines 1 pt wide and solid
  • Fixed render drawing outlined text (text rendering modes 1, 2, 5 and 6) filled in the fill colour — the glyph outline is stroked in the stroke colour and line style
  • Fixed render drawing strokes and text painted with a tiling pattern in a flat colour — the pattern now shows inside the stroke or the glyphs
  • Fixed fit and thumbnail sizes of render coming out smaller than asked on pages with a crop box
  • Fixed images with fewer than 8 bits a sample and the TIFF predictor decoding to wrong pixels
  • Fixed 16-bit images and images with several colours below 8 bits a sample decoding to wrong pixels when stored with a PNG or TIFF predictor
  • Fixed a failed open or edit keeping its source channel until the instance was disposed
  • Fixed a native crash when a job was cancelled while its sink was still writing: the late write touched freed memory
  • Fixed a cancelled read on a document held open sending its late answer to the next job on that document, which then read the wrong bytes
  • Fixed an operation on a disposed document reaching another open document that happened to have the same engine id — it fails with "document not found"
  • Fixed cancel() on a job still waiting behind another one waiting for that job to end — it resolves at once; on JSPI a cancel during a sink write no longer waits for the write
  • Fixed one failed web worker start making every later operation of that Pdf fail — the next operation starts a worker again
  • Fixed a lane that panicked (native) or trapped (web) going on to serve jobs on broken engine state — the lane ends, operations on its documents fail with a typed error, and new work goes to a new lane
  • Fixed builder.save, editor.save and extractAttachment succeeding in web OPFS mode when the sink threw, and a slow sink piling chunks up in memory — the worker now spools output to disk and the sink is awaited chunk by chunk, so its error fails the op
  • Fixed a Pdf that was never disposed keeping its workers, lanes and registered fonts for good — they are released when it is garbage collected, with a debug warning
  • Fixed the blob URL of a cross-origin worker bootstrap never being revoked — it goes once the worker has started or failed to
  • Fixed text extraction giving wrong characters for fonts whose ToUnicode CMap ends lines with a bare CR, puts several ranges on one line or splits a range's array across lines — every range entry is read
  • Fixed a full save writing a PDF name that contains a delimiter such as ( or < unescaped, so the name ended early and the rest of its dictionary was misread — delimiters are written as #XX
Commits since v5.0.1-dev.0 (10)
  • b774fc6 release: v6.0.0-dev.0
  • 9c0f86e feat!: 6.0.0: bounded memory, complete redaction, a new API and a migration guide from every version (#262)
  • f4cec27 chore: bump the deps group across 1 directory with 6 updates (#272)
  • fd31eef chore: refresh lockfiles (#266)
  • 99f8c0a chore: bump pinned versions (#267)
  • ac6cec9 chore: bump Flutter SDK (#265)
  • 56a5a1f ci: bump all action refs (workflows + composites) (#264)
  • e28b2a6 chore: refresh lockfiles (#260)
  • f08b245 Merge branch 'prod' into dev
  • 02ae148 release: promote dev → prod (v5.0.0) (#250)

Install (git tag)

dependencies:
  pdf_manipulator:
    git:
      url: https://github.com/whuppi/pdf_manipulator.git
      ref: v6.0.0-dev.0

Install (pub.dev)

dependencies:
  pdf_manipulator: ^6.0.0-dev.0