What changed, from the point of view of someone who has to decide whether to install this version.
The format follows Keep a Changelog 1.1.0, and the version numbers
follow Semantic Versioning 2.0.0. A version gets an entry here
before it is tagged, not after: docs/release-checklist.md G3 refuses a release whose notes do not exist,
and a version with no notes is a version a consumer cannot evaluate.
1.0.0-preview.1 was published to nuget.org on 2026-10-15, as four packages — SharpCorePDF.Domain,
.Application, .Infrastructure and .DependencyInjection — pushed by publish.yml from tag
v1.0.0-preview.1. The SharpCorePDF entry point did not exist in that tree, so the only id on the feed
that a consumer could have installed was a layer. 1.0.0-preview.2 and 1.0.0-preview.3 were bumped here
and never pushed, which is why this file keeps no entries for them: there is no consumer of a version no
feed ever served.
1.0.0 is therefore the first version that changes the shape of the install rather than only the
contents of the layers, and the entry below is written against the published preview.1 rather than
against an empty feed.
-
Twelve independent validation checks, in CI.
validation.ymlputs the example output and a new validation corpus — written bytools/SharpCorePDF.Validation, with a manifest of the text, passwords, permissions, revisions and signature coverage each document must have — through qpdf, three text extractors, four readers of the RC4/AES encryption matrix (qpdf, MuPDF, pypdf, pdf.js), fontTools and OTS, PDFium against MuPDF, pyHanko, the incremental-update invariants and four synthesized hostile documents.robustness.ymlruns weekly: libFuzzer over the parser and the DCT, CCITT, LZW, Flate and RunLength decoders, the veraPDF and pdf.js corpora one process per file, and the PDF/A writer judged by veraPDF over the veraPDF corpus.compliance.ymlcross-validates PDF/A-4 too. No shipped package changes; nothing new reaches a consumer.docs/validation.mdrecords each check, how it was shown to fail before it was trusted, and the defects below. -
PdfEngineOptions.MaxDecodedStreamBytes(128 MiB by default) bounds what one stream may decode to.MaxSourceBytesbounds the input only, and Flate reaches about a thousand to one. -
PdfEngineOptions.MaxFormPaintsPerPage(100,000 by default) bounds how many times one page may paint a form XObject, across every level of forms inside forms; a page that reaches it is read as far as it got, with aPdfWarningKind.FormPaintLimitExceededremark.PdfWarningKind.PdfAFeatureRepairedreports an entry a PDF/A conversion set right in the copy.
-
Looking for signatures in a form no longer takes exponential time. The walk of the form's field tree was bounded in depth but followed every path, so a form whose levels each list the next level twice has two to the power of its depth paths: forty levels, a 2.6 KB file, and the validation never finished. The
documentfuzz target found it as a timeout. Each field is now read once, as the other field-tree walks already do. -
A media box whose digits overflow a double no longer crashes a read or an edit. A number too large for a double reads as infinite, and three readers passed it to a constructor that refuses it, so the
documentfuzz target found a 378-byte file that threwArgumentOutOfRangeExceptionfrom the inspection, the page reader and the edit engine. Such a box is now taken as unreadable, and the page is described as A4 with a remark, as one with no box is. -
A hybrid-reference file is read. Its classic table lists the objects it keeps in object streams as free, so a reader that knows no streams skips them, and describes them in the stream the trailer's
/XRefStmnames. The table kept the first entry it met, so the free entry hid the one in the stream, and such a file read as having no pages. The stream may now answer for the numbers its own section's table frees, and is read before the revision/Prevpoints at, as ISO 32000-1 7.5.8.4 orders them. -
An object stream no longer answers for an object the table places elsewhere. A stream still holds the copies it held when it was written, and loading it to resolve one object cached every object inside it: an object a later revision rewrote in the file body came back stale, and one a later revision freed came back from the dead, depending on which object was resolved first. Only the numbers the table places in a stream are taken from it, and the table is consulted before any cache.
-
A page that paints forms without end is read up to a budget. A form that paints the next form forty times, six levels down, is under the depth limit and the guard against a form that paints itself, and asked a 3.6 KB document for four billion paints: the read did not finish. Both the text walk and the image walk now count the paints of a page against
MaxFormPaintsPerPage, and the form content of a page against 256 MiB, and keep a small per-page cache so a form painted again is not decoded again. -
Form field appearances state
/Resources. A check box or radio button draws no text, names no font, and its appearance stream had no/Resources; the Arlington model of PDF 1.7 and later requires the entry. -
The PDF/A conversion sets right, removes, or refuses more of what the profiles name. The analysis never looked at a content stream, a bookmark, an annotation's flags or a form's actions; the veraPDF test corpus, converted and judged by veraPDF 1.30.4, showed it writing documents that still broke the rule. Now: an annotation's Print flag is set when it is missing (
PdfAFeatureRepaired); a hidden annotation and a type the profile does not list are refused; a widget's and a field's actions, and an XFA form, are dropped; a forbidden action is found along/Nextchains and on bookmarks, pages and the open action, and the forbidden set is the one the profiles list (SubmitFormis permitted,ResetForm,Hide,SetOCGState,Trans,GoTo3DView,SetStateandNoOpare not; a named action must be one of four); content that paints inDeviceCMYK, through aSeparationorDeviceNalternate included, under an RGB intent, an operator ISO 32000 does not define, and the graphics-state keys the profiles forbid are refused; and a source that already states a usableGTS_PDFA1output intent keeps it instead of being re-labelled sRGB.docs/validation.mdhas the measurement. -
Security: signature wrapping. The validator required only that the byte range start at 0 and end at the end of the file, so bytes written into the unsigned gap could close the signature value early and add entries while the digest still matched, and the signature was reported valid and covering the whole document. The gap must now be exactly one hexadecimal string equal to the dictionary's
/Contents; anything else isMalformedByteRange, integrityUnknown, andCoversWholeDocumentfalse. -
Security: decompression bombs. Flate, LZW and RunLength streams decoded without a limit, so a 1.1 MB document took the process past 1 GiB. They now stop at
MaxDecodedStreamBytes; buffer growth no longer overflows past 1 GiB. -
Security: stack overflow. A chain of streams whose
/Lengthis the next stream was resolved by recursion, and 60,000 links ended the process. The chain is followed no deeper thanMaxNestingDepth; past it the stream is found by itsendstreamkeyword, as for a/Lengthcycle. -
Security: allocations sized by the file. An object stream's
/Nsized two arrays before anything checked it (513 bytes asked for 16 GiB), and a JPEG frame's 16-bit width and height sized the sample planes before the caller's budget was consulted./Nis now bounded by what the stream can hold, a JPEG above the budget is measured from its header without being decoded — the same answer as before, without the allocation — and the working sizes are computed in 64 bits. -
A JPEG scan header is checked before it is used. A Huffman table selector above 3, and a progressive scan whose spectral selection runs past coefficient 63 or starts after it ends, indexed past the decoder's tables (
IndexOutOfRangeException); such a scan is now refused and the image reported undecodable. -
The empty name is a dictionary key like any other.
/on its own is a name PDF allows; four documents of the pdf.js test corpus use it as a key and did not open at all (ArgumentException). -
A glyph drawn upside down has a box. A negative font size made
PdfGlyph.BoundingBoxthrow, so text extraction faulted on the page. -
PdfDate.TryParseanswers instead of throwing for a time-zone offset beyond fourteen hours, which it now reads as no offset; one malformed/CreationDateno longer fails the inspection of the document. -
An incremental update appends what changed, and only that.
UseIncrementalUpdateappended a copy of the whole document under new object numbers: the file grew by its own size per edit, and the signature dictionary of a signed source was written again after signing, so validators that look at what changed after a signature (pyHanko, Acrobat) saw the signed field as modified. The edited document's objects now keep their numbers and an object written exactly as the source already states it is left out — rotating a page of a signed document appends 716 bytes and three objects instead of 20,969 bytes and twelve. -
An incremental update keeps the permanent identifier. The first element of
/IDis the source's in every revision, as ISO 32000-1 §14.4 requires; only the second element is new. -
A merge writes a media box for a page that states none. Every page of a PDF needs one; a source page with none, and none to inherit, was copied without it, and each reader assumed its own size. It is now written with the A4 box the inspection already describes it with, and
PageSizeAssumedsays so. -
Copied real numbers keep their value. A merge or an edit rewrote every real it copied to five decimals — a Type 3 font matrix of
0.000012became0.00001, seventeen percent off, and0.000004became0. A real read from a document is now written back from its own text. A real too large for the formatter's buffer no longer fails the write of the whole document (found by thedocumentfuzz target in its first run). -
The image copy route refuses damaged Flate data with
PdfSourceFormatExceptioninstead of letting the decompressor'sInvalidDataException, or theZLibExceptionit throws for some inputs, reach the caller (both found by theflatefuzz target). -
An edit reads a page's rotation the way the inspection does. A
/Rotatethat is not a multiple of 90 made the edit engine throwArgumentOutOfRangeException(found by thedocumentfuzz target), and a real or indirect/Rotatewas read as no rotation at all. Both now take the nearest quarter turn, the rotation the inspection already reported, and a value beyond the range ofintis reduced instead of wrapped. -
Annotations satisfy the Arlington model. A free text annotation states the
/DAISO 32000-1 requires, and every annotation appearance states its/Resources(found by the Arlington check in its first run). -
A cross-reference table whose offsets moved is rebuilt. Bytes inserted or removed after a table was written — a converted line ending, a prepended byte order mark — leave a table that parses and offsets that land inside other objects. Reconstruction used to run only when no table or no catalog was found; it now also runs when the catalog's offset, or most of a sample of offsets, does not land on its own object.
-
Reconstruction looks inside object streams. A PDF 1.5 file whose cross-reference stream is lost keeps its catalog and pages in object streams, which a scan for object headers cannot see; it was refused with "no document catalog". The objects of every object stream the scan finds are now indexed, and
/Rootis taken from the dictionary of the last cross-reference stream. -
Hardening. AESV2 always uses a sixteen-byte key, as AES-128 requires, so a file that declares a shorter one opens. A predicted row is sized in 64 bits on the whole-buffer path too: declared columns and colours whose product wrapped to zero looped forever, and to a negative number threw
ArgumentOutOfRangeException. A stream whose length is wrong is cut where its compressed data is complete — where its Adler-32 matches — rather than at the firstendstreamwhose bytes inflate, and at most sixteen candidates are inflated. A reference to a generation the table does not list resolves to null, as ISO 32000-1 reads it. -
A revision appended to a file that uses cross-reference streams ends in one. Edits and signatures appended a classic table chained to a stream; they now write the form the document uses.
-
Copying a listed attachment that embeds nothing writes nothing. A file specification in the embedded files tree that only names an external file is listed, with a warning and a length of zero; copying it threw
ArgumentExceptionas if the caller had passed a file of another document (found by the veraPDF corpus run,isartor-6-1-11-t01-fail-a.pdf). -
A merge walks a deep or looping outline without ending the process. The outline was copied recursively, one stack frame per level, and a source nested about fifty thousand levels deep overflowed the stack. The walk stops at 256 levels with
BookmarksTruncated, and a bookmark reached a second time — a/Firstor/Nextthat points back up the tree, or a child two parents share — is copied once and reported withBookmarkSkipped(found by thedocumentfuzz target). -
Rebuilding a table passes over the offsets it cannot read. Reconstruction keeps the damaged table's entries beside the ones its scan finds, and the search for a cross-reference stream's trailer sliced the document at each of their offsets unchecked: one past the end of the file, or beyond the range of an index, threw
ArgumentOutOfRangeExceptioninstead of letting the rebuild find the catalog (found by thedocumentfuzz target). -
Run-length images are decoded.
RunLengthDecodejoins Flate, LZW and the two ASCII filters: a bilevel or scan-style image that declares it now yields its samples — andGray8,Rgb24orCmyk32pixels — rather thanImageFilterUnsupported, and a stream that ends without its end-of-data byte is decoded as far as it goes.ADR-005scopes the remaining four filters —CCITTFaxDecode,DCTDecode,JPXDecodeandJBIG2Decode— with the evidence path each one has to meet. -
CCITT fax images are decoded.
CCITTFaxDecodecovers Group 3 (one- and two-dimensional) and Group 4 for bilevel images —K,Columns,Rows,BlackIs1,EncodedByteAlignandEndOfLineare honoured — so a scanned page now yields its samples (andGray8pixels) instead ofImageFilterUnsupported. The decoder is checked against Group 3 and Group 4 strips Pillow wrote through libtiff, with the bitmap Pillow decodes as the reference;ADR-005schedulesDCTDecode,JPXDecodeandJBIG2Decodenext. -
Baseline JPEG images are decoded.
DCTDecodenow yields samples —Gray8for one component,Rgb24for three (YCbCr converted) andCmyk32for four with the Adobe YCCK transform — whileDatakeeps the stored JPEG andDecodedPixelscarries the samples, so a caller can have either. Baseline and extended sequential (SOF0/SOF1) are decoded, and a subsampled component is upsampled with libjpeg's 3:1 fancy filter, so a 4:2:0 fixture matches a reference decoder within two levels. Progressive (SOF2) followed in the next entry. -
Progressive JPEG images are decoded.
DCTDecodenow reads the multi-scan form too: spectral selection and successive approximation accumulate in the quantised coefficient grids the scans share, and the inverse DCT runs once at the end, so a non-interleaved AC scan (one component) and an interleaved DC scan (every component, MCU order) land on the same blocks. Seven progressive fixtures — 4:4:4, 4:2:0, grayscale, CMYK, a non-square 32 x 16 image, a sparse one that uses the EOB and zero runs, and one with 150 restart markers — each matches Pillow within two levels of every sample. The AC refinement's two conventions — the sign bit is read before the correction bits, and 1 means positive — are recorded inADR-005, because getting either backwards still decodes every scan and leaves a handful of coefficients a step or two out.
- One call reports the whole picture.
IPdfDiagnoser.DiagnoseAsyncreturns aPdfDiagnosticsReport— the document, its fonts, its signatures, an optional PDF/A pre-flight and the merged, de-duplicated warnings — assembled from the use cases the library already exposes, so it cannot disagree with them. The report is read-only and never returns stream contents; a document that stays closed is reported withIsReadable/RequiresPasswordinstead of throwing.tools/SharpCorePDF.Diagnosticsprints it as text or JSON, with--profilefor the archival pre-flight and--jsonfor the whole report. - PDF/A-4 (ISO 19005-4) is written.
PdfAProfile.PdfA4writes a PDF 2.0 document withpdfaid:part4 and no conformance level — the base level — with the same embedded fonts and sRGB output intent as the other profiles, and transparency allowed.compliance.ymlnow validatesarchive-4.pdfandarchive-source-4.pdfwith veraPDF, and thearchive-pdfaexample writes both. PDF/A-4f/-4u and level A remain out of scope.
- The packages ship symbols, and the build is proven reproducible. Every
dotnet packwrites a.snupkgbeside the.nupkg,publish.ymlpushes both, and areproducibleCI job packs the same commit twice and compares every entry of every package. The assembly and file versions follow<Version>again (the 1.7.0 bump had left them at 1.6.0.0).
- Stationery: a background template per page range, with a default.
PdfStationerymaps a template to aPageRangeand can name a default for the pages no assignment covers (Assign,AssignDefault,AssignNone), andPdfEditPlan.ApplyStationery(...)records the whole plan as one operation. The template is recorded as the underlay layer the editor already writes — a form XObject — so the page's own content streams keep their bytes, vector graphics and selectable text survive, and nothing is rasterized. Assignments are tried last first, a one-page template repeats across its range, a multi-page template maps one page for one page, and a range that reaches past it is refused.PDF/A-1brefuses a translucent or blended stationery. The manual's chapter 14 has the section andPdfDocumentEditorTests.Stationery*has the tests, including one per acceptance criterion of #6.
-
The archival output is validated by CI, against a pinned validator.
compliance.ymlinstalls veraPDF 1.30.4, writes thearchive-pdfadocuments and validates each one against the profile it was written for — the authored page and, throughSCPDF_ARCHIVE_SOURCE, the six-pageSafeWebCore.pdffixture — then uploads the machine-readable reports. A validator below the pin exits 2 through--require-versioninstead of answering, so a stale rule set cannot report a pass this repository no longer stands behind. The run is repeated weekly because a validator upgrade changes the answer without this library changing a byte. -
validate-pdfa.pyreads the report instead of the word PASS.--format xmltakes the verdict from theisCompliantattribute of veraPDF's machine-readable report,--report-dirkeeps that report per document, and--require-versionrefuses a validator older than the one the repository ships against. The text mode a person runs by hand is unchanged. -
The
archive-pdfaexample can archive a document it did not write.SCPDF_ARCHIVE_SOURCEnames a file, and the example converts it for all three profiles beside the authored page — the same environment-variable pattern the signature example uses for its timestamp token, because no redistributable real-world PDF belongs in the repository. On 2026-11-13 all six documents reportedPASSunder veraPDF 1.30.4. -
Two more implementations read the same documents.
validate-pdfa-cross.pyputs every archival file through Apache PDFBox preflight and Ghostscript beside veraPDF. PDFBox shares no code with veraPDF and validates PDF/A-1 on its own, so1bgets a second verdict while2band3bare reported asparsed, never as judged — PDFBox 3.0 does not implement those profiles and the tool does not pretend it does. Ghostscript rewrites the document as archival output from what it understood, the evidence that the file is not readable only by the tool that wrote it.compliance.ymlruns the cross-check with--strict-tools, so a missing implementation fails the run rather than narrowing it silently, and a2bfile judged as1bis now rejected by two independent implementations. -
The archival output intent can be the caller's own ICC profile.
PdfAConversionOptions.OutputIntenttakes aPdfOutputIntent— the profile bytes, the number of components and the condition identifiers — and the writer states it instead of the built-in sRGB one. The bytes are written verbatim, and they are checked first as what they claim to be: the ICC header's declared length, theacspsignature at offset 36 and a data colour space that agrees with the declared component count, so a caller who passes a JPEG or a CMYK profile labelled as RGB is refused before a byte of the result exists. The pages are not converted into that colour space; the intent states what they are meant to be read in. A 6-page real-world document written with the sRGB program from a Windows workstation, under its own condition identifier, reportedPASSunder veraPDF 1.30.4, and the bytes in the result are exactly the bytes that went in. -
PDF/A-3b output associates its embedded files, as ISO 19005-3 requires. The catalog gains an
/AFarray, each entry of theEmbeddedFilesname tree and its association name the same file specification object (the tree is flattened so both point at one object), and every specification states an/AFRelationship. A file that already states a relationship keeps it, because the source's claim is evidence this writer does not have; one that states none takesPdfAConversionOptions.AssociatedFileRelationship, which defaults to/Unspecifiedrather than inventing a meaning, and may be set to/Data,/Source,/Alternativeor/Supplement. A relationship set beside any other profile is refused, because those profiles forbid embedded files. A one-page document carrying atext/plainattachment, written with/Alternative, reportedPASSunder veraPDF 1.30.4. -
PDF/A-2u and PDF/A-3u output. A level-U document is a level-B one whose every glyph has a Unicode equivalent, and the writer already states a
ToUnicodemap for every font it subsets — so the level is a statement in the packet, not a different file. A measurement came before the code: a 2b and a 3b result whosepdfaid:conformancesaidUboth reportedPASSunder veraPDF 1.30.4, for an authored page and for a six-page document written by "Microsoft: Print To PDF", which is the case that would have failed if the copied fonts had no mapping. Both profiles are now written end to end,ArchiveExampleswrites all five, andcompliance.ymlvalidates and cross-validates every one of them. Level A, which needs tagged structure, is still out of scope. -
A page can state an opacity and a blend mode for what it paints next.
PdfPageCanvas.SetAlpha(alpha, blendMode)writes the pair as one/ExtGState(/ca,/CA,/BM) and selects it withgs, so a stretch of text, an image or a whole group of shapes can fade or blend without giving each one an opacity of its own. The state is written once per distinct pair and restored bySaveState/RestoreState; a paint that states an alpha of its own still wins over the selection, which is the rule an explicit paint already followed for colour. Ten tests inPdfPageCanvasTransparencyTestspin the operator, the deduplication, the blend name, the restore, the guards and the interaction with the archival profiles: PDF/A-1b has no transparency and the existing pre-flight refuses the page for that profile, while PDF/A-2b keeps it. The manual's drawing chapter gained Transparency and blend modes, thedraw-shapesexample paints one panel through a multiplied state (qpdf check: no problems,/ExtGStatewith one entry per distinct pair perdocs/parity.mdrow 2), and the new measurement rows live indocs/measurements.md§10. -
A document's fonts can be read without opening them.
IPdfFontInspector.ReadFontsAsyncanswers which fonts a file uses and whether each program travels with it: one entry per font, keyed by the object its resource names, carrying the kind (Type1…CIDFontType2), where the program lives (/FontFile,/FontFile2,/FontFile3or a Type 3 font's own streams), the encoding the document states, whether a/ToUnicodemap is present, whether the name carries the six-letter subset tag, and the one-based pages that select it. A font selected by two hundred pages is one entry with two hundred page numbers. A resource that does not resolve is reported asFontUnreadableand a font that states no descriptor asFontDescriptorMissing— the second is not a defect, because a standard font may legally rely on the one the reader already has. The walk follows a form XObject's own resources at depth, honoursPdfEngineOptions.MaxNestingDepthand opens an encrypted document with its password instead of reporting it closed. The descriptor, kind, encoding and subset rules moved intoPdfFontDescriptorLookup, which the PDF/A pre-flight now shares with the new inspector rather than keeping a second copy. Twenty tests inPdfFontInspectorTestscover every shape, the form case, the real-world case and both encryption outcomes; the manual gained chapter 26.
- A merge and an edit read each source once instead of twice. The application layer inspected a source to
resolve the page selection and then handed the same stream to the engine, which read the whole document a
second time; on a 100 MB file that was 100 MB of extra garbage per operation, and it is what
docs/measurements.md§1 attributed to "the output copy" — an explanation that could not hold for a partial selection, whose output here is 0.9 MB.IPdfDocumentBytesReaderhands the inspected bytes on, the use cases prefer it when their reader implements it, and the engine's existing owned-bytes fast path turns the second read into an aliasing read. Measured on the same 100 MB document: a merge of ten of its pages allocated 204.2 MB → 104.2 MB (2.04× → 1.04× input) with the same 931 273 B of output, and the process peak working set fell from 955.6 to 856.3 MB.IPdfDocumentReaderis unchanged, so a third-party reader still compiles and still pays the second read;SourceReadOnceTestspins both behaviours with a source whose stream can be drained only once. The decision and the options that were rejected are recorded indocs/adr/0004-buffer-model.md. - Configuration registration is trim- and Native AOT-compatible.
AddSharpCorePDF(IConfiguration)bindsPdfEngineOptionswith ordinary property reads instead of the framework binder's reflection and runtime-generated converters, so the overload no longer carries[RequiresUnreferencedCode]or[RequiresDynamicCode]. An absent section still keeps the defaults; an unparsable value keeps that member's default.examples/SharpCorePDF.AotSmokenow exercises default, explicit and configuration registration and publishes with zero IL2026/IL3050 warnings.docs/aot.mdrecords the evidence.
Named here so the next version starts from a list rather than from memory. Each one is a capability, not a defect: nothing below is claimed by the packages above.
- Level A, and PDF/UA. PDF/A-1a, -2a and -3a need a tagged structure tree and the accessibility semantics that go with it; PDF/UA is a different standard again. The writer states level B or U; a caller who needs a tag tree has to add one, and no part of this release pretends otherwise.
- A PDF/A target on the merge path.
MergeOutputOptionshas no profile, so an archive that merges first and converts second reads every source twice — once to merge, once to convert. The conversion is the only entry point that writes archival structures (IPdfAWriter), and a merge-time profile is a design of its own: the merge engine and the conversion share the writer but not the analysis. - A caller-supplied output intent on an ordinary edit. The intent is a conversion option. A
PdfEditOutputOptions.OutputIntentwith a PDF/A profile works, because that route goes through the same writer, but a plain edit copies whatever the source carried and adds none. - Colour conversion. The writer states the intent a caller supplies and never converts a page into that colour space. A CMYK profile on pages painted in device RGB is a finding a validator reports, not something the library repairs — by design, because a silent conversion changes what the page looks like.
- Per-page and per-object associations. PDF/A-3 allows an embedded file to be associated with a page or a
structure element, not only with the document. This release writes the catalog-level
/AFarray and only that. - A corpus of real files. The gate runs two documents through three implementations on every push: an authored page and one file a producer wrote. The next step is breadth — customer files, one per profile and per producer — because a document that fails is worth more than a rule that passes.
- PDF/X. Prepress exchange is a separate standard with its own colour and box rules. It stays out.
- Ghostscript locally.
validate-pdfa-cross.pyreports it asn/awhen it is not installed and only fails under--strict-tools, which is what CI passes. A workstation without it gets two implementations instead of three, and the run says so.
-
The scan allocates less per letter, and two more bulk scans are vectorised. A word's text is built once at its final length with
string.Createinstead of aStringBuilderper word; the glyph list is sized from the first page's count so it stops doubling; the search forendstreamwalks the stream a vector at a time through the sameSimdByteScankernel the inline-image search uses; and the PNGUppredictor is a vector add. Measured on the 200-page fixture under server GC in an isolated process: warm extraction 58.8 → 38.3 ms and allocations 33 183 → 29 557 KiB; on the locked 13-document external corpus the median open+extract fell from 36.1 to 21.9 ms with the same 1 852 569 letters on both engines. A newextract-1-inline-image-1mbrow — the first scenario that contains aBI/EIimage — reads a 1 MiB inline image in 0.7 ms against PdfPig's 8.2 ms. -
A session keeps the glyphs of its two most recent page ranges. A caller that asks the letters and then the words of the same pages now walks the content once and groups it twice; the second answer costs a grouping pass instead of a page walk. On the new
text-200-two-questionsrow a session reads in 31.3 ms and allocates 41 MB against PdfPig's 89.3 ms and 109 MB, and the same build with the cache bypassed allocated 7.9 MB more — exactly one glyph list. -
The scan allocates less and runs faster on the work a reader does. Seven changes, each measured on the same 200-page fixture with
DOTNET_gcServer=1in an isolated process: a number is parsed in place withUtf8Parserinstead of being copied into a string first (the three scanners and the token lexer); a literal string that needs no decoding is a slice of the stream rather than a list and a copy, and one that does is decoded into a pooled buffer; a hexadecimal string is one array of the right size rather than a growing list and an array copied out of it; an operator keyword comes from a cached set keyed by its packed bytes instead of a fresh string per operator; aTJitem is a struct rather than a boxedobject; the two base-encoding tables are built once and copied only by the one caller that changes them (/Differences); and the word grouping reads a range of the glyph list instead of copying a page at a time. Extract allocations fell from 35 028 to 33 183 KiB (−5.3 %), median cold extract from 75.2 to 57.8 ms (−23 %) and warm from 68.8 to 58.3 ms (−15 %) over five runs; the external corpus still reads 1 852 569 letters on both engines, so none of it moved a byte of text. -
The vector byte scan is used where a run is bulk, and was measured out of where it is not. A new internal
SimdByteScanfinds a byte with AVX2 (32 bytes), SSE2/NEON (16 bytes) or a scalar loop, in the shape this team uses elsewhere: a platform check, one kernel per instruction set, a scalar tail. Applied to the whitespace and keyword scan that runs before every token it was slower — 75.2 to 97.6 ms — because those runs are one to three bytes and a 32-byte compare of six to sixteen values costs more than the three byte branches it replaces. That use was reverted, the set-shaped kernels written for it lost their last caller and were removed with it, and the single-byte kernel stays for the inline-imageEIsearch, where the run betweenIDandEIis hundreds of kilobytes. The lesson is recorded indocs/mutation-testing.mdrather than remembered: vectorising a per-token decision is a loss.
- The external corpus the scoreboard cites is larger, and the numbers are fresh. Two documents join it: a
linearised copy of one arXiv paper (
qpdf --linearizethroughpikepdf) and an image-only A4 page the library writes itself, standing in for a scan — the two shapes the earlier sample did not contain. Both engines read 13 of 13 files, the letters are still identical to the character (1 852 569 on each), the linearised copy reads the same 53 921 letters as its original with no warning, and the image-only page yields no text on either engine and raises nothing, so "this page has no text" stays distinct from "this page could not be read".docs/competitive-scoreboard.mdcarries the new lock hash (fca6dd17…5dab5b), the refreshed medians and the release-cite table re-measured withDOTNET_gcServer=1in isolated per-engine processes.
-
A font that states
MacRomanEncodingis read. The reader knewWinAnsiEncodingandStandardEncodingand reported any other set as unreadable rather than guess; a Mac-written PDF found by the wider external corpus therefore read as no text at all. The Mac OS Roman table is now built once beside the other two — including thefi/flligatures, the typographic quotes and the dashes — and the file that found the gap reads 2 432 letters, the same count PdfPig reports.MacExpertEncodingremains outside the claim and is still reported rather than approximated. -
A PAGE XML export is schema-valid. The first run of the schema check the parity matrix asks for (ALTO 4.2 and PAGE XML 2019-07-15 against the published
.xsdfiles withlxml) rejected the PAGE document: its<Metadata>stated a creator and neither of the two times the schema requires.CreatedandLastChangeare now written at a fixed instant - the export stays byte-for-byte reproducible, which another test already pins - and both documents validate.docs/parity.mdrow 16 moves to Evidenced with the run recorded and the new test named.
-
The packages are trim- and Native AOT-compatible, and one overload says when it is not. Every assembly declares
IsTrimmableandIsAotCompatible, and the build is clean under the trim, AOT and single-file analyzers: the reader, the writer and the merge engine use no reflection, no dynamic code and no serialization of their own types.examples/SharpCorePDF.AotSmokeproves it — it authors a page, merges two documents through the container and reads the text back, and itsexpect-aotswitch fails the run when the published binary still supports dynamic code. The configuration-binding overload (AddSharpCorePDF(IConfiguration)) uses the framework binder and is annotated[RequiresUnreferencedCode]/[RequiresDynamicCode], so a trimmed or AOT publish reports it at build time; an AOT application passesPdfEngineOptionsin code.docs/aot.mdrecords the evidence. -
A page can paint in a colour space the caller names.
PdfPageCanvas.SetFillColorandSetStrokeColorwrite the selection set —cs/CSthenscn/SCN— andFillPath/StrokePathpaint with what they selected, writing no colour operator of their own; that pair is what makes a separation, a device-N space or a pattern reachable, because aPdfPaintcarries a device colour and every other drawing call states its own paint. An explicit paint still wins over a selection, a name a PDF name cannot state (#, a delimiter, whitespace, or nothing after the slash) is refused at the call site, and so is a colour with no component or one that is not finite. This closes the lastPartialrow of the creation parity matrix:docs/parity.mdrow 2 is now Evidenced with six new tests and avalidate-pdf.pyrun over a page whose content stream is/DeviceCMYK cs,scn,f,/DeviceGray CS,SCN,S(qpdf check: no problems). -
The harness reports informational notes apart from warnings, so a decrypted document no longer looks damaged. A file that is encrypted with an empty user password is read in full; the remark saying so was being counted as a warning, which put the external corpus's last remaining "warning" in the wrong column.
ExtractionObservationandRobustnessResultnow carry a note count (the encryption remark), perf rows printnotes=when there are any, and the robustness table has its own Notes column. The eleven-document external leg therefore reads 0 warnings for SharpCorePDF with one note, and 1 798 648 letters on both engines. -
A Type1 font's own encoding is read when the document states none, so LaTeX formulas are no longer lost. A pdfTeX subset of a Computer Modern math or symbol font states neither
/Encodingnor/ToUnicode: what its codes mean exists only in the clear-text header of the embedded Type1 program, as a run ofdup <code> /<glyph> putlines or aStandardEncoding defstatement. That header is now read (the encrypted part of the program still never is), and the glyph table now knows the mathematical and Greek names these fonts use. The gap was found by the external-corpus leg — 16 glyphs and eightTextUnreadablewarnings on one arXiv paper — and closed to zero: both engines now read 1 798 648 letters on the same eleven documents. The manual's claim that the reader never consults an embedded font program is corrected accordingly, and a fixture pins the precedence: a dictionary that states an encoding keeps it. -
The first external-corpus leg is recorded, not just the synthetic one. Eleven public-domain documents (IRS forms and Publication 15, USCIS AcroForms, two arXiv LaTeX papers, NIST SP 800-53r5) were fetched locally, pinned by a SHA-256 manifest and scored through the hash-locked robustness leg by both engines: 11/11 completed for each, no errors or timeouts, median open+extract 36.5 ms (SharpCorePDF) against 157.2 ms (PdfPig), and identical letter counts on ten of eleven files — the exception being 16 glyphs of a 54 000-letter paper where SharpCorePDF reports 8 warnings. Word counts stay non-comparable across engines, as they are everywhere else. The corpus and its manifest live under gitignored
artifacts/; the harness still downloads nothing. -
Row-band order and the segmentation interplay it lives in are pinned by tests. A three-row two-column fixture shows the row-band read (
Alpha, BetabeforeDelta, Charlie), the same page read column by column under the default, and a raw segmentation that keeps each drawn string a block; a touching row whose left edge contradicts the row above proves the band comparison is strict. The fixture also documents that the default segmentation merges tightly-led rows of a column into one block by leading, which is why the boundary needs the raw segmentation to be observable at all. -
A row-band reading order, for documents known to be tables.
PdfReadingOrderStrategy.RowBandsreads a page as horizontal bands — the blocks that overlap vertically, left to right, before the band below them — which is the order a table's cells are read in. The labelled table now readsItem, Quantity, PricethenWidget, 2, 10.00under it, and a corpus test pins that. The default staysColumnAware: the same order applied to a two-column page would interleave its columns line by line, so the previous characterisation of the default remains correct and is kept as the record of what the default does. -
Block segmentation is a measured row, and one engine per process is the cite recipe. The harness now compares each engine's Docstrum as a block producer (
text-200-all-blocks-docstrum: equal output of 200 blocks and 16 400 words on the fixture) and accepts--engine <name>so a release-cite run puts one adapter in a process of its own. UnderDOTNET_gcServer=1with that isolation the warm extraction rows sit within a few milliseconds of each other while cold extraction and block segmentation lead. A deterministic local robustness sample can be rebuilt from repository assets withscripts/sample-corpus.ps1, which writes its SHA-256 lock before scoring it (synthetic by design, never presented as an external corpus). Harness and docs only — no product package changed. Seedocs/competitive-scoreboard.md. -
A convention-free box overlap column in the competitive scorer. The labelled scoring now reports intersection-over-union per matched character beside the label-convention agreement, so a coordinate convention and a miss are distinguishable: on the current corpus PdfPig scores 0% against the label baseline boxes but 40.83% under IoU while SharpCorePDF scores 100% on both. Alternates are measurable too:
text-200-all-nearest-neighbour-altis a named opt-in row per adapter, and the external robustness leg accepts a SHA-256 manifest (--robustness-lock, written once with--write-robustness-lock) that reports a changed file asLockMismatchwithout opening it. Harness only — no product package changed. Seedocs/competitive-scoreboard.md. -
A reusable layout session.
IPdfLayoutReader.OpenAsyncreturns anIPdfLayoutSessionthat keeps one parse open across letters, words, blocks, hyperlinks and exports. One-shot members are unchanged. The competitive harness measures cold extract and a namedtext-200-all-warmrow so session reuse is visible beside PdfPig's single open. -
A competitive measurement harness, outside the product packages.
benchmarks/SharpCorePDF.Competitiverestores pinned PdfPig 0.1.16 and PDFsharp 6.5.0 behind a separate solution and lock file, never referenced bySharpCorePDF.slnx,src/or the unit tests. It scores labelled extraction, timed text/create/merge scenarios with equal-work summaries, optional local-corpus robustness, and captured writer output forvalidate-pdf.py. Methodology and the first local baseline live indocs/competitive-scoreboard.md; licence notes are inbenchmarks/SharpCorePDF.Competitive/THIRD-PARTY.md. Reports are gitignored underartifacts/competitive/.
-
The competitive harness measures steady state, and it now has a row for the vector scan. Every scenario is executed once per engine before any warm-up is taken, because the first call of a method pays tiered compilation: PdfPig's cold and warm rows run the identical code path and read 181.6 and 47.8 ms in the previous report. The per-letter observation the harness builds is a struct rather than a class, so the allocation column is closer to the engine's own number, and the report's method limits say what it still includes.
extract-1-inline-image-1mbis the first scenario with aBI/EIimage, so the vector byte scan is measured rather than assumed. -
Text advance is computed once per glyph, and character/word spacing and Tz are now asserted. The text walk derives the em-scaled width once and shares it between the glyph box and the advance, and tests a space without a string comparison; the measured effect is nil on the competitive fixture (allocation medians byte-identical, wall time inside its noise band), so this is a clarity change, not a speed one. What it surfaced is real: no test pinned Tc/Tw/Tz, so the collector scored 41.9% under mutation; a spacing fixture and test (
Moves_letters_by_the_character_word_spacing_and_scaling_it_is_drawn_with) now pin the arithmetic at 100/104/110 points and the collector scores 46.6%. -
The glyph walk no longer copies its own output. Pages append straight into the read's glyph list (no per-page list plus
AddRange), and the result of a glyph walk is handed over as built instead of being copied into a defensive list. Extract allocations fell again (36 → 34 MB on the competitive fixture, ~36% below PdfPig); warm full-document extract is within ~1.2× of PdfPig in the latest run —docs/competitive-scoreboard.mdkeeps the run-to-run variance note. -
Word grouping no longer materialises a letter and a rectangle per glyph on the way to a word.
WordExtractorgroups on glyph geometry and reads as a letter only what lands in a word; the word box comes straight off the baseline points. One-byte fonts resolve widths through a table lookup instead of a dictionary hit per code. Competitive cold extract: ~146 → ~110 ms median; allocations on extract are now ~33% below PdfPig while PdfPig still leads that wall-time row — seedocs/competitive-scoreboard.md. -
Font state and the text scan are no longer rebuilt per operator or per page. The fonts a resource dictionary names are read once per read — a 200-page document with one shared resources entry decodes its /ToUnicode maps and width tables once instead of 200 times — and
PdfTextScanneryields a single reused operation instance instead of allocating one object and three lists per operator. Median cold extract time on the competitive fixture moved again (467 → ~146 ms across slices); PdfPig still leads that row. -
Cold text extraction no longer copies an in-memory source before the page walk. When the stream is a
MemoryStreamthat already owns the whole document array (the shapePdfByteArraySourcehands in),PdfByteReaderuses those bytes as they are.WordExtractorgroups pages with a linear scan and an in-place page-order sort instead of LINQGroupBy/OrderBy, and builds each word without per-glyphSelectallocations. On the competitive 200-page cold extract (2 warm-ups / 5 iterations, this machine) median wall time dropped about 3× versus the prior smoke baseline while work counts stayed equal; PdfPig still leads that full-document row, and the warm session row still trails — seedocs/competitive-scoreboard.md. -
The README authoring summary no longer denies JPEG. PNG, JPEG, BMP and GIF are the image formats the surface accepts, with the refusals already named in
docs/parity.md.
-
An image's colour space is read, not guessed from its name, so the spaces and bit depths that used to stay payloads now yield pixels.
DecodedPixelswasnullfor every image whose samples were not already one byte per channel ofDeviceGrayorDeviceRGB— a bilevel scan, a palette image, a CMYK photograph, anICCBasedone — even though the payload had been decoded and nothing about it was unknown. The read now resolves/ColorSpacethrough the document (PdfSampleSpaces), following a resource name, an[/Indexed base hival lookup]array to the palette it points at — a stream or a string, decoded through the same filters as any payload — and an[/ICCBased profile]array to the component count its/Nstates, and a sample that is narrower than a byte is widened instead of a row being read as a continuous bit stream.PixelFormatgains a third value,Cmyk32: four device samples per pixel with no ink conversion, because turning cyan, magenta, yellow and black into light is a rendering decision rather than a fact of the file, and neither an ICC profile nor a tint transform is applied anywhere on this route. ASeparation,DeviceNorLabspace, sixteen bits per sample, and a palette image whose indices run past its own table stay payloads, and the record states which one it is. The expansion is bounded by the sameMaxInlineContentBytesbudget that governsData, so widening a large image cannot allocate past it. -
An image compressed with LZW is decoded instead of being handed back compressed.
LZWDecodesat in the list of filters the reader named and passed through, so a scan stored the way TIFF stores one was reported withIsDecodablecleared andDecodedPixelsnulleven though the library could already read everything about it but the samples.PdfFiltersnow carries a decoder for the coding PDF inherits from TIFF — nine-bit codes growing to twelve, the table built as the stream is read,EarlyChangehonoured — so such an image yields its samples on both the read and the copy route, and theImageFilterUnsupportedwarning it used to raise is gone. The same decoder serves object streams, so a document that stores one behind LZW now reads instead of raisingPdfUnsupportedFeatureException, and the abbreviated name/LZWis accepted wherever/LZWDecodeis — which it was not before. The one convention a decoder can get wrong on its own account is the code at which the field widens, so the tests decode a strip libtiff wrote as well as one this repository's own test encoder wrote: a round trip cannot catch a rule that is wrong on both sides, andEarlyChangeexists precisely because a decoder's table is one entry behind an encoder's.
- A materialised payload is handed back as a view of the buffer the copy route filled, not as a second array
of the same size.
ReadImageDataAsyncandReadEmbeddedFileDataAsyncreturnedReadOnlyMemory<byte>that already was the payload, and then copied it withToArray(); both now return the stream's own buffer, sliced to its length, so reading a large attachment into memory costs one copy of it rather than two. Nothing observable changes but the allocation: the bytes, the length and the lifetime after the call are the same.MergeToBytesAsynckeeps its copy — abyte[]of exactly the merged length cannot be the buffer of a stream that grew by doubling — and its documentation now says so, instead of leaving the copy to be found in a profiler.ReadPageDetailAsyncis written withawait foreachand reads exactly as it did. The same pass documents the destination path ofMergeToFileAsync,SaveImageDataAsyncandSaveEmbeddedFileAsync: it is used as given, no root is enforced, and confining a path that came from an untrusted source is the caller's job. That boundary is stated once inSECURITY.md, once in the manual's chapter on error handling, and in each member's XML documentation.
- A filter name this library has never seen was reported as a damaged payload rather than as an
unsupported filter.
PdfImageFiltersrecognised five names it does not decode —JPXDecode,JBIG2Decode,CCITTFaxDecode,RunLengthDecodeandCrypt— and let every other name fall through to the arm that reports data a filter refused. A producer that invents a filter name therefore had its image reported asImageDataUnreadable— "the payload could not be decoded" — whiledocs/manual/src/08-inspection.mdandspecs/001-pdf-content-inspection/contracts/warnings.mdboth describe such an image asImageFilterUnsupported: nothing was decoded because the decoder is not there, not because the bytes are damaged, and the stored bytes are still what the read carries. The pass-through decision is now the complement of the four filters the library decodes, so the two cases stay apart however many names a document states. - An image with no filter never yielded pixels, so the simplest image of all was the one shape the read
model could not state.
ImagePixelstreated anullfilter chain as "nothing here to widen" and returned before it looked at the samples, which meant an unfiltered image — and every inline image written without a filter — was reported withDecodedPixelsnullwhile the same bytes behind/FlateDecodewere exposed, anddocs/manual/src/08-inspection.mdhad always described the unfiltered image as the simplest case rather than an exception. The condition now asks whether the chain containsDCTDecode— the one payload whose samples are not bytes yet — instead of whether there is a chain at all. - A form whose field tree was too deep lost fields without saying so.
ReadFormFieldsAsyncfollowed the tree to a hardcoded 32 levels and, past that point — or at a reference that repeated an object it had already read — returned without a word, so a truncated form read exactly like a shorter one. The walk now usesPdfEngineOptions.MaxNestingDepth, the same guard the page tree and the content reads already use, and reports the cut with the newPdfWarningKind.FormFieldDepthExceeded; a repeated object is reported asFormFieldUnreadable. The fields read above the cut are still returned, which is what makes "this form has five fields" and "this form was too deep to finish" two different answers. Adding the enum member is additive: the set is open, so an existingswitchkeeps working through itsdefaultarm. - The signature search had a depth of its own, and it was silent too.
SignatureValidatorcarried a privateMaxFieldDepth = 32and returned past it without a word, so a document whose form nests deeper than that answered "these are its signatures" with nothing to suggest the list could be short. The walk now usesPdfEngineOptions.MaxNestingDepth, the same limit as everything else, and recordsPdfWarningKind.FormFieldDepthExceededon the reader. A signature answer has no warnings channel, so the cut is also reported as the newPdfSignatureProblemKind.FormFieldTreeTooDeepon every validation that was returned:IntegrityandTruststill describe the signature that is named, and the new problem says the answer is narrower than the document rather than that a signature is wrong. The page annotations are still scanned as well, which is where a signature a viewer shows carries its widget, so the cut costs the fields between the root and the widget and not the signature itself.
1.3.0 is on the feed: the five packages were pushed by publish.yml from tag v1.3.0 on 2026-10-24.
- Chapter 25 describes how this manual is built.
docs/manual/src/25-how-this-manual-is-built.mdwalks the four stages — Markdown to HTML, HTML to pages, measure, finish — and states what each one refuses: the converter's subset of Markdown (no raw HTML, no nested list, no image), the six class names the highlighter emits so that the stylesheet stays the contract,--no-pdf-header-footerand why the browser prints no header of its own, the forward search that locates a heading without pulling the cursor back into an earlier chapter, the second pass that replaces the placeholders with measured numbers and the re-render that follows a number which moved a heading, and the overlay, outline and metadata SharpCorePDF writes. It records the coordinate trap that put the footer at the top of the page, and the command line with its five switches. The preface no longer asks for Python to build the book.
- The manual is generated by the library it documents.
tools/SharpCorePDF.Manualreplacesdocs/manual/build-manual.py, anddotnet run --project .\tools\SharpCorePDF.Manualis the build: it writesdocs/SharpCorePDF-Manual-<version>.pdf(the1.3.0edition unless--versionsays otherwise) and there is no second route. The tool is a console project inSharpCorePDF.slnxunder/tools/and needs nothing beyond the .NET SDK and Chrome or Edge —SHARPCOREPDF_CHROMEpoints it at a browser installed elsewhere, and a missing browser is an error message that says so rather than a stack trace. The Markdown conversion, the highlighting, the contents page, the two passes that measure the heading pages, the running footer, the bookmarks and the document metadata are all written with SharpCorePDF's own reader, authoring surface and edit plan, so no pypdf and no Pygments take part. The rebuilt edition is 26 chapters, 118 pages and 222 bookmarks; the1.2.0entry below records the edition as it was first released, at 25 chapters and 113 pages.
- The quickstart promised one package and then built a container.
SharpCorePDFbrings every SharpCorePDF assembly, butServiceCollectionandBuildServiceProvider()live inMicrosoft.Extensions.DependencyInjection, which the registration package does not reference — it takes...Abstractions, the assemblyAddSharpCorePDF()extends. A project that followed Chapter 3 and Chapter 10 as they were written did not compile until it added that package itself. Both chapters now say so, where the first provider is built. G8 found it: the published1.2.0packages, installed into an emptynet11.0console app, failed on the first build withCS1061onIServiceCollection. - The manual builder printed the running footer under the top edge. The Python builder wrote the
footer's text matrix 30 points above the bottom edge; the port passed the same 30 to a canvas that counts
down from the top-left corner, so every page carried the footer in its top margin, where it reads as a
header.
ManualFinishernow converts the anchor (page.HeightPoints - 30, the rule 12 points closer to the text), which puts the footer back inside the 18mm bottom margin the stylesheet declares. Reading the printed page's content stream —1 0 0 1 48.2 30 Tmafter the fix,811.92before it — is what caught it; a screenshot of the page did not. - A layer was drawn under the state the page left open. The streams of a page reach a reader as one
stream, so a producer that states a transform outside a
q— Chromium's print output opens every page with.24 0 0 -.24 0 841.92 cm— had that transform still in force wherePdfEditPlan.Overlaydrew its form: the layer landed at a quarter of its size, in the corner of the page instead of where it was made. The plan now frames the original content inq/Qwhenever it draws a layer, as it already did for a resized page, so what a page states cannot reach what the plan appends — which is whatdocs/parity.mdrow 6 asked for in the first place. The page's own bytes are still copied unchanged.PdfDocumentEditorTests.Places_a_layer_where_it_was_made_when_the_page_leaves_its_state_openis the test; the manual's footer is how the fault surfaced, as a short dash of purple above the first line of every page.
- A document is annotated without touching its content.
PdfAnnotationscreates the ten kinds a viewer draws — a link to a URL or to a page, a sticky note, free text, a stamp, a highlight, an underline, a strike-out, a square, a circle, a line and ink — andPdfEditPlan.AddAnnotation,UpdateAnnotationandRemoveAnnotationwrite them through the same immutable plan as every other edit. The page's/Annotsarray is rebuilt and the page's content streams are never rewritten, so a page the plan does not name keeps every object it had; an annotation removed stops being reachable and is therefore not written at all. Every annotation the engine creates carries an appearance stream of its own — a note with a folded corner, free text auto-sized to its box, a centred stamp caption, filled quads, elliptical arcs, lines and ink — drawn in the annotation's own space and compressed, so a viewer that does not synthesise appearances and a printer, which never does, still show it; a caller that wants its own operators suppliesPdfAnnotationAppearance. An annotation without an identifier is namedscpdf-N, which is what a later operation of the same plan names it by. The refusals happen before a byte is written: a link with both a page and a URL, a markup without a quad, a line with the same point at both ends, an unknown flag bit, an opacity outside 0–1, a translucent annotation for PDF/A-1b and an identifier the page does not carry. A rectangle that reaches past the page is clipped with anAnnotationClippedwarning, and a link to a page the same plan deletes is dropped with anAnnotationDestinationUnresolvedwarning. - A form is described, filled and flattened through the same plan.
PdfFormFieldscreates the five fields a form is built from — text, check box, radio button, choice (list box or combo box) and push button — andPdfFormgroups them with the style a field that states none is drawn in.PdfEditPlan.SetForm,SetFormField,ResetFormandFlattenForm(whole document or one page) carry them, and a field is addressed by its name, dotted when it is a leaf of a tree: writing a name the document already has fills that field in place and leaves every other field alone. The flags a document stores are derived from the properties (IsReadOnly,IsRequired,IsMultiline,IsComboand the rest), so no bit the editor cannot honour can be asked for. The refusals happen before a byte is written: a name with an empty part, a choice value that is not an option unless the combo box is editable, repeated or empty options, a button that states a value, a value longer than the maximum length, a text field that is multiline and a password field at once, options or a length on a kind that holds neither, two fields that share a name, and a plan that writes one name twice. - The form writer fills, resets and flattens.
PdfEditEnginenow writes the fields a plan states, soSetFormFieldon a document that already carries the name fills that field where it stands — its rectangle, its ancestors and its widgets survive, and only/V,/ASand/APchange — while a name it does not carry becomes a new field, a dotted name written as a tree. Every widget gets an appearance the engine draws (a wrapped or shrunk value, a masked password, a highlighted list selection, a tick, a dot, a caption),NeedAppearancesis writtenfalse, and the form carries a/DRwith the fonts it names.ResetFormrestores each field's/DV;FlattenFormdraws the widgets into the page content so a reader without form support still shows the values, then takes them off the page and drops the form. A read-only field and a signature field are refused with the field's name, an XFA packet is removed with the newXfaFormRemovedwarning, and an action on a field is copied inert withFormFieldActionPreserved. Thefill-formexample writes, fills and flattens a form, and the three files pass qpdf, pypdf and PyMuPDF. - An authored page draws a PNG, a JPEG, a BMP or a GIF image.
PdfImage.Openreads a file once —FromPng,FromJpeg,FromBmpandFromGifare the same read with the format stated, and refuse a file whose signature disagrees — and reportsFormat,WidthPixels,HeightPixels,ColorSpace,BitsPerComponent,HasAlpha,NaturalWidth,NaturalHeight,FrameCountand aKeythat makes two opens of one file a single image object.PdfPageCanvas.DrawImagetakes either the bytes or thePdfImage, at an explicit size or at the size the file's resolution states. A JPEG is passed through untouched underDCTDecode, withDeviceGray,DeviceRGBor — when an AdobeAPP14segment states the transform —DeviceCMYKand the/Decodearray that flips its inverted samples, and a file it cannot read (an EXIF orientation, arithmetic coding, a precision other than eight bits, four components with no transform) is refused by name. A BMP is decoded from its palette or its twenty-four and thirty-two bit pixels in either row order, and a GIF's first frame is LZW-decoded, de-interlaced, and given a soft mask from its transparent palette entry; the frames after the first are counted byFrameCountand not drawn, because PDF has no animation. - A PNG that states its own colour profile keeps it. An
iCCPchunk becomes an/ICCBasedcolour space with the profile in its own Flate stream —/Nfrom the profile's signature,/Alternatethe device space to fall back to — instead of being dropped, which would show the picture through whatever profile the viewer happens to use.PdfImage.ColorSpacereportsIccBasedfor such a file, and a profile that does not describe the samples (aGRAYprofile on an RGB image) is refused by name. - An authored document carries an XMP packet, bookmarks, and pages copied from another file.
PdfDocumentBuilder.WithXmpwrites an XMP packet into the catalog exactly as it was given and uncompressed, from bytes or from thePdfXmpMetadataa reader returned.WithOutlinewrites the bookmark tree — nesting, open or closed state, page destinations, URLs, and the/XYZcorner a stated area names — and refuses a bookmark that points at a page the document does not have rather than writing a dangling one.ImportPageandImportPagescopy pages out of another document with the merge engine's own copier, so an imported page keeps its content, resources, annotations, rotation and geometry, and the attributes it inherited from its own page tree are stated on the copy. - A typeface says what its metrics are, and measures text without a page.
PdfTypeface.Metricsreturns aPdfTextMetricsin the face's own font units — em size, ascent, descent, cap height, x-height and the line heightLineHeight(size)derives from them — for a standard font out of metrics generated from the AFMs, and for an embedded TrueType face out of itshead,hhea,maxp,hmtxandcmaptables, with the cap and x height falling back to the outline ofHandxwhenOS/2states neither.PdfTypeface.Measure(text, size)returns the advance width of a string, with optional character and word spacing, so a caller can centre a title or size a column before anything is built. A standard font measures through WinAnsi and refuses withArgumentExceptiona character it cannot encode rather than guessing a width; an embedded face refuses a character itscmapdoes not map, and a size that is not a positive finite number is refused by both. - Text wraps into a box and is drawn line by line.
PdfTextLayouter.Layouttakes a string, aPdfTextStyleand aPdfTextLayoutOptions— width, alignment, line height,BreakWords,Overflowand direction — and returns thePdfTextLayoutthatPdfPageCanvas.DrawTextLayoutdraws: a paragraph per line break, greedy wrapping at spaces by measured word width,Left,Center,RightandJustifyplacement (a justified line stretches the gaps between its words, not the words themselves), a leading that is the option, then the style's, then the typeface's own line height, andRefuse,BreakWords,CliporContinuefor a word that does not fit the width. The layout's coordinates are its own: the origin is the top-left corner of the box and y grows downwards, so the first baseline is one ascent below the point the layout is drawn at. A right-to-left paragraph is refused withPdfUnsupportedFeatureExceptionrather than drawn backwards. - An edit records one page of another document over or under a page of the source.
PdfEditPlan.OverlayandUnderlaytake a one-page document, a page number and aPdfOverlayOptions— placement (Fit,Stretch,OriginalSize), opacity,Clipand the six separable blend modes — and write the layer as a form XObject that keeps the resources of the document it came from, so a font or image name in the layer cannot collide with a name the page already means something else by. The page's own streams are copied unchanged: an overlay appends a stream that draws the form, an underlay prepends one, and the opacity and blend mode of the layer travel in anExtGStateof its own. The layer follows its page through a move, a duplicate shares it, and a deletion removes it with the page. A translucent layer is refused on a PDF/A-1b output, whose format has no transparency. - An edit replaces the bookmarks, the page labels, the viewer preferences and the XMP packet.
PdfEditPlan.SetOutlinewrites the bookmark tree as stated, with page destinations numbered in the order the edit leaves the pages in, andPdfOutline.Emptyremoves the panel the source carried;SetPageLabelswrites ranges in any of the six styles the standard names, andPdfPageLabeling.Noneremoves the labels instead of reporting them as dropped;SetViewerPreferenceswrites the window, panel, layout, binding and print-scaling preferences in place of the ones the source had; andSetXmpwrites the packet as given, uncompressed. A bookmark or a label range that names a page the result does not have is refused before the source is opened, and a later operation of the same kind replaces an earlier one. - An edit appends a revision to the source instead of rewriting it.
PdfEditOutputOptions.UseIncrementalUpdatecopies the bytes of the source into the result unchanged and writes the edited objects, the pages and the catalog after them as one more revision, whose cross-reference section chains back to the one the source ended with through/Prev. That is what keeps a signature: the bytes it covers are still the bytes it covered, so the outcome reportsPriorSignaturePreservedfor the signature andIncrementalUpdateAppendedfor the revision, while the same edit as a complete rewrite reportsPriorSignatureInvalidated. New objects are numbered above every object the source used, because a reused number would make an earlier revision ambiguous to a reader that resolves through the newest section first. The version of the source is kept — an appended revision cannot change the header it follows — and a plan that asks for another one is written anyway, withIncrementalUpdateVersionKept. The path refuses what it cannot honour: a source that cannot seek, an encrypted source, whose appended objects would need the file key of the revision they follow, a cross-reference table the reader had to rebuild by scanning, a destination that already holds bytes, and a plan that also asks for encryption or a PDF/A profile. - The examples draw a page of shapes. The
draw-shapesscenario (examples/SharpCorePDF.Examples/DrawingExamples.cs) writes one page of vector content with the authoring surface: a round-capped dashed rule with a dash phase, a two-subpath path whose even-odd fill leaves a hole, a clipped column of stripes drawn past its own clip, and a group of shapes turned and moved by a singleSetTransform. It is the artifact the drawing row ofdocs/parity.mdis validated against. - The examples watermark a document. A new
watermarkscenario inexamples/SharpCorePDF.Examples/PdfEditExamples.csbuilds a stamp as a document of its own — one A4 page whoseDRAFTis turned forty-five degrees — and places it on every page of an existing document as an overlay at 18 % opacity inMultiply, then prints the operations and the warnings the edit reports and reads its own output back, the page's sentence whole and the stamp a letter per block because each turned glyph has its own baseline. It is the artifact the overlay row ofdocs/parity.mdis validated against, besideedit-pages, whichspecs/003-pdf-platform-parity/quickstart.mdstep 4 names. - An image read states its pixels, not only its bytes.
PdfImageInfocarriesDecodedPixelsandPixelFormat, so a caller that wants to look at a picture no longer writes a decoder first: the samples arrive tightly packed, top row first, one byte per sample, asGray8orRgb24, and their length is exactly the geometry times the channels. They are present only when nothing is left to interpret — the library decoded the payload itself, the width, height and bit depth are stated, every sample is eight bits, and the colour space is one whose samples are its channels (DeviceGray,CalGray,G,DeviceRGB,CalRGB,RGB) — so a palette image, a sixteen-bit image, aCMYKorICCBasedone, and any payload the reader passed through keepnulland are described byFilter,ColorSpaceandIsDecodableinstead. A JPEG stays a JPEG: its bytes are already a format the caller can read, soPixelFormatisnullfor aDCTDecodeimage rather than a second decoder being shipped for it. - The examples archive a page and then sign it. The
sign-and-archivescenario (examples/SharpCorePDF.Examples/ArchiveExamples.cs) writes one authored page as PDF/A-3b, signs that file with a certificate it makes for the run and never writes down, and reports the integrity and the trust of what it produced as two separate verdicts —integrity Valid, trust Trustedwith the run's own certificate as the anchor — with a timestamp token only whenSCPDF_TIMESTAMP_TOKENsupplies one. The order is the promise: the conversion writes the archival bytes and the signer appends a revision, so the signature covers the whole file (coverageENTIRE_FILE, as pyHanko reports it) while the structures the conversion wrote are still the ones a validator reads. Converting a signed file would be the reverse and is not offered, because it rewrites the bytes the signature covers.
- A drawn text layout landed a box height above its origin.
PdfPageCanvas.DrawTextLayouttook the top ofPdfTextLayout.Boundsoff every baseline, and that top is the height of the box, so a five-line block asked for at 100 points from the top of an A4 page was drawn at 37.5 — 71 points too high, with its first line almost off the page. Each run is now placed at its own start point added to the origin, andPdfDocumentBuilderTests.Draws_the_layout_from_the_top_left_of_its_boxpins the result against the same baselines drawn one at a time withDrawText. - A caller-supplied annotation appearance is written, with the face it names.
PdfAnnotationAppearancewas validated, its bounding box became the/BBoxof the form XObject, its font decided that a/Helvresource was written — and itsContent, the operator stream the record exists for, was dropped: the writer drew its own appearance and a caller who stated one got the engine's drawing instead. The operators are now the appearance, verbatim, wrapped in the same form XObject; and the face written as/Helvis the one the record names rather than the annotation's text style, which is what the record's own documentation promised.PdfDocumentEditorTests.Writes_the_operators_of_a_supplied_annotation_appearancewrites a square with its own stream inCourier-Boldand asserts both.
- The manual is the
1.2.0edition.docs/SharpCorePDF-Manual-1.2.0.pdfis rebuilt from the sources — 25 chapters, 113 pages, bookmarks and contents page numbers measured — and it is the first edition whose chapters describe the surface without dating it: the availability notes on chapters 16 to 19 used to say which part of their subject the1.1.0package did not carry, and they now say what1.2adds instead. The preface and the version note name1.2.0, the installation chapter installs1.2.0, and the1.1.0edition stays beside the new one as the record of what that release shipped.docs/README.mdand the repository README point at the new file. - The manual documents the layers and the document-level edits.
docs/manual/src/14-editing.mdgains the six operation rows, a section on overlays and underlays with every option they take, and a section on the four edits that state a value of the document; it now also states that a value the plan states replaces the one an edit would otherwise drop or report, and that PDF/A-1b refuses a translucent layer. - The manual documents text layout.
docs/manual/src/16-text-layout.mdis new: measuring withPdfTypeface.Measureand the metrics in font units,PdfTextLayouter.Layoutand every option it takes, the wrap rules, alignment and justification, the overflow policies, theDrawTextLayoutcoordinate space, the result records, determinism and what a layout deliberately does not do. Chapter 12 now points at it instead of stating that nothing measures or wraps, the cookbook gains a sub-recipe for a paragraph that comes from a template, and the preface explains why chapter 16 is no longer reserved.docs/SharpCorePDF-Manual-1.1.0.pdfwas rebuilt from the sources — 21 chapters, 92 pages, bookmarks and contents page numbers measured. The chapter states at its head that the1.1.0package does not carry the surface it describes. - The manual documents drawing.
docs/manual/src/15-drawing.mdis new and chapter 15 is no longer reserved: coordinates and the trap inPdfRectangle's edge names, lines, rectangles, ellipses, paths and the two fill rules,PdfPaintandPdfStrokewith the operator each member writes, alpha as an/ExtGState, dashes in points, clipping, transforms (including that a positiveRotateturns content clockwise on a canvas whose y axis points down, and how to compose a group so the rotation does not turn the placement), the saved graphics state, and what the surface deliberately does not do. Chapter 12 points at it for shapes, the preface reserves only chapters 17–19, anddocs/README.mdlists it. - Every
dotnet add packageline names the version that exists. The installation chapter and the README asked for1.1.0's predecessor —--version 1.0.0in three places — and the producer examples said a merged document is stampedSharpCorePDF 1.0.0. Both now say1.1.0, which is what the feed serves and what the domain assembly's version produces.
- PDF/A conformance is what a validator says it is, not what this library says.
PdfAConversionResultreports what a conversion could or could not meet; the verdict comes from running veraPDF against the output (chapter 24,docs/tools/validate-pdfa.py). The archival files this release is evidenced on were validated before the signature was appended, so a validator run on the signed copy is the caller's step — chapter 23 says why the order cannot be the other way round. - A timestamp is only as good as the token the caller supplies. There is no network call:
PdfSignatureOptions.TimestampTokensigns what the caller hands over, and without one the signature states its ownsigningTimeand nothing more. Revocation checking, trust lists and certificate chain building are a verifier's job here, which is whyPdfSignatureTrustreports what the file carries rather than what a PKI would decide. PdfImageInfo.DecodedPixelsis present for the images whose samples need no interpretation. A JPEG is a payload, a palette or sixteen-bit image is described but not expanded, and aCMYKorICCBasedimage keeps its declared colour space — the reader statesFilter,ColorSpaceandIsDecodablefor those rather than guessing at a conversion (chapter 8).- Layout analysis reports what it measured, not a guarantee. Blocks, reading order and the extracted
text are scored against
docs/tools/score-layout.pyand the fixture indocs/measurements.md; a table is a block of text with the rows the heuristics found, not a parsed table. - The remaining gates are the ones the release checklist still calls open. There is no symbol package
yet, so a debugger shows no source for a stack trace, and nothing is code-signed. The 90% new-code floor
of G9 is enforced by
ci.ymland read again bypublish.ymlfor the tagged commit; the measurement for this version's code is indocs/measurements.md. Rendering, format conversion, OCR and conformance validation stay outside the product, as ADR-001 states.
- An existing document can be edited into a new one.
IPdfDocumentEditor, resolved byAddSharpCorePDF(), applies an immutablePdfEditPlanto one source:RotatePageadds a quarter turn to a page,DeletePageremoves it,MovePagechanges its position,DuplicatePagecopies it to another position, andSetMetadataoverrides document information. Page numbers are one-based and are resolved against the state produced by the preceding operations, so a plan reads like a sequence of edits. Each operation is a value; the plan is validated before the source is read, and an operation that reaches past the last page fails withPdfEditPlanValidationExceptionbefore any output is written.PdfEditResultreports the page count, bytes written, output version, elapsed time, the operations applied and the warnings the edit produced. - Pages can be cropped and resized without re-rendering their content.
CropPagesets an explicit/CropBoxinside the media box: a box that reaches outside it is clamped and reported asPdfWarningKind.PageGeometryNormalized, and a box with no overlap is refused before any output is written.ResizePagechanges/MediaBoxand wraps the untouched original content streams in a graphics state (q, acmtransform, thenQ), soPdfPageResizeMode.Scalescales the content to the new size andPdfPageResizeMode.Preservekeeps it at its original size and centres it. A crop box set before a resize is carried through the same transform. - Editing copies pages, it does not re-render them. The engine writes a complete new document and
copies every surviving page's content streams, resources, fonts, images and annotations verbatim;
inherited
MediaBox,CropBox,ResourcesandRotateare materialised onto each page. Bookmarks, named destinations and form widgets that name a source page are redirected to the first surviving occurrence, or to the first page of the result when the named page did not survive. Page labels are dropped when an operation changes the page order or count, and an XMP packet is dropped when document information is overridden; both decisions are reported throughPdfWarningKind.PageLabelsDroppedandPdfWarningKind.XmpPacketDroppedrather than silently producing a document whose metadata contradicts itself. - An edit is reproducible when its inputs are fixed.
PdfEditOutputOptionschooses the output version, metadata overrides, producer, modification date and document identifier. The file identifier is derived from the version, date, page count, identifier and applied operations, so a fixedModificationDateandDocumentIdmake repeated edits of the same source byte-identical. The editing release reads encrypted sources through the existing standard security handler; the result is written in the clear unlessEncryptionis set (see below). - A page written from nothing.
PdfDocumentBuildercreates an in-memory document — one or more pages of anyPdfPageSize— whose pages are drawn throughPdfPageCanvas:DrawTextsets a line in a standard or an embedded font at a baseline, in a top-left coordinate system withydownwards, andDrawImageplaces a PNG at an explicit size or at the size itspHYschunk states.Build()returns aPdfByteArraySource, so the page can lead aMergePlanwithout a temporary file;ToArray()andSaveAsync(Stream)are the other two routes.WithMetadatawrites the document information andPdfAuthoringOptionsfixes the creation date and document identifier, which makes repeated builds byte-identical. - Two levels of font, neither of them a system font.
PdfTypeface.Standardselects one of the twelve standard PDF faces withWinAnsiEncodingand no font file;PdfTypeface.FromTrueTypeembeds a TrueType program the caller supplies, subsetted to the glyphs the pages draw, with a/ToUnicodemap so the text —é,è,à,ç,ô,ïincluded — extracts again. Glyph numbers are preserved, unused outlines are left out, and the program is never looked up in the machine's font folder. A character the face cannot encode is refused with the character and code point in the message, rather than replaced. - PNG images without an imaging dependency. Eight bit, non-interlaced PNGs of colour types 0, 2, 3,
4 and 6 are embedded: an alpha channel becomes an
/SMask, a palette withtRNSis expanded to RGB and a soft mask, a colour key becomes/Mask, and an opaque image keeps its originalIDATbytes with a PNG predictor instead of being recompressed. Interlaced and sixteen bit images are refused with an explanation; JPEG and other formats are out of scope. One image drawn on several pages is one object. - Reading what a document already contains.
IPdfContentReader, resolved byAddSharpCorePDF()and constructible by hand, answers the questions a caller asks before drawing anything:ReadImagesAsyncreturns every image a page range paints — one entry per object, carrying every page that draws it, with the bytes the file holds (aDCTDecodeimage is never re-encoded) and the area it occupies;ReadAnnotationsAsyncreturns comments, highlights, stamps and links with their geometry, their text and their target, resolving direct and named destinations;ReadFormFieldsAsyncreturns the field tree with fully-qualified names, types, values and every widget of each field;ReadMetadataAsyncreturns the XMP packet byte-exact with thedc:,pdf:andxmp:values parsed beside it;ReadEmbeddedFilesAsyncreturns the attachments with a distinct identifier per entry;ReadOutlineAsyncreturns the bookmark tree with its destinations resolved; andReadPageDetailsAsyncyields everything known about one page at a time, so a 200-page index never holds a report for the whole file. - One payload rule for every read. A record carries its bytes inline only within
PdfEngineOptions.MaxInlineContentBytes(new, default 256 KiB,0for metadata only); above itDataisnull,ByteLengthstays truthful andIsBufferedsays so, with no warning because nothing failed.CopyImageDataAsync,CopyImageMaskDataAsyncandCopyEmbeddedFileDataAsyncwrite such a payload to a stream the caller supplies through a pooled 64 KiB buffer, andReadImageDataAsync/SaveImageDataAsyncand their embedded-file twins are the convenience members beside them. AReadOnlyMemory<byte>that escapes a call never aliases a rented buffer. - Reading the text the pages draw.
IPdfContentReader.ReadTextAsyncreturnsPdfTextBlockrecords in the order a reader would take them — down the page, then along the line — rather than in the order the content stream happens to draw them. A block carries itsText,LineCount, page andBoundingBox, and holds thePdfWordrecords it is built from, each with a baseline, a font size and a font name and thePdfGlyphrecords behind it, so a caller that needs a coordinate never parses the page a second time. Words end where the document draws a space and where aTJadjustment is wide enough to stand in for one;Tc,Tw,Tz,TL,Ts,Td,TD,Tm,T*andq/Qare all honoured, so a line inside a scaled or rotated form lands where a viewer draws it. A simple font is read through its/Encoding, its/Differencesand the standard glyph names, a composite font through its/ToUnicodemap, and the width of a code comes from/Widthsor/Wwith the fallbacks the specification states. One page overload,ReadTextAsync(source, page), reads a single page without a range. - Text is read or reported, never guessed. A glyph whose code no font entry maps is skipped and its
font named in one
TextUnreadablewarning per page, so a document whose encoding this library cannot follow reads as fewer words plus a remark instead of a page of plausible nonsense, and a page whose font is unreadable still leaves the pages around it readable. - Eleven new
PdfWarningKindmembers —ContentStreamUnreadable,ImageFilterUnsupported,ImageDataUnreadable,XObjectResourceMissing,NamedDestinationUnresolved,EmbeddedFileUnreadable,EmbeddedFileNameCollision,XmpPacketMalformed,FormFieldUnreadable,AnnotationUnreadableandTextUnreadable— so a filter the library does not decode, a damaged image, a name that does not resolve, a malformed XMP packet or a font it cannot read is reported as data instead of being skipped in silence. - The layout comes out with the text.
IPdfLayoutReader, resolved byAddSharpCorePDF()and constructible by hand, reads a page the way a search or an analytics pipeline needs it:ReadLettersAsyncreturns onePdfLetterper glyph in content order, with its Unicode value, its font size, the font the document declares, its box, its baseline start and end and the direction that baseline runs in;ReadWordsAsyncgroups those letters intoPdfWordrecords that keep the letters they were grouped from, with the order of the page as the default andPdfWordExtractionStrategy.Rawfor a caller that needs the order of the producer; andReadHyperlinksAsyncreturns the clickable area of every link with either the URI it opens or the destination it jumps to.PdfWordExtractionOptionsstates both rules in ems — a quarter em as a space, half an em as one line — and refuses a negative distance or a strategy this release does not implement when it is created, before a document is opened. Whitespace letters can be kept in the word they follow, so the words of a page concatenate back to the text it draws, and a letter whose baseline runs towards the left is read in its own direction with a box that covers the area between its two baseline points. - A page's blocks, and the order a reader takes them in.
IPdfLayoutReader.ReadBlocksAsyncgroups the words of a page intoPdfTextBlockrecords — the text, the words it keeps, the area it covers and its one-based position on the page — by the segmentationPdfLayoutOptionsselects:Raw, which reproduces the producer's drawing order and is the baseline a comparison starts from;NearestNeighbour, which groups the lines of a paragraph;RecursiveXYCut, the default, which splits a region along the widest vertical gutter and then the widest horizontal one, so two columns and a heading are found without knowing what a column is; andDocstrum, which measures the page's own leading instead of assuming it. The reading order is chosen separately, because a page can be segmented correctly and still be listed in the wrong order:ColumnAware, the default, reports the columns of a page left to right and the blocks of a column top to bottom, andRawkeeps the order the segmentation produced. The segmentation and the order travel with the result, so a page that yielded no block is not the same answer as a page that was never segmented;PdfLayoutOptions.IncludeDecorationsdecides whether a block that carries no letter and no digit — a rule drawn as a run of hyphens, a lone bullet — is reported; and a strategy only groups the letters and words a read produced, never changing what one of them says. - The reading of a page written down for another tool.
IPdfLayoutReader.ExportAsyncwrites what a block read produced asPdfLayoutFormat.Alto,PageXml,HocrorSvgText, straight into a stream the caller supplies: ALTO 4 with aPageper page, aTextBlock, aTextLineand aStringper word; PAGE XML with aTextRegionper block, aTextLineper line and the reading order that names them; hOCR as XHTML withocr_page,ocr_carea,ocr_par,ocr_lineandocrx_wordelements, each carrying itsbbox; and SVG with onetextelement per word on the baseline it is drawn on. Coordinates are the page's own numbers with the origin moved to the top left corner and the y axis turned down, which is the convention of every one of the four formats; text is escaped for the document it lands in, and a character XML cannot carry becomes the replacement character instead of aborting the write. A page that draws no text still produces its page element, a range is written in ascending page order, and no document states a timestamp or a random identifier, so the same read produces the same bytes on every run. The call returns the blocks it wrote, with the segmentation and the order that produced them and the warnings the read made, so an export of a page whose font could not be mapped is not silent. A destination that cannot be written and a format this release does not produce are both refused before the document is opened, and the exports describe text only:PdfLayoutOptions.IncludeImagesis reserved for the image regions a later release places beside it. - A document can be signed without rewriting a byte that is already signed.
IPdfDocumentSigner— resolved byAddSharpCorePDF()and constructible by hand like every other engine port — appends one revision to a source and returns aPdfSignatureInforead back from the file it wrote: the field, the filter and sub-filter, the digest, the signer, the byte range and the revision the signature covers. The CMS is built here rather than bySignedCms, because a detached signature over a reserved byte range needs the digest of everything except its own placeholder, the signed attributes CAdES names, and a size known before the value exists: the writer reservesByteRangeandContents, hashes the revision with the gap removed, patches the range, and only then writes the signature into it. The certificate's key decides the algorithm — RSA PKCS#1 v1.5 or ECDSA — and the options decide the digest. A certificate with no private key, an encrypted document and a revision too small for the chain are refused before anything is written, so a half-signed file cannot exist; a visible appearance writes a form XObject, a widget and an/Annotsentry in that same revision, and/AcroFormis added when the document had none. - A signature can carry a timestamp the caller obtained.
PdfSignatureOptions.TimestampProvideris the whole of it: the library hands the caller'sIPdfTimestampProviderthe digest of the signature value and embeds the RFC 3161 token it answers with as thesignatureTimeStampTokenunsigned attribute. Nothing here opens a socket, and a provider that throws stops the signature instead of leaving a document that only looks signed. The token travels unverified, and says so: a token that cannot be read is aTimestampInvalidproblem rather than a claim about its time, andPdfTrustOptions.CheckTimestampTrustis reserved for the release that checks the authority's own signature. - Every signature in a document is checked, and the two questions are answered apart.
IPdfDocumentSignatureValidatorfinds each signature field in the form tree and on the page widgets, reads its byte range and its CMS, and reports onePdfSignatureValidationper signature:Integrity— the digest the CMS carries matches the bytes the range covers — and, only when the caller names anchors throughPdfTrustOptions,Trust— the chain leads to one of them. They are separate results because they are separate failures: a document changed after it was signed is not the same defect as a certificate that leads nowhere, andIsValidspeaks only about integrity, which is the half this library can decide on its own. No machine trust store is consulted, no certificate is fetched and no authority is asked whether one was revoked; a placeholder signature, an unreadable structure or a range that does not reach the end of the file isUnknown, neverValid. - A document can be written for archival delivery.
IPdfAWriter, resolved byAddSharpCorePDF()and constructible by hand, writes a complete PDF/A-1b, -2b or -3b document: the version the profile names, an uncompressed UTF-8 XMP packet carryingpdfaid:partandpdfaid:conformancewith the document information mirrored into it, an/N 3output intent built from a generated sRGB colour profile, and/NeedAppearances falseon a form.PdfEditOutputOptions.PdfAProfileroutes an ordinary edit through the same writer. The analysis runs before a byte is written: a font that is not embedded, a CID subset that states no/CIDSetfor 1b, transparency,JPXDecode/LZWDecode, optional content or an attachment the profile forbids, an annotation without an appearance stream, a JavaScript/Launchand similar action, or an external file stream is refused withIsWritten = false, a named requirement and an untouched destination — never written with a label it does not deserve. What can be removed without changing a page is removed and reported asPdfWarningKind.PdfAFeatureRemoved.docs/tools/validate-pdfa.pywraps veraPDF; the release is recorded indocs/parity.mdon veraPDF 1.30.3 reportingPASSfor all three profiles of both an authored page and a real "Microsoft: Print To PDF" document. - An edit can write an encrypted result.
PdfEditOutputOptions.Encryptionapplies the same standard security handler a merge uses — AES-256 by default, AES-128 and RC4 available — and the identifier of the result keys it. The engine refuses a plan that asks for a PDF/A profile and encryption together, before the source is read, and withVerifyOutputon it reads its own encrypted output back with the password it was written with. - Embedded TrueType subsets now state a
/CIDSet. ISO 19005-1 requires the set of CIDs a subset describes, and veraPDF failed a PDF/A-1b conversion without it. The writer emits one that names every CID the preserved numbering makes present, which also satisfies the PDF/A-2 rule for subsets that carry a set.
- Images decode to the samples their filter names, and a mask can be fetched. A
/Predictorimage is now inflated and undone one row at a time instead of into a single buffer, so an image whose stored form is small but whose samples are large is counted rather than materialised and the copy route writes rows as it produces them. An inline image's data ends where its header says it does — the separator afterIDis consumed once andEIis found even when a delimiter follows it — so a sample stream containing a space followed byEIis no longer cut short, and an image with noEIat all keeps what it read and raisesImageDataUnreadableinstead of ending in silence, and a page's streams are separated only between streams, so an unterminated image ends at the last byte the page holds. An inline dictionary whose value is a name (/CS /G) keeps its colour space instead of losing it and misreading the entry after it. Three smaller corrections ride with them:CopyImageMaskDataAsyncfetches a soft or explicit mask by the(ImageId, Kind)its record carries and refuses a colour key mask, which has no payload, by name;PdfImageInfo.IsInlinetells an inline image from an object; and every image warning names the source and the page, plus the image wherever the failure belongs to one, so a 200-page report can be triaged. - The examples no longer contain a password. The encryption example in
examples/wrote a literal user password and a literal owner password into the document it demonstrates — the kind of constant a static analysis scanner reports as a hardcoded credential, and the kind a reader copies into their own code. Both are now made per run, the user password is printed so the document can still be opened, and the example opens it with the value it just wrote. No package changes with this; the finding is what turned the project's security rating red.
- What 1.1 delivers, and what it defers to 1.2. The capability described in this entry is what
1.1.0ships: page creation with standard and embedded fonts, PNG images, the path writer, every page operation of the editor (rotate, delete, move, duplicate, reorder, crop, resize, extract, split, import, insert, append and metadata overrides), reading with layout analysis and the four text exporters, digital signatures and PDF/A-1b, -2b and -3b output. Text measurement and word wrap, JPEG/BMP/GIF, overlays, annotation and form authoring, and incremental updates are not in1.1.0. They stay in the parity matrix as1.2rows with a named task rather than disappearing, so a caller can see the gap instead of discovering it:docs/parity.mdnames the release of every row, and the specification carries the dated scope amendment behind that split. - The product boundary now includes creation and editing. Constitution 2.0.0 and ADR-001 define SharpCorePDF as a dependency-free PDF creation, editing and reading library. The 1.1 target is capability parity with PDFsharp 6.5 for creation and processing and PdfPig 0.1.x for reading and layout analysis; rendering, conversion, OCR, conformance validation, services and CLIs stay outside the product. This release implements page-assembly editing only — page content, annotations and forms are still copied, not rewritten.
- A release waits for the quality gate, on the commit being released.
publish.ymlreads the SonarCloud verdict in asonar-gatejob that runs before the build, before the pack and before the OIDC exchange, and stops when the gate is red, when the snapshot it judged carried no coverage report, or when the newest analysis ofmainis of a different commit than the tag. It changes when a version appears on the feed, not what is in it; the rule it adds is that a tag goes on the commit whose analysis is the newest onmain.
One shortfall is stated rather than left for a reader to find: 77.76% of the executable lines this version
adds are covered by the suite, against the 90% new-code floor in docs/release-checklist.md G9 —
ADR-002 records the measurement, the eight parser and validator
files the uncovered lines sit in, and the decision to ship with the number stated rather than to move it with
tests that only execute lines. The floor itself is unchanged and is re-measured on 1.2's new code. What the
suite does instead is evidence behaviour: 748 tests on both legs, 21 parity rows each naming a test and an
external command, and pyHanko, qpdf, veraPDF 1.30.3, pypdf and PyMuPDF run against the output.
Two things are as they were at 1.0.0: there is no symbol package yet, so a debugger shows no source for a stack trace, and nothing is code-signed. Both remain gates in the release checklist rather than intentions, and neither changes what the packages contain.
SharpCorePDF, the package to install. The four layers stay separate assemblies with separate API snapshots, but a consumer no longer has to work out which of them to reference:SharpCorePDFis a meta-package whose only content is a dependency onSharpCorePDF.Domain,.Application,.Infrastructureand.DependencyInjection, anddotnet add package SharpCorePDFis the whole install. The four remain installable on their own.NOTICE, stating in one page who holds the copyright, what third-party material exists (no third-party source code;Microsoft.Extensions.*inSharpCorePDF.DependencyInjectiononly; test fixtures generated bydocs/tools/make-fixtures.py) and what the name is not.SECURITY.md,CODE_OF_CONDUCT.mdandCONTRIBUTING.mdat the repository root: a private reporting route with a 7-day acknowledgement, Contributor Covenant 2.1 with two enforcement channels, and the build, test and review bar a change has to clear..github/: issue forms for a defect and a feature request, a pull request template, and a Dependabot configuration for the NuGet packages and the workflow actions.SonarAnalyzer.CSharpin the build (src/Directory.Build.props, dev-time only). The rules SonarCloud applies now run indotnet build, at the line that causes them. The three rules this repository answers with a decision rather than a change (S101,S1694,S4790) are silenced per file insrc/.editorconfigwith the reason, and their lines carry// NOSONAR.- The public surface is an approved snapshot (
Microsoft.CodeAnalysis.PublicApiAnalyzers, dev-time only). Each project declares what it exports inPublicAPI.Shipped.txtand queues additions inPublicAPI.Unshipped.txt, and RS0016/RS0017 are build errors: a public member the snapshot does not list, or an entry that outlives its member, stops the build rather than the next release.
publish.ymlchecks the entry point differently from the layers. Every package still has to carrylib/net10.0andlib/net11.0and the README nuget.org renders;SharpCorePDFcarries no assemblies by design, so it is held to the opposite rule instead: it must depend on all four layers.- The trusted publishing policy needs two subjects, not one.
SharpCorePDF.*matches the four layers and does not matchSharpCorePDFitself, which has no dot after the product name; a policy holding only the glob pushes four packages and refuses the fifth. ci.ymlenforces the SonarCloud quality gate instead of reporting it. The scan passessonar.qualitygate.waittobegin— theendphase rejects every property but the token — so a failing gate fails the run, and the gate's coverage condition reads the report this run produced:dotnet-coverage collectmeasures the net11.0 leg, and the Visual Studio XML it yields is named exactly (artifacts/coverage/net11.0.xml) instead of by a glob. Coverage is measured on every run rather than only when a SonarCloud token exists, and every action is pinned to a commit hash rather than a tag.- Codecov is gone, and with it the second coverage report. One service measuring the number is the
arrangement that cannot disagree with itself:
codecov.ymlasked for 90% on the project and on the change, while SonarCloud was already importing the same measurement, so the gate holds the number and the cobertura conversion that only Codecov read is no longer produced. The 90% is a condition to enter on the quality gate on sonarcloud.io — above Sonar's 80% default on new code, and the only place it can be enforced once the file that declared it is gone — andREADME.md,CONTRIBUTING.mdanddocs/release-checklist.mdsay so instead of pointing at a file in the tree. - The SonarCloud findings are fixed in the source, not silenced: loops that read better as
Where/Select/Distinct, a nested ternary in the AES object-key derivation, two helpers moved into the walker that uses them, andPdfReferencenow implementsIEquatable<PdfReference>, so theEqualsoverload it already carried is the one a generic comparer calls.
Two things are known and deliberately not promised: there is no symbol package yet, so a debugger shows no source for a stack trace, and nothing is code-signed. Both are gates in the release checklist rather than intentions. Neither affects what the packages contain or what the assemblies do.
The shipped leg is two, not one: lib/net10.0 and lib/net11.0 carry the same API, as preview.1
already advertised, because a 1.0.0 that narrowed to a single framework would withdraw a target the feed
has promised since 2026-10-15 (docs/release-checklist.md G2). The public surface is the one frozen by
PublicAPI.Shipped.txt — additions after this version go through PublicAPI.Unshipped.txt and a minor
version, not through a silent change to a shipped signature.
Never pushed. Both names exist only as values the repository's <Version> passed through, so no feed ever
served them, nothing was downloaded from them, and skipping them broke no promise to anyone.
The first and — until 1.0.0 — only published version: SharpCorePDF.Domain, .Application,
.Infrastructure and .DependencyInjection at 1.0.0-preview.1, from tag v1.0.0-preview.1. No entry
was written here for it at the time, and this heading does not invent one after the fact; it records that
the four ids are live and immutable, which is why their next version is 1.0.0 and not a re-cut of
preview.1.