mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-26 18:56:55 -06:00
M4.86: PDF page thumbnails and fast web view (linearised files)
Embed Page Thumbnails gives every page a /Thumb image: the page drawn on white, 106 px on its long side, without the layers the page leaves out (the engine draws them; vectorcraft_pdf::page_areas says what each page shows; PDF/X files get grey ones). Optimize for Fast Web View writes a linearised file: the objects are put in linearised order and numbering, encrypted when a password asks (the encryption dictionary goes with the catalog, PDF layers' groups too), then laid out with the linearization dictionary, both cross-reference tables and the page offset and shared object hint tables (the hint stream encrypted like any other). Their "not applied yet" warnings are gone. Reading the objects back uses the lexer of encrypt.rs (syntax.rs adds what rewriting needs). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
87df4a0648
commit
8961824876
@@ -61,6 +61,21 @@ impl Xref {
|
||||
number(entry, 0).map(|(off, _)| off)
|
||||
}
|
||||
|
||||
/// The in-use objects: number and offset, in number order.
|
||||
pub fn objects(&self, pdf: &[u8]) -> Vec<(u32, usize)> {
|
||||
(1..u32::try_from(self.count).unwrap_or(u32::MAX)).filter_map(|n| Some((n, self.offset(pdf, n)?))).collect()
|
||||
}
|
||||
|
||||
/// Where the table (`xref`) starts.
|
||||
pub fn at(&self) -> usize {
|
||||
self.at
|
||||
}
|
||||
|
||||
/// Where the trailer dictionary starts (its `<<`).
|
||||
pub fn trailer_at(&self) -> usize {
|
||||
self.trailer.0
|
||||
}
|
||||
|
||||
/// The object the trailer's `key` (`b"/Root"`) refers to.
|
||||
pub fn trailer_ref(&self, pdf: &[u8], key: &[u8]) -> Option<u32> {
|
||||
let dict = pdf.get(self.trailer.0..self.trailer.1)?;
|
||||
|
||||
Reference in New Issue
Block a user