Skip to main content

LinearizationParams

Struct LinearizationParams 

Source
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

Source

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.

Source

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

Source§

fn clone(&self) -> LinearizationParams

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LinearizationParams

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for LinearizationParams

Source§

fn eq(&self, other: &LinearizationParams) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for LinearizationParams

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V