diff options
Diffstat (limited to 'src/export/pdf/mod.rs')
| -rw-r--r-- | src/export/pdf/mod.rs | 29 |
1 files changed, 3 insertions, 26 deletions
diff --git a/src/export/pdf/mod.rs b/src/export/pdf/mod.rs index bdbb2bb7..8fc76471 100644 --- a/src/export/pdf/mod.rs +++ b/src/export/pdf/mod.rs @@ -13,7 +13,6 @@ use pdf_writer::types::Direction; use pdf_writer::{Finish, Name, PdfWriter, Ref, TextStr}; use xmp_writer::{LangId, RenditionClass, XmpWriter}; -use self::outline::HeadingNode; use self::page::Page; use crate::doc::{Document, Lang}; use crate::font::Font; @@ -54,7 +53,6 @@ pub struct PdfContext<'a> { image_map: Remapper<Image>, glyph_sets: HashMap<Font, HashSet<u16>>, languages: HashMap<Lang, usize>, - heading_tree: Vec<HeadingNode>, } impl<'a> PdfContext<'a> { @@ -76,36 +74,12 @@ impl<'a> PdfContext<'a> { image_map: Remapper::new(), glyph_sets: HashMap::new(), languages: HashMap::new(), - heading_tree: vec![], } } } /// Write the document catalog. fn write_catalog(ctx: &mut PdfContext) { - // Build the outline tree. - let outline_root_id = (!ctx.heading_tree.is_empty()).then(|| ctx.alloc.bump()); - let outline_start_ref = ctx.alloc; - let len = ctx.heading_tree.len(); - let mut prev_ref = None; - - for (i, node) in std::mem::take(&mut ctx.heading_tree).iter().enumerate() { - prev_ref = Some(outline::write_outline_item( - ctx, - node, - outline_root_id.unwrap(), - prev_ref, - i + 1 == len, - )); - } - - if let Some(outline_root_id) = outline_root_id { - let mut outline_root = ctx.writer.outline(outline_root_id); - outline_root.first(outline_start_ref); - outline_root.last(Ref::new(ctx.alloc.get() - 1)); - outline_root.count(ctx.heading_tree.len() as i32); - } - let lang = ctx .languages .iter() @@ -118,6 +92,9 @@ fn write_catalog(ctx: &mut PdfContext) { Direction::L2R }; + // Write the outline tree. + let outline_root_id = outline::write_outline(ctx); + // Write the document information. let mut info = ctx.writer.document_info(ctx.alloc.bump()); let mut xmp = XmpWriter::new(); |
