pub struct LinearizationParams {
pub linearized: f64,
pub file_length: u64,
pub hint_offset: u64,
pub hint_length: u64,
pub hint_overflow: Option<(u64, u64)>,
pub first_page_object_number: u32,
pub end_of_first_page: u64,
pub page_count: u32,
pub main_xref_offset: u64,
}Expand description
Parsed /Linearized parameter dictionary per ISO 32000-1 §F.2.
Returned by parse_linearization_dict (and from
crate::reader::DocumentReader::linearization). All field names
match the PDF dict keys exactly; the linearized field is the
numeric version (always 1.0 for current Annex F).
Fields§
§linearized: f64/Linearized — the version number (always 1 in published
PDF specs; surfaced as f64 so the parser tolerates the
theoretical “future version” case).
file_length: u64/L — total file length in bytes. Must equal input.len()
for a non-truncated linearized file; the parser does NOT
enforce this (callers may want to surface a mismatch as a
“truncated” diagnostic rather than a hard parse error).
hint_offset: u64/H — primary hint stream [offset, length] (the first two
integers in the /H array). Tables F.3 / F.4 / F.5 / F.6
/ F.7 live inside this hint stream. Some files emit
[off1 len1 off2 len2] for split hint streams; we surface
only the first pair (the mandatory primary).
hint_length: u64§hint_overflow: Option<(u64, u64)>/H overflow / secondary hint stream [offset, length],
when present. Optional per §F.2.
first_page_object_number: u32/O — object number of the first page’s /Page indirect
object. Section F.3.6 anchors the first-page section at this
indirect object’s byte offset.
end_of_first_page: u64/E — byte offset of the end of the first-page section
(one past the last byte of the first page’s contents
stream). A streaming reader can stop downloading once it has
[0, E) and [main_xref_off, file_length).
page_count: u32/N — total page count in the document.
main_xref_offset: u64/T — byte offset of the main cross-reference section
(the one referenced by startxref in non-linearized files).
startxref at the end of a linearized file actually points
at the first-page xref; /T is the way to find the main one.
Implementations§
Source§impl LinearizationParams
impl LinearizationParams
Sourcepub fn parse(input: &[u8]) -> Result<Option<Self>, PdfError>
pub fn parse(input: &[u8]) -> Result<Option<Self>, PdfError>
Try to parse the linearization parameter dictionary from the start of a PDF file.
Returns Ok(None) when:
- The file is too short to contain a linearization parameter dict (< 16 bytes; the spec requires the first 1024 bytes).
- The first indirect object isn’t a dictionary, or it is a
dictionary but doesn’t carry
/Linearized.
Returns Err(PdfError::Other) when /Linearized IS present
but a required key is missing or malformed — the file
declares itself linearized but doesn’t honour the contract.
Sourcepub fn verify(&self, input: &[u8]) -> Result<(), PdfError>
pub fn verify(&self, input: &[u8]) -> Result<(), PdfError>
Verify the parameter dict matches the actual file bytes —
/L equals input.len() and /T points within bounds.
Returns Ok(()) when consistent; Err lists the first
mismatch. Pure diagnostic — parse accepts malformed
values without consulting the file bytes.
Trait Implementations§
Source§impl Clone for LinearizationParams
impl Clone for LinearizationParams
Source§fn clone(&self) -> LinearizationParams
fn clone(&self) -> LinearizationParams
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LinearizationParams
impl Debug for LinearizationParams
Source§impl PartialEq for LinearizationParams
impl PartialEq for LinearizationParams
Source§fn eq(&self, other: &LinearizationParams) -> bool
fn eq(&self, other: &LinearizationParams) -> bool
self and other values to be equal, and is used by ==.