Repository navigation
chore(deps): update Rust crate printpdf to 0.13.0 - #260
Merged
Merged
Conversation
|
This pull request is merged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
0.12.0→0.13.0Release Notes
fschutt/printpdf (printpdf)
v0.13.0Compare Source
Added
The features
text_layout_hyphenation_allandhtml_hyphenation_allembed the hyphenation dictionaries of all 82 languages.text_layout_hyphenation, and sohtml, hyphenate English (US) only, which makes the binary 2.9 MB smaller (the WebAssembly demo was 13.8 MB).ppdf, a command-line tool inppdf/(its own crate, not part of the printpdf package). It converts a PDF to JSON and back so the document can be edited withjq, prints text, text boxes, SVG pages, fonts and images, and renders HTML to PDF. Seeppdf/README.md.web/minimal.html: a single HTML file that makes a PDF in the browser with two wasm calls. It imports the package of the latest release from the demo site, and is deployed with it. Described indocs/API.md.docs/HTML.mddocuments the HTML and CSS thatfrom_htmlsupports. It replacesSYNTAX.md, which described an API that no longer exists.The library denies
unwrap,expect,panic!,unreachable!,todo!, indexing and string slicing outside tests (clippy::unwrap_usedand its relatives, set insrc/lib.rs). A CI job runs clippy with--all-features,--no-default-featuresand--no-default-features --features text_layout. Onwasm32-unknown-unknowna panic traps and cannot be caught, so a failure has to come back as anErr, a warning or a skipped item.More than 180 regression tests for hostile input in
tests/no_panic_*.rs: crafted and mutated PDFs, fonts, images, dates, form values, CSS sizes and JSON of the wasm API.GeneratePdfOptions::show_page_numbers,header_text,footer_textandskip_first_pagedraw a header, a footer and page numbers on every page (azul-layout 0.0.21; they drew nothing before).Form XObjects are part of the document model. A form read from a PDF is an
XObject::Formwith its ownops,/BBoxand resources, and it is written back as a form.extract_text,extract_text_boxesandto_svgread the text and drawing inside forms (PDFs from macOS Quartz draw their whole page in one form; their text was empty before).FormXObject::new,with_matrix,with_resources,with_group,from_content_streamandPdfDocument::add_formcreate a form in code, for example a watermark that several pages draw.Variable fonts from Rust code (feature
text_layout):font_variation_axeslists the axes of a font,instantiate_variable_font_bytescreates a static font at chosen axis values, andPdfDocument::add_variable_fontregisters such an instance. TrueType (gvar) and CFF2 fonts work; a CFF2 instance is converted to CFF1, which a PDF can embed. The types areFontVariationTag,FontVariationAxis,FontVariationSettingsandVariableFontError. Based on #278 by NicTanghe.shape_lineturns a string into positioned glyphs in one font without HTML (featuretext_layout, nothtml): script and direction come from the text, kerning and mark offsets are applied, and the result is aPlacedLinewith thePlacedGlyphs and the width, ready forshow_placed_glyphs.LineShapershapes many lines in one font without copying the font each time.examples/shape_line.rsshows Latin, Arabic and mixed-direction lines (#229, #230).Patterns as fill and stroke colors.
Pattern::Tiling(a repeated drawing, colored or uncolored) andPattern::Shading(a gradient that fills or strokes the shape) are registered withPdfDocument::add_patternand selected withOp::SetFillPatternandOp::SetOutlinePattern. A PDF that sets/Pattern cs /P1 scnkeeps its fills and strokes when it is read, and patterns are written and read back in pages and forms. A pattern that has no model, such as a mesh shading, is kept asPattern::Externaland written as it was read. The SVG preview draws a pattern as one solid color, with a warning. Seeexamples/patterns.rs.Preflight (
printpdf::preflight):preflight_bytes,PdfDocument::preflightandPdfDocument::preflight_with_optionscheck a PDF and return aPreflightReportof findings, each with a severity, a stable rule id (RULESlists the 97 ids), a page, an object and, for some PDF/A-1b rules, the clause of the standard. Profiles:General(file structure, page tree, resources, colour spaces such as the malformed one behind #211, fonts, content stream balance),PdfA1b,PdfA2b,PdfX1a_2001andPdfX3_2002(embedded fonts, output intent, XMP and PDF/A identification, transparency, layers, encryption, JavaScript, LZW, page boxes, Info dictionary). The work and the number of findings are bounded, and hostile files do not panic (tests/no_panic_preflight.rs). It is not a certification and does not replace veraPDF or Acrobat Preflight;NOT_CHECKEDlists what it does not look at.ppdf check FILE [--profile general|pdfa-1b|pdfa-2b|pdfx-1a|pdfx-3] [--json]prints the report. Exit code 0: no errors, 1: errors found, 2: the file cannot be read.PDF/A-1b and PDF/A-2b files that pass printpdf's own preflight, and PDF/X-1a:2001 with its output intent. Saving a document with
PdfConformance::A1B_2005_PDF_1_4,A2B_2011_PDF_1_7(and the other PDF/A variants) writes: XMP metadata withpdfaid:partandpdfaid:conformanceand the title, author, subject, keywords, creator, producer and dates of the Info dictionary as the same values; an output intent with/S /GTS_PDFA1,/OutputConditionIdentifierand an embedded sRGB profile (the FOGRA39 profile when the document uses DeviceCMYK and no DeviceRGB); the header version 1.4 (PDF/A-1) or 1.7 (PDF/A-2 and 3); and the/Printflag on link annotations.tests/pdfa_output.rschecks this against the preflight and, whenverapdfis installed, against veraPDF 1.30 (--flavour 1band2b): the oracle document with built-in fonts only, with a TrueType font subset and complete, with and without stream compression, with grey, RGB or CMYK-only colour, and for PDF/A-2b with transparency pass. The PDF/X files,SymbolandZapfDingbats, levelaandu, and CFF fonts in PDF/A-1 are not covered.PDF/A-1 files get an sRGB output intent profile of ICC version 2.1, built at save time from the sRGB colorants and transfer function (PDF/A-1 is based on ICC version 2, and veraPDF rejects the bundled version 4 profile there). PDF/A-2 and 3 use the version 4 profile.
A PDF/A document whose output intent is the CMYK profile (it uses DeviceCMYK and no DeviceRGB) has the RGB
/Ccolour of its link annotations left out, with a warning, because PDF/A allows an annotation colour only with an RGB output intent.PDF/A-1 files get a
/CIDSetin the descriptor of every subset TrueType CID font.The 14 standard fonts are embedded when the conformance level requires embedded fonts (all PDF/A and PDF/X variants,
PdfConformance::must_embed_fonts). They are written as TrueType subsets with the same resource names,WinAnsiEncodingand codes in the content stream, so extracted text does not change.SymbolandZapfDingbatsstay unembedded because the font files that printpdf bundles for them are not the standard glyph sets; the save warns. The save also warns, naming the characters, when a bundled font has no glyph for a character of the text.Save warnings for content that the chosen standard forbids; the content is written as it is. Transparency (
/CAand/cabelow 1, soft masks, blend modes, transparency groups) in PDF/A-1, PDF/X-1a and PDF/X-3; layers in PDF/A-1, PDF/X-1a and PDF/X-3; the LZW filter, JavaScript and launch actions in PDF/A; JPEG 2000 and JBIG2 in PDF/A-1; embedded files in PDF/A-1 and 2; DeviceCMYK together with DeviceRGB in PDF/A (one output intent cannot cover both); DeviceRGB in PDF/X-1a.PdfConformance::is_pdfa,pdfa_part,pdfa_level,must_embed_fontsandis_transparency_allowed.A saved PDF/A file is read back as the PDF/A variant that its XMP names. It was
Custombefore, because the variant was only in/GTS_PDFXVersion.Changed
/Pattern cs /P1 scngivesOp::SetFillPattern(andOp::SetOutlinePatternforCSandSCN). Before, the name was read as the gray level 0, so the fill became black, andcswas read asOp::SetColorSpaceFill. A form that sets a pattern from its own resources is now read asXObject::Forminstead of being kept asXObject::External.PdfResourcesandPageStatehave a new field,patternsandpattern_spaces.MmandPtcompare NaN equal to NaN and an infinity equal to itself, sox == xholds for every value asEqrequires. Before,Mm(f32::NAN) == Mm(f32::NAN)was false (#292).web/, the documentation todocs/andgen.shtoscripts/gen-examples.sh.scripts/build-demo.shassembles the demo in_site/.web/,docs/andppdf/.docs/API.mdnow documents all seven functions of the wasm API. It listed five, used wrong option names (subsetFontsinstead ofsubset_fonts,pageWidthinstead ofpage_width) and atitleinput that does not exist.<head><header>and{builtin:pagenum}, which the layout engine does not implement.RawImage::encode_to_bytes,apply_ditheringandresize_to_fit_sizereturnErrwhen the pixel buffer is not exactlywidth * height * channelssamples, andencode_to_bytesalso for an image of size 0. They used to panic or abort inside the encoder.xml_to_pdf_pagesandxml_to_pdf_pages_debugreturnErrwhen the page, or the area inside the margins, is NaN or outside 1 to 1,000,000 pt.FormXObjecthasops,bboxand its ownresources(aPdfResources) instead ofbytes; its JSON changes. Forms that a PDF contains areXObject::Formand no longerXObject::External. A form that cannot be read without loss staysExternal, with an info message.to_svgmultiplies nestedcmoperators. It replaced the transform before.savewarns when a variable font added withadd_fontis embedded at its default instance. Useadd_variable_fontto choose the axes.PdfResourcesas their scope for fonts, images, graphics states and shadings.glyph-namesandencoding_rsdirectly (both were in the tree through allsorts).PtandMmorder byf32::total_cmp(-0.0 sorts before 0.0, NaN last), so==andcmpcan differ within the 0.0005 tolerance of==.Pxaddition and subtraction saturate.PageStatehas two more public fields,untracked_savesanduntracked_marked_content.PdfConformance::must_have_icc_profileistrueforX1A_2001_PDF_1_3. PDF/X-1a:2001 requires an output intent, and printpdf wrote none, so its files are larger by the FOGRA39 profile (650 KB before compression).must_have_xmp_metadataistruefor the PDF/A variants.avariants (A1A_2005_PDF_1_4,A2A_2011_PDF_1_7) writepdfaid:conformanceasBand the save warns that level a needs tagged document structure, which printpdf does not write.A2U_2011_PDF_1_7writesBtoo, because printpdf does not check that all text maps to Unicode.get_identifier_stringis unchanged./GTS_PDFXVersion. It named a PDF/X standard, and for PDF/A it held a string such asPDF/A-1b:2005.conformancemodule docs say what saving a standard writes, what it only warns about, and that the preflight is not a certification. The PDF/A-1b and PDF/A-2b test documents were checked with veraPDF 1.30; the PDF/X output was not.Documentation
#![warn(missing_docs)]keeps it that way. Remove history, issue numbers, pasted spec text and examples that did not compile; the 34 doctests all run.Removed
font_embeddingandimage_optimizationfields ofGeneratePdfOptions.from_htmlnever read them: fonts are always embedded, and image recompression isPdfSaveOptions::image_optimization. JSON that still contains the fields is accepted and the fields are ignored.render_to_svgandrender_to_svg_asyncare no longer public. UsePdfPage::to_svg,PdfPage::to_svg_asyncorPdfDocument::page_to_svg;PdfToSvgOptionsstays.subset.ttf,build.sh, a disabled shape test and two example files that were never registered.CHANGELOG2.mdis merged into this file.Fixed
pdf:Trapped, which veraPDF does not accept as a predefined property.xmp:CreateDate,xmp:ModifyDate,xmp:MetadataDate) are ISO 8601,2018-09-19T10:05:05+00:00. They had theD:prefix and the+00'00'offset of PDF dates, which XMP does not allow./DestOutputProfile. It used/DestinationOutputProfile, which readers do not look for.&or<made the XMP packet invalid XML.PdfConformance::is_layering_allowedisfalsefor PDF/A-1b and PDF/A-1a, which forbid optional content./Countnow counts only the bookmarks that are written./ToUnicodeor a Type0/Encoding) no longer panics on a multi-byte character inside a hex token such as<000é000>; the token is an error and only costs that font its map.begincidrangewhose destination runs pastu32::MAXmaps the affected codes to CID 0 (notdef) instead of overflowing./Nextcycle stops with a warning. References that fan out (a 2 KB file took 1.6 GB) are inlined within a budget of 2 million objects and 256 MiB per document. A page tree whose/Countis huge no longer panics withcapacity overflow(the parser,optimize_textand the form reader read the page list page by page). Image and soft-mask sizes that overflow are rejected. A form field value that refers to itself overflowed the stack: values are read to a depth of 8 and 4096 objects.RawImage::decode_from_bytessets limits of 512 MiB and 2^20 pixels per side.q,BMCandBDCnest at most 256 levels deep (deeper ones are counted and warned about once), and a repeatedWorW*on a path that is already clipped is skipped: 28 KB of them produced 4 million points. The SVG output capsqthe same way.usecmapchain no longer takes quadratic time, and the CFF width scan stops after 10,000 steps per glyph (subroutine fan-out hung it)./Wruns and the synthetic sfnt of a CFF font no longer overflow./Subtype /Type1with/FontFile3 /Type1C, as Quartz, Distiller and ps2pdf write it) survives parse and save. A bare CFF font had no character map, so no character found a glyph on save and the font was dropped, with the text unreadable. The font now gets a map from its glyph names (Adobe Glyph List)./Encoding(StandardEncoding,MacRomanEncoding,WinAnsiEncodingand/Differences) and the built-in encoding of its CFF program, where it used to read every code as WinAnsi (ƒtats-UnisforÉtats-Unis). With poppler as the reference, parse, save and parse again keeps 100% of the words of an Apple CFF PDF and about 80% of two TeX PDFs; it was 0%, 7% and 5%.PdfPage::to_svg,PdfDocument::page_to_svg, the wasmPdf_PageToSvg) escapes every string it takes from a PDF: the tags of marked content, marker ids, layer ids and names, link targets, font names and the names of unknown operators. A crafted PDF could add anonmouseoverattribute or a<script>element through them, which runs wherever the SVG is inlined into a page, as the web demo does. A link other thanhttp,https,mailto,telor a relative reference (javascript:,data:) is left out with a warning. Font names in the@font-facerule and the<text>elements keep only letters, digits and.,-,+,_.Configuration
📅 Schedule: (UTC)
🚦 Automerge: Enabled.
♻ Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.