#[non_exhaustive]pub struct LoadedXref {
pub table: XrefTable,
pub trailer: Dict,
pub startxref: u64,
pub newest_shape: SectionShape,
pub highest_object_number: u32,
pub suppressed_by_size: usize,
pub hidden_objects: BTreeSet<u32>,
pub hybrid_stream_unreadable: bool,
}Expand description
Result of a successful chain load: the merged table, the newest trailer dictionary, and the physical facts a minimal-diff writer needs about the newest section.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.table: XrefTableMerged object-number → entry map (newest wins, /Size-filtered).
trailer: DictThe trailer dictionary of the NEWEST section — the one whose
/Root//Info//Encrypt govern the document (§7.5.5 load
algorithm step 9).
startxref: u64The byte offset the file’s own startxref names (§7.5.5).
This is the exact value an appended update’s /Prev must
carry — §7.5.6 Q2: “the location of the previous
cross-reference section”, i.e. the section this update
supersedes, which is the one startxref currently points at.
Deriving it from the base trailer’s own /Prev instead is the
classic off-by-one-revision bug.
newest_shape: SectionShapeThe physical form of the newest section — see SectionShape.
highest_object_number: u32The highest object number the chain mentions before the
/Size filter runs.
§Why the unfiltered number has to be kept
/Size is a hard reader-side filter (Table 15, §7.5.5), so a
file whose /Size under-reports loads with those entries
invisible — and a writer that allocates a “new” object number
from the filtered view will happily pick a number the file
already defines. The result is an update section whose entry
collides with a live one, which is the worst failure shape
available: a file that looks fine and resolves an object to the
wrong bytes.
Found by the writer_roundtrip fuzz target on a corpus file
carrying /Size 3 over six real entries.
suppressed_by_size: usizeHow many entries the /Size filter removed.
Non-zero means the file is hiding cross-reference entries
behind an under-reported /Size. That matters to the writer
beyond diagnostics: raising /Size — which any object creation
does — would expose every one of them, resurrecting objects
the operator never touched and which may not even parse. See
crate::document::Document::suppressed_object_count.
The object numbers whose winning cross-reference entry came from a
hybrid file’s /XRefStm stream rather than from any classic table
(§7.5.8.4) — the file’s hidden objects (Pass 281.0).
§Why this has to be retained rather than re-derived
§7.5.8.4 describes a three-part unit a writer “creates … at the same time”: a main classic table where the hidden objects are free with generation 65535, an update section, and a cross-reference stream that gives their real locations. To rewrite such a file, a writer must know which objects belong on which side.
The alternative — re-deriving hiddenness from §7.5.8.4’s recursive
visibility rule (“the root … shall not be hidden, nor any object that
is visible from the root”) — answers a different question. That
rule says what a producer is allowed to hide; this set records what
this file did hide. A file may legally hide less than it could, and a
rewrite that re-derived the maximum would move objects the operator
never touched from one side of the partition to the other, which is
precisely the “plausible, working, wrong file” R33 exists to prevent.
Empty for every non-hybrid file, and empty for a hybrid file whose
/XRefStm did not parse — the writer distinguishes those two cases,
because the second one means the partition is unknown rather than
absent.
hybrid_stream_unreadable: boolWhether the newest section named an /XRefStm that pdfcer could not
parse (Pass 281.0).
A broken /XRefStm is deliberately not fatal to loading — the
module docs explain why (§7.5.8.4 guarantees the visible graph is
resolvable without it), and every hidden object is optional by
construction. It is fatal to a full rewrite: the file says it hides
objects, pdfcer cannot say which, and emitting either partition would
be a guess. crate::writer::WriteError::HybridFullRewrite keeps that
case.
Implementations§
Source§impl LoadedXref
impl LoadedXref
Sourcepub fn hybrid_partition(&self) -> HybridPartition
pub fn hybrid_partition(&self) -> HybridPartition
This file’s §7.5.8.4 partition, as one value for the writer
(Pass 281.0).