Repository navigation
·
10 commits
to develop
since this release
Changelog
Breaking Changes
- Recipe
info()without arguments reports the custom keys of a source PDF
in their own spelling, as the PDF stores them, instead of lower-cased:
info().reportidis nowinfo().ReportId; see
Breaking Changes
#996 - Recipe
info()without arguments returns{}for a new PDF, and for a
source without an Info dictionary, instead ofundefined, and includes the
values set on the Recipe, as@muhammara/wasm
does; see
Breaking Changes
#996 - Recipe
custom()withtitle,author,subjectorkeywordssets that
field, asinfo()and@muhammara/wasmdo, instead of writing a custom
/titleentry; see
Breaking Changes
#996 - Recipe
info()andcustom()throw aTypeErrorforTrapped, the
source-Creator,source-Producerandsource-ModDateentries and an empty
key, which used to write custom entries. Recipe writes these itself; use
another key.Trappedis only carried over from a source PDF; see
Breaking Changes
#996 - Recipe
info(options)afterendPDF()throwsPDF writer has ended, as
@muhammara/wasmdoes, instead of ignoring the values; set them before
endPDF()#996 - The native packages need Node.js 20.19 or later on the 20 line, or 22.12 or
later on the 22 line. The line-breaking dependencylinebreak2.0.0 is
ESM-only, so an older Node.js failsrequire("@muhammara/native")with
ERR_REQUIRE_ESM. Upgrade Node.js; see
Breaking Changes
Added
- Write PDF/A documents with the new
pdfaRecipe option,
{ level, iccProfile, outputCondition }: PDF/A-1b, 2b, 2u, 3b, 3u, 4, 4e
and 4f (Recipe.PdfA), with the PDF version of the level, XMP metadata that
identifies it, and an output intent with the caller's ICC profile, given as
a Buffer or a path. Recipe throws where the document would not conform:
transparency in PDF/A-1, colors the profile does not describe, hidden
annotations, annotations without an appearance stream from PDF/A-2 on,
custom Info entries in PDF/A-4, and encryption; see
Write PDF/A Documents #1000 - Attach files to a new PDF with Recipe
attach(name, file, options), with a
MIME type, a description, and how each file relates to the document
(Recipe.AFRelationship) #1000 - Remove the creation or modification date of an Info dictionary with
setCreationDate(null)andsetModDate(null)#1000 - Write XMP metadata that mirrors the Info dictionary with the new
xmpoption
of Recipe, and read the XMP packet of a source PDF withrecipe.xmp(). An
edit keeps the existing packet, or, withxmp: true, replaces it with one
built from the Info values the PDF is written with
#996 - Draw right-to-left text such as Hebrew in visual order when
writeText()
or Recipetext()is given the newdirectionoption (TextDirection/
Recipe.TextDirection)."auto"takes each paragraph's direction from its
first strong letter, and"ltr"and"rtl"set it. Text is reordered with
the Unicode Bidirectional Algorithm (bidi-js,
MIT, a new dependency of@muhammara/native-core): numbers and Latin
words inside Hebrew keep their order, brackets
are mirrored, points are drawn on their letters, and invisible direction
marks are neither drawn nor measured. Recipe reorders each wrapped line with the direction and levels of its
whole paragraph, also across the styled runs of an HTML line,
places justified words from right to left, and ends the last line of a
justified right-to-left paragraph at the right edge;textDimensions()
takes the same option, andtable()takes it for the table and each
column, whose headers take it too. The default,"none", draws text exactly as given,
as before; see Write Right-to-Left Text
#330 - Support Electron 39 through 44 on macOS x64, which used to stop at 38.1
#984 - Strike out
<s>and<strike>text in Recipe HTML, as<del>already does
#936 - Add Recipe
formFields()to list the AcroForm fields of an existing PDF
with their object IDs, fully qualified names, kinds, values, flags, options
and widgets, and theRecipe.FormFieldKindandRecipe.FormFieldFlag
constants to compare them against
#992 - Add Recipe
fillForm()to fill text, checkbox, radio, combo box and list
box fields of an existing PDF by name or id, drawing a new appearance
stream for each changed widget, or setting/NeedAppearanceswith
appearances: "viewer", dropping the/XFAof a form that also has
fields, and theRecipe.FormAppearancesconstant
#992
Fixed
- Throw "The Recipe has no source PDF to read" from Recipe
structure()for a new PDF instead of claiming the reader was released byendPDF()#1016 - A dictionary's
writeKey()andwrite*Value()methods throw
Dictionary context is no longer activeafter the dictionary was passed to
ObjectsContext.endDictionary(),startPDFStream()or
startUnfilteredPDFStream(). Passing such a dictionary, or one of another
writer that has ended, tostartPDFStream()orstartUnfilteredPDFStream()
throws aTypeErrorProvide the active dictionary context, as
@muhammara/wasmdoes; so does a dictionary of a writer event that has
returned. Before, these calls terminated the process or wrote after the
dictionary's end
#1039 ObjectsContext.startPDFStream()andstartUnfilteredPDFStream()throw a
TypeErrorProvide the active dictionary contextfor an open dictionary
that is not the innermost onestartDictionary()opened: an outer
dictionary while an inner one is open, a dictionary of another writer, or a
writer event's dictionary while the event runs.startPDFStream()throws
Unable to start PDF streamfor a dictionary that already has the/Length
key, or the/Filterkey while compression is on, and
startUnfilteredPDFStream()throwsUnable to start unfiltered PDF stream
for one that has/Length. The errors match@muhammara/wasm.
Before, the returned stream terminated the process on use, and a writer
event's dictionary madewritePage()fail or wrote an unreadable PDF
#1055- Decrypt PDFs whose crypt filter selects RC4 with
/CFM /V2, the name the
PDF specification uses. Their strings and streams were returned still
encrypted, andrecrypt()wrote them out unchanged
#1026 - Read the document's XMP metadata stream (the catalog's
/Metadata) of an
encrypted PDF that keeps its metadata unencrypted (/EncryptMetadata false)
as stored, instead of decrypting it into unreadable bytes, sorecrypt()
keeps the packet intact
#1027 - Decrypt streams that name their own crypt filter (
/Filter /Crypt) when
they are copied from an encrypted PDF (appendPDFPagesFromPDF(),
mergePDFPagesToPage(),createFormXObjectsFromPDF(),
createPDFCopyingContext(),recrypt(), RecipeappendPage()), and drop
that filter from the copy, instead of copying the encrypted bytes that
readers cannot decode
#1028 writeLiteralString(),writeHexString(),startPDFStream()and
startUnfilteredPDFStream()of the objects context, a dictionary's
writeLiteralStringValue(), and a copying context'scopyDirectObjectAsIs()
andcopyDirectObjectWithDeepCopy()throw anErrorwhen a writer created
with a password has no indirect object open, instead of terminating the
process. On a writer created withversion: ePDFVersion20, and for direct
copies that contain no strings, these calls used to succeed and now throw as
well; callstartNewIndirectObject()first
#1029ObjectsContext.endIndirectObject()throwsUnable to end indirect object
when no indirect object is open, as@muhammara/wasmdoes. Before, it wrote
a strayendobj, and on a writer with a password it aborted the process
#1030ObjectsContext.endIndirectObject()right afterendPDFStream(), which
already ends the object, writes nothing. Before, it wrote a secondendobj,
which also appeared in RecipereplaceText()output
#1030ObjectsContext.startNewIndirectObject()andstartModifiedIndirectObject()
throwUnable to start indirect objectand
Unable to start modified indirect objectwhile another indirect object is
open or when the object cannot be started, such as an ID that is already
written, and aRangeErrorObject ID must be positivefor ID0, as
@muhammara/wasmdoes. Before, they wrote a nested object or failed
silently #1030- Recipe
editPage()throws aRangeErrorfor a page number that is not an
existing page (such as1.5,0, a page past the end, or the string"1"),
as@muhammara/wasmdoes, instead of an internalTypeError
#1023 - Open a Recipe from a
Uint8Arrayor anArrayBuffersource, andread()
one, as@muhammara/wasmdoes, instead of throwing
src.toLowerCase is not a functionorUnable to start parsing PDF file;
another non-string source throws aTypeErrorthat names the accepted types
#1009 - Decrypt strings and streams correctly when a PDF encrypted with RC4 or
AES-128 (security handler revision 2 to 4) is opened with its owner password,
instead of returning garbled text without an error. AES-256 was not affected
#1002 - Set the field when Recipe
info()orcustom()gets the Info name of a
standard field, such asTitle, instead of writing a value without a key,
which broke or overrode the Info dictionary. Creator, Producer, CreationDate
and ModDate,
which Recipe writes itself, throw aTypeErrorbefore any entry is set
#996 - Keep the custom entries of a source PDF that are named like Recipe's own
fields (creator,modDate,trapped) when Recipe edits it, and write the
source-Creator,source-Producerandsource-ModDateof the edited source
over those it carries from an earlier edit, as@muhammara/wasmdoes
#996 - Start the objects that native Recipe appends to an output file when it writes
annotations on their own line, after the%%EOFof the first pass, as PDF/A
requires #1000 - Keep the custom text Info entries of a source PDF, empty ones included, in their
original spelling when Recipe edits it. They used to be dropped by the next
edit
#996 - Keep the custom Info entries set with Recipe
info()orcustom()when the
Recipe also writes annotations. They used to be dropped
#996 - Keep a title, author, subject or keywords set through the low-level writer
of a Recipe that edits a PDF, as@muhammara/wasmdoes.endPDF()used to
write the value of the source over it
#996 - Leave a custom Recipe
info()value that isnullorundefinedout of the
PDF instead of writing the textnullorundefined, as@muhammara/wasm
does #996 - Write a Recipe
keywordsarray, and an array passed tocustom(), as
comma-and-space-separated text, as@muhammara/wasmdoes, instead ofa,b
#996 - Turn a rotated Recipe
rectangle()withoutrotationOriginaround its
top-left corner, as documented and as in@muhammara/wasm, instead of its
bottom-left corner. PassrotationOrigin: [x, y + height]to keep the old
pivot #923 - Apply
rotationin Recipeline(), clockwise around its first point or
rotationOrigin, as in@muhammara/wasm. The option was validated but the
line was drawn unrotated #925 - Draw a stroked Recipe
circle()withrotation. Its placing matrix had
nanoffsets, which PDF viewers reject #922 - Turn Recipe text links with rotated text, so the link covers the turned text
instead of the unrotated line box #926 - Keep the box padding in Recipe
text()with a boxheightorminHeight
and a bottom or centertextAlign. Bottom-aligned text ended flush with the
box, and centered text ignored unequal padding #935 - Wrap Recipe HTML text that follows an inline element at the text box width,
and keep justified HTML inside its box #891, #905 - Keep the spaces that start a line of Recipe text: in a flow before
movedown(), and on any line that ends with a line break, also when the
text is right or center aligned #906 - Add the markup annotations of flowed Recipe text (
highlight,underline,
strikeOut,squiggly) over the run that sets them, instead of from the
call that ends the flow over the whole line #909 - Keep the first line of flowed Recipe text whose box has
textBox.wrapof
trim,clip, orellipsis, instead of dropping runs, and stop throwing a
TypeErrorwhen a run continues a line withellipsis#913, #928 - Align flowed Recipe text as the call that ends the flow sets it, as in
@muhammara/wasm, so the runs of a line no longer overlap or leave a gap
#918 - Continue the open line of flowed Recipe text up to a line break in a later
run, instead of gluing the words on either side of the break together
#927 - Justify flowed Recipe text line by line, with one gap width per line and a
left-aligned last line, so runs no longer overlap or run past the box
#929 - Stop drawing a line feed that ends a Recipe HTML text node or an inline
element; it ends the line instead #931 - Lay out Recipe HTML runs with the font and size they are drawn in, so the
run after bold or italic text no longer overlaps it, bold and italic lines
get their face's baseline and line height, andh1–h3andsmalltext
wraps at its own size #937 - End a flowed Recipe line at every paragraph separator that ends a run:
\r, vertical tab, form feed, U+0085, U+2028 and U+2029 no
longer draw as missing glyphs with the next run on the same line, as\n
already did, text written after a flow that ends with one starts below
the flow instead of over its last line, and a plain line ending in U+0085
no longer ends a missing glyph short of the right edge
#330 - Keep the spaces a Recipe line starts with when a line break ends it, in a
text box or a flow, ormovedown()ends a flowed line, as Wasm does; they
were dropped only on such lines, and so was the space a later run on such
a line starts with, so styled or flowed runs touched
#330 - Keep the space that the first element of a flowed HTML run starts with,
as in<span> 6 7</span>, inside that element, as Wasm does; it was
dropped, so the run touched the text before it
#330 - Keep a figure space (U+2007) or a narrow no-break space (U+202F) at the
start and end of a Recipe line, as the no-break space (U+00A0) already was
and as Wasm does #330 - Write no link annotation without width for Recipe text, such as for a run
of only spaces at the end of a line or a justified HTML line whose link
ended before it started, as Wasm does
#330 - Lay out a long Recipe text flow in time that grows with its runs: each
flowedtext()call copied and searched every run the flow had, so a
flow built word by word took time with the square of its words
#330 - Measure the line height of a Recipe font once for each size instead of for
everytext()call, which took about a millisecond each
#330 - Write the Recipe
structure()of a PDF without an Info dictionary, such as
one written by pdf-lib, instead of throwing
Cannot read properties of undefined (reading 'getType'); trailer entries
the PDF lacks are skipped
#1008 - Reference the Node.js types from the native type declarations, so TypeScript
6 and later resolveBuffer,EventEmitterandNodeJSin
@muhammara/nativewithout"node"incompilerOptions.types - Keep the Info entries of the source, such as
Title,Authorand custom
entries, in a PDF modified with the low-levelcreateWriterToModify(), and
start the writer'sgetDocumentContext().getInfoDictionary()with them, so
that set values replace them. The update wrote an Info dictionary with only a
newModDate, and readers showed none of the others
#1053 - Let a custom Info entry added with
addAdditionalInfoEntry()under the key
of a field (Title,Author,Subject,Keywords,Creator,Producer,
CreationDate,ModDateorTrapped) replace that field, on every writer,
includingcreateWriter(). With the field already set, the repeated key was
refused but its value still written, so the Info dictionary could not be read
and readers showed none of its entries
#1053 - Let an Info field set after a custom entry under its key replace that entry,
on every writer:title,author,subject,keywords,creator,
producer,trapped,setCreationDate()andsetModDate()after
addAdditionalInfoEntry()with the field's key, such asTitle, also when
they clear the field; clearing used to keep the entry. The custom value was
still written after the field, so the Info dictionary could not be read and
readers showed none of its entries. Atrappedset that throws now leaves the
Info dictionary as it was; it used to setTrappedtoTrue
#1056
Changed
- Recipe
info()of a source that needs its user password returns{}
instead of throwing, the newxmp()returnsundefinedfor it, and
endPDF()throws as@muhammara/wasmdoes, instead of
unable to create copying context:
Editing a password-protected source is unsupported; decrypt it with recrypt() first
#996 - Test the native prebuilds up to Node.js 26.11.1 and Electron 44.7.1
#984 - Update the test dependency
serialize-javascript(pulled in bymocha)
from 7.1.2 to 7.1.4 for its security fix. Only the repository's tests use
it; installed packages are unaffected. - Check the npm, GitHub Actions, and docs requirements dependencies weekly
with Dependabot
#867 - Update the documentation-build dependency
mkdocs-materialfrom 9.7.7 to
9.8.1. Only the repository's documentation site uses it; installed
packages are unaffected. - Update the test dependencies
minimatchto 11.0.9 andglobto 14.0.6
(pulled in bymochaandjest) for the minimatch security fix
GHSA-g3hv-75wg-m249. Only the repository's tests use them; installed
packages are unaffected.
#1057
Pull requests
- #884 Draw right-to-left (Hebrew) text in visual order by @julianhille, closes #330
- #982 Prepare native 7.2.0 and Wasm 1.2.0 releases by @julianhille, closes #981
- #987 Raise tested Node.js and Electron upper limits by @julianhille, closes #984
- #988 Fix Recipe text, HTML and vector parity between native and Wasm by @julianhille, closes #891, #904, #905, #906, #909, #910, #913, #918, #922, #923, #924, #925, #926, #927, #928, #929, #931, #933, #934, #935, #936, #937, #969
- #999 Write and read XMP metadata, keep custom Info entries, and align Recipe info() on both ends by @julianhille, closes #996
- #1001 Write PDF/A documents from Recipe by @julianhille, closes #1000
- #1004 Add Recipe formFields() to read AcroForm fields by @julianhille
- #1005 Read an encrypted Wasm Recipe source with its password by @julianhille, closes #1003
- #1010 Read Wasm dictionary keys that are not valid UTF-8 by @julianhille, closes #1007
- #1011 Add Recipe fillForm() to fill AcroForm fields by @julianhille
- #1012 Decrypt RC4 and AES-128 PDFs correctly with the owner password by @julianhille, closes #1002
- #1013 Accept Uint8Array and ArrayBuffer sources in native Recipe by @julianhille, closes #1009
- #1015 Write Recipe structure() of a PDF without /Info by @julianhille, closes #1008
- #1017 Bump markdown-it from 14.3.2 to 14.3.3 by @dependabot[bot]
- #1019 Bump serialize-javascript from 7.1.2 to 7.1.4 by @dependabot[bot]
- #1020 Bump undici from 7.30.0 to 7.30.1 by @dependabot[bot]
- #1024 Reject a page number that is not an existing page in native editPage() by @julianhille, closes #1023
- #1025 Merge native 7.2.3 and Wasm 1.2.3 into develop by @julianhille
- #1032 Decrypt PDFs whose RC4 crypt filter is named /CFM /V2 by @julianhille, closes #1026
- #1033 Read the XMP of an encrypted PDF that keeps its metadata unencrypted by @julianhille, closes #1027
- #1034 Decrypt streams with their own crypt filter when copying from an encrypted PDF by @julianhille, closes #1028
- #1035 Throw a clear error for strings and streams written outside an indirect object on an encrypted writer by @julianhille, closes #1029
- #1037 Reject unbalanced indirect object starts and ends in native ObjectsContext, as Wasm does by @julianhille, closes #1030
- #1038 Copy encrypted sources that open without a password in Wasm append and merge, as native does by @julianhille, closes #1031
- #1041 Check dependencies weekly with Dependabot by @julianhille, closes #867
- #1042 Bump the docs-requirements group across 2 directories with 1 update by @dependabot[bot]
- #1044 Split the paragraph separator text-direction test per separator by @julianhille, closes #1043
- #1045 Bump the npm-minor-and-patch group with 5 updates by @dependabot[bot]
- #1046 Bump chai from 4.5.0 to 6.3.0 by @dependabot[bot]
- #1047 Bump typescript from 5.9.3 to 7.0.2 by @dependabot[bot]
- #1048 Bump jsdom from 29.1.1 to 31.0.0 by @dependabot[bot]
- #1049 Bump @types/node from 22.20.4 to 26.6.6 by @dependabot[bot]
- #1050 Bump the github-actions group across 1 directory with 2 updates by @dependabot[bot]
- #1059 Require approval before publishing to npm by @julianhille, closes #1058
- #1060 Raise the test dependencies minimatch to 11 and glob to 14 by @julianhille, closes #1057
- #1061 Throw a clear error for a native dictionary used after it was ended, as Wasm does by @julianhille, closes #1039
- #1062 Throw a clear error in Wasm Recipe overlay() and appendPage() for a PDF that needs a password by @julianhille, closes #1040
- #1063 Keep the source Info entries when modifying a PDF on both ends by @julianhille, closes #1053
- #1064 Throw a clear error from Wasm Recipe splitPdf() for a PDF that needs a password by @julianhille, closes #1054
- #1065 Throw instead of returning an unusable stream from native stream starts by @julianhille, closes #1055
- #1066 Let an Info field set after a same-named custom entry replace it on both ends by @julianhille, closes #1056
- #1069 Read the Wasm Recipe source through the modifier's parser by @julianhille, closes #1068
- #1071 Bump puppeteer-core from 25.16.0 to 25.17.0 in the npm-minor-and-patch group by @dependabot[bot]
- #1072 Bump linebreak from 1.1.0 to 2.0.0 by @dependabot[bot]
- #1073 Merge native 7.2.4 and Wasm 1.2.4 security release back into develop by @julianhille
- #1074 Release ended Wasm modifier readers from their tracking lists by @julianhille, closes #1070
- #1075 Add StructureFormat.TREE to Wasm Recipe structure() by @julianhille, closes #1016
Contributors
Full changelog: native-v7.2.4...native-v7.3.0