Repository navigation
pdf_manipulator 6.0.0-dev.0
Pre-release
Pre-release
·
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:
DataSourcehas a newclose(), andDataSinkhas newabort(Object reason)andclose(), where the library callsaborton 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:
FileSourceandFileSink.createareawait FileSource.open(file)andawait FileSink.open(file), and whoever opens a source or sink closes it → await the factory and callclose()when the job is over - Breaking:
open,edit,merge,split,compress,signand every other call that opens a PDF take aPdfInputwhere they took aDataSourceand apassword:→ writePdfInput(source, password: 'x');PdfFile(file)andPdfInput.owningopen and close the source for the job - Breaking:
PdfDocisPdfDocument, andpdf.open,pdf.editandpdf.buildreturn the owningPdfDocumentHandle,PdfEditorHandleandPdfBuilderHandle, the only types withdisposeandsave→ rename the type;pdf.read,pdf.rewriteandpdf.buildTodispose for you - Breaking: the one-shots
deletePages,reorderPages,movePage,rotatePages,rotateAllPages,flattenForms,embedFile,watermark,addStamp,addImageStampandconvertToPdfAare removed → call the edit onpdf.editOnce(input, output), for example.removePages(PdfPages.single(0)), or put several edits in onepdf.rewrite - Breaking: the
applyRedactionsone-shot is removed → callapplyRedactions()in apdf.rewritebody - Breaking:
eraseRegionsandclearEraseRegions, on the editor and as a one-shot, are removed → callredact(page, regions, overlay: const PdfRedactionOverlay.none()), orclearRedactions()to drop queued marks - Breaking: the
encryptanddecryptone-shots are removed → callpdf.resave(input, output, save: PdfSave.full(encryption: PdfEncryption.password(ownerPassword: 'x'))), orPdfEncryption.remove()withPdfInput(source, password: 'x')to decrypt - Breaking:
extractPagesis removed → callpdf.editOnce(input, output).keepPages(PdfPages.list([0, 2]))to keep pages in document order, orreorderPages(PdfPageOrder([2, 0]))for another order - Breaking:
split,splitBySizeandsplitByBookmarksare onesplit(input, sinkFor, by: ...)withPdfSplitRule.every(n),.maxBytes(n)or.bookmarks(), andsinkFortakes thePdfSplitPartit is for → rename the call; it returns the parts (index, first page, end page, bookmark title) and no byte sizes - Breaking:
compresshas nogarbageCollectparameter, since it always collects garbage, and itsimagesdefault isPdfImagePolicy.losslesswhere it wasebook→ drop the argument, and passimages: PdfImagePolicy.ebookfor the old result - Breaking:
imagesToPdfgives every page the image's own size, one point per pixel, where it drew each image on an A4 page → passpage: const PdfImagePage(size: PdfImagePageSize.fixed(PdfPageSize.a4()))to keep A4 pages - Breaking:
convertToandconvertToPdfareconvertToOffice(input, output, format:)andconvertFromOffice(document, output, format:), andPdfDocumentFormatisPdfOfficeFormat→ rename the calls and the type - Breaking:
registerFallbackFonttakes the font as aDataSource, which it reads whole, where it tookUint8Listbytes → wrap the bytes:MemorySource(bytes) - Breaking: the
title,author,subject,keywords,creator,producerandcreationDateofPdfDocare fields ofdoc.metadata(PdfMetadata), andcreationDateis a UTCDateTime?where it was a raw PDF date string → readdoc.metadata.title - Breaking: the
isEncrypted,requiresPassword,encryptionAlgorithmandpermissionsofPdfDocare fields ofdoc.encryption(PdfEncryptionInfo), which is null when the document is not encrypted → readdoc.encryption?.permissions - Breaking:
PdfDoc.pagesis gone, and opening a document no longer reads the pages → callawait doc.pageInfo(), ordoc.pageInfo(pages: PdfPages.single(0))for one page - Breaking:
PdfPageInfohaspage,mediaBox,cropBoxand aPdfRotationrotation, where it hadindex, anintrotationandwidthandheightas fields (they stay as getters) → readinfo.page, and compareinfo.rotationwithPdfRotation.r90 - Breaking:
extract({pages, format})istext({pages, format}), which returns the string, andextractText(output, {pages, format}), which writes it to a sink as the engine produces it → callawait doc.text();pagesis optional - Breaking:
search(query:, pages:)issearch(query, {pages}), andSearchResultisPdfSearchHitwith the same fields → drop the label and rename the type - Breaking:
renderreturns aFutureof thePdfRenderedPagedescriptors and writes each page to the sink thatsinkForreturns, where it returned aStreamofRenderedPagewith the bytes;pagesis optional → pass(page) => MemorySink(), or calldoc.bitmap(0)for one page's bytes - Breaking:
extractImagesreturns aFutureofPdfImageInfoand writes each image to the sink thatsinkForreturns, where it returned aStreamofPdfImagewith the bytes;pagesis optional → pass(image) => sink - Breaking:
PdfRenderSize(maxWidth:, maxHeight:)andPdfRenderSize.thumbnail(n)arePdfRenderSize.fit(maxWidth:, maxHeight:), andPdfRenderSize.dpi(n)is new → rename the constructor;thumbnail(n)isfit(maxWidth: n, maxHeight: n) - Breaking: the document's
signatures,formFields,xfaandattachmentsand the editor'spageCount,versionandisModifiedare methods, where they were getters → add the parentheses:await editor.pageCount() - Breaking:
PdfDoc.formField(name)is gone → find the field inawait doc.formFields() - Breaking:
validatePdfAandvalidatePdfUaanswer aPdfValidationReport(isCompliant,errorCount,warningCount) and take aPdfALevelorPdfUaLevel, wherePdfValidationResulthadcompliant,errorsandwarnings,validatePdfUaanswered a bool andlevelwas anint→ readreport.isCompliant - Breaking:
convertToPdfAtakes aPdfALevel(a1,a2,a3) and defaults toa2, where it took anintand defaulted to level 1 → passlevel: PdfALevel.a1for the old default - Breaking:
planSplitByBookmarksisbookmarkRanges(), andPdfBookmarkSplitwithstartPageandendPageisPdfBookmarkRangewithstartandend→ rename the call and the fields - Breaking:
classifyPageisclassifyPages({pages}), a page'stypestring andconfidenceare akind(PdfPageKind), andclassifyDocumentanswers aPdfDocumentKindwhere it answered aPdfDocumentClassification→ readresult.first.kind - Breaking:
PdfFormFieldhaskind(PdfFormFieldKind, withtextField,pushButtonandsignatureField),isReadOnlyandisRequired, where it hadtype(PdfFormFieldType),readOnlyandrequired;PdfCheckedValue.checkedisisChecked→ rename the fields and the type - Breaking: the value of a radio group, combo box or list box reads as
PdfChoiceValuewith the selected option (PdfMultiChoiceValuefor several,PdfNoValuefor none), where a radio group read asPdfCheckedValueand the others asPdfTextValue→ match onPdfChoiceValue - Breaking:
sizeofPdfAttachmentissizeBytes,serialofPdfCertificateInfoisserialNumber, andregionsofPdfRedactionReportisregionCount→ rename the fields - Breaking:
PdfSignatureInfohas a requiredcoversWholeDocumentparameter → pass it where you construct one, in test fakes for example - Breaking: the fields of
PdfPermissionsarecanPrint,canPrintHighQuality,canModify,canCopy,canAnnotate,canFillForms,canExtractForAccessibilityandcanAssemble, where they wereprint,printHq,modify,copy,annotate,fillForms,accessibilityandassemble, andtoBitsis gone → rename the arguments and the fields - Breaking:
monoPpiandminSavingsofPdfImagePolicyarebilevelPpiandminSavingsRatio, andPdfImageOutcomehasbitsPerComponent,isIndexed,minPpiandplacementCountwhere it hadbits,indexed,ppiMinanduses→ rename the fields - Breaking:
rotationofPdfWatermarkStyleisangleDegrees→ rename the argument - Breaking:
PdfExtractionFormat.plainTextisplainand.textislayout, andPdfEncryptionAlgorithmhasrc4Key40,rc4Key128,aesKey128andaesKey256where it hadrc4_40,rc4_128,aes128andaes256→ rename the values - Breaking:
PdfConfig(webLaneWorkerUrl:, maxLanes:)isPdfConfig(webWorkerUrl:, concurrency:)→ rename the arguments;concurrencydefaults tomax(2, cores / 2)operations at once - Breaking: the
setTitle,setAuthor,setSubject,setKeywords,setProducerandsetCreationDateof the editor and the builder are onesetMetadata(PdfMetadata), which replaces the standard fields, and the editor reads them withmetadata()→ change one withsetMetadata((await editor.metadata()).copyWith(title: 'X')) - Breaking:
rotatePage,rotateAllPagesandsetPageRotationarerotatePages(by:, pages:)andsetRotation(rotation, pages:), which take aPdfRotation(r0,r90,r180,r270) where they tookdegrees:→ callrotatePages(by: PdfRotation.r90) - Breaking:
pageMediaBox,pageCropBox,setPageMediaBoxandsetPageCropBoxarepageInfo({pages})withmediaBoxandcropBox,setMediaBox(box, {pages})andsetCropBox(box, {pages})→ a null crop box removes the crop box - Breaking:
deletePageisremovePages(PdfPages), which throwsPdfEngineFailedfor a page the document does not have, or for every page → callremovePages(PdfPages.list([1, 3])) - Breaking:
selectPagesiskeepPages(PdfPages), which keeps the pages in document order, andreorderPages(PdfPageOrder), which keeps them in the order given → callreorderPages(PdfPageOrder([2, 0, 1]))to keep the old order - Breaking:
mergeFrom(source, {pages})isappendPages(PdfInput, {pages}), andpagesis aPdfPageswhere it was a list of indexes → passPdfInput(source, password: 'x')for an encrypted source - Breaking:
addWatermark(page, text)isaddWatermark(text, {pages})with every page as the default, and a page of-1no longer means every page → passpages: const PdfPages.all() - Breaking:
addStamp(page, type:, rect:)andaddImageStamp(page, image, rect:)areaddStamp(stamp, bounds:, pages:)andaddImageStamp(image, bounds:, pages:), andPdfStampTypeisPdfStamp→ writeaddStamp(PdfStamp.draft, bounds: r) - Breaking:
embedFileisaddAttachment→ rename the call - Breaking:
flattenForms({int? page})andflattenAnnotations({int? page})takepages(aPdfPages, every page by default) → writeflattenForms(pages: PdfPages.single(0)) - Breaking:
addRedactionismarkRedaction(page, regions, {overlay}), since the engine never drew the overlay text → passPdfRedactionOverlay.fill(color)for a box of that colour, orPdfRedactionOverlay.none() - Breaking: the editor's
setFormFieldValue,setCheckboxFieldValue,removeFormFieldand the othersetFormField…methods are oneditor.field(name)assetValue,setReadOnly,setRequired,setTooltip,setBounds,setMaxLength,setAlignment,setBackgroundColor,setBorderColor,setBorderWidth,setAppearance,setFlagsandremove→ writeeditor.field('name').setValue(const PdfFormFieldValue.text('Ada')) - Breaking:
resizeImageandrepositionImageare removed, andpageImagesreturnsPdfImagePlacementwhere it returnedPdfPageImage→ callsetImageBounds(page, name, bounds)with the size and position you want - Breaking:
scrubMetadataandsanitize(PdfSanitizeOptions)aresanitize({stripMetadata, stripJavaScript, stripAttachments}), wherePdfSanitizeOptionshadmetadata,javascriptandembeddedFiles→ callsanitize(stripJavaScript: false)forscrubMetadata() - Breaking:
PdfSaveOptionsisPdfSave, andPdfSaveOptions.fullRewrite(compress:, garbageCollect:, encryption:)isPdfSave.full(deflate:, garbageCollect:, encryption:)with aPdfDeflatelevel;save(output, options:)issave(output, save:)and exists only on the handles → rename the class and the arguments - Breaking:
PdfSaveOptionswithincremental()now appends the edits to the original bytes, so a signature over them stays valid, and throwsPdfIncrementalRefusedwhen an append cannot carry them (pages removed or reordered, redaction, content edits, an encrypted or repaired source) → catch it and save withPdfSave.full() - Breaking:
PdfEncryption.configisPdfEncryption.password(ownerPassword:, userPassword:, algorithm:, permissions:), whoseuserPasswordis null for a document that opens without one and whosealgorithmdefaults toaesKey256→ rename the call - Breaking: the subclasses
PdfPagesAll,PdfPagesSingle,PdfPagesList,PdfPagesRange,PdfEncryptionKeep,PdfEncryptionRemove,PdfEncryptionConfig,PdfSaveFullRewrite,PdfSaveIncremental,PdfWatermarkCenter,PdfWatermarkCorner,PdfWatermarkTiled,PdfWatermarkExact,PdfPkcs12CredentialsandPdfPemCredentialsare not exported → call the factory, for examplePdfPages.single(0)orPdfEncryption.keep() - Breaking:
PdfColorand every result and options type (PdfPageInfo,PdfImagePolicy,PdfRectand the rest) arefinalwith value==andhashCode→ replace anextendsorimplementsof one with a wrapper - Breaking:
PdfPages.listis notconst, sorts the indexes, and throwsArgumentErrorfor an empty list, a negative index or an index given twice, where it kept the list as given;PdfPages.from(start)is new → writePdfPages.list([3, 1]) - Breaking: the
bottomof aPdfRectis its lower edge,y, where it wasy + height→ readtopfor the upper edge;PdfRect.fromEdgesbuilds a rectangle fromleft,bottom,rightandtop - Breaking:
PdfInvalidArgumentis removed: a programmer mistake (an empty list, a negative page, a second call on a one-shot) throwsArgumentErrororStateErrorbefore any I/O, and an engine refusal throwsPdfEngineFailed→ catchPdfErrorfor runtime failures only - Breaking:
PdfIoError,PdfEngineError,PdfPageRangeErrorandPdfCryptoErrorarePdfIoFailed,PdfEngineFailed,PdfPageOutOfRangeandPdfCryptoFailed→ rename the type in eachcatchandswitch - Breaking:
PdfSearchErrorandPdfExtractionFailedare removed, since nothing threw them → delete theircatchclauses andswitchcases; engine failures arrive as the otherPdfErrorsubtypes - Breaking:
PdfErrorhas two new subtypes,PdfNotFound(a missing attachment or image) andPdfIncrementalRefused→ add a case to every exhaustiveswitchoverPdfError - Breaking:
addA4Page,addLetterPageandaddPage(width:, height:)areaddPage([PdfPageSize])→ calladdPage(),addPage(PdfPageSize.letter())oraddPage(PdfPageSize.points(400, 300)) - Breaking: the page builder's
fontandataresetFont(name, size)andmoveTo(PdfPoint(x, y)), anddone()andnewPageSameSize()are removed → a page ends when the next is added or the document is saved - Breaking: the page builder's
fieldKeystroke,fieldFormat,fieldValidateandfieldCalculate, and itslinkUrlandlinkPage, are arguments of the call that writes the field or text → passscripts: const PdfFieldScripts(format: 'x')orlink: const PdfLink.url('https://example.com') - Breaking: the page builder's
textFieldtakesvaluewhere it tookdefaultValue,checkboxtakesisCheckedwhere it tookchecked, andradioGrouptakesPdfRadioOption(value, bounds)where options were records → rename the arguments - Breaking:
PdfTextAlignmentisPdfAlignment, and the page builder'simage(data, rect, {altText})isimage(data, bounds, {altText})where a nullaltTextplaces an artifact → rename the type; passaltText: '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)ornone(): a redaction with no overlay removes the content and draws no box - Added
PdfEditor.clearRedactions(), andfield(name).setTooltip,setMaxLength,setBackgroundColorandsetBorderColortake null to remove the tooltip, the limit or the colour - Added
PdfFormFieldValue.choice,.choicesand.none:field(name).setValueselects 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) asPdfAnnotationInfo - Added the page builder calls the engine already had:
appendText,textIn,rect,line,stickyNote(..., at:),stamp(PdfStamp...),freeText,onOpen,onCloseandtable(columns, rows, {options})withPdfTableCellandPdfTableOptions, and aPdfTextStyle,PdfMarkuporPdfLinkargument ontext - Added
PdfBuilder.addImagePage, a page that holds one picture and takes the picture's own size unless you name one - Changed
PdfBuilder.saveto 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 withFileReaderSyncin JSPI, Atomics and Asyncify, and copies to OPFS itself in OPFS mode: aFilefrom a picker opens with no main-thread read and O(1) memory at any size - Added the web Asyncify mode,
asyncify: trueunderhooks: user_defines: pdf_manipulator:, which ships the Asyncify wasm so a browser with neither JSPI norSharedArrayBufferstreams 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 listpdf_oxide_bg.wasmre-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 andcompressto 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
editto 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
appendPagesto 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 throwPdfUnsupported - 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
renderandextractImagesto 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,extractImagesandimagesToPdf(JPEG, fax, interlaced PNG, palettes, raw samples,CIDToGIDMapfonts) 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
applyRedactionsto 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,balancedorbest, defaultbest); a full save re-deflates Flate streams at that level and keeps a stream's source bytes when the result is not smaller - Changed
compressand every full save to recompress copied page content, pack object streams fuller, drop orphan/Lengthobjects, rewrite LZW as Flate and deflate like native zlib level 9: on 13 public test files a losslesscompressis now smaller than pdf_document 12.0.0's on 12 and equal on 1, where it was up to 6 times larger - Changed
compressto write the source unchanged when its result is not smaller - Changed
compressto 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
compressto 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
compressto 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.screento re-encode a stored JPEG at its quality even when the image is not downsampled (recompressJpeg: true);ebookandprintstill keep stored JPEGs - Changed
verifySignaturesto check each signature's digest and signer key, where it returnedfalsefor every document;PdfSignatureInfohasisValid,coversWholeDocumentandsigningTimefilled - Changed
registerFallbackFontso a second registration of a kind replaces the first and reaches only thePdfthat 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 reachmerge,split,compress, rendering,bookmarkRanges,classifyPagesand 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; anopenoreditthat finished is closed and reportsPdfCancelled - Changed
Pdfinstances 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
convertFromOfficeandconvertToOfficeto bound hostile.doc,.xls,.pptand ZIP input, to keep what a cut-off.docx,.pptxor.xlsxholds 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 trimmedkeep:) to 1.93 or newer, since the engine's per-thread memory count needs it on Android; the build says so and names therustupcommand - 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;
rendernow adds 2.4 MB where it added 4.8 MB, andofficeadds 5.4 MB where it added 2.9 MB - Fixed
keepPages,splitandremovePageswriting 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
signdropping 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
signwriting a cross-reference table that other readers had to repair — each entry is now 20 bytes - Fixed
PdfSignatureInfoshowing 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.permissionsreporting the wrong flags (a print-allowed file read ascanPrint: false) — the engine's/Pword is read at its spec bit positions - Fixed a save after
markRedactionwithoutapplyRedactionsdrawing 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/Redactannotation) and the page content is left as it was - Fixed
applyRedactionsleaving 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
applyRedactionsleaving 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
applyRedactionsleaving 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
applyRedactionsdropping 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
applyRedactionsrefused 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
reduceImagesleaving 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
convertToPdfAleaving 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,removePagesor a reorder — each kept page keeps its label - Fixed
PdfPageInfo.labelalways beingnull— 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
mergeor any other multi-source op shifting every source after it, so the op read the wrong documents — an empty input now throwsPdfCorrupted - Fixed
compressand 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/Infoand/ID, and an edited title replaces the old/Infoinstead of leaving it behind - Fixed the same input saving to different bytes on every run, so
compressand 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
/Sizewriting new objects over existing ones, and dropping an object it could not read without a word — it now throwsPdfCorrupted - 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
rotatePagesand other per-page edits slowing down with the square of the page count on large documents - Fixed
flattenForms()andflattenAnnotations()of every page leaving pages unflattened after a page was deleted or moved,addImageStampstamping 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.radioGroupalways 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
formFieldsmisreading 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 throwsPdfEngineFailed - 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
PdfPageOutOfRangewith the page and the page count - Fixed a source that fails to read while a document opens throwing
PdfCorrupted— it now throwsPdfIoFailed, 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
renderandextractImagesreturning 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
renderignoring 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
renderdrawing 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
renderdrawing 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
rendercoming 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
openoreditkeeping 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
Pdffail — 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.saveandextractAttachmentsucceeding 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
Pdfthat 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.0Install (pub.dev)
dependencies:
pdf_manipulator: ^6.0.0-dev.0