diff options
| author | Laurenz <laurmaedje@gmail.com> | 2019-10-16 21:31:14 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2019-10-16 21:31:14 +0200 |
| commit | f2f05e07b0ff2d98e3c822b2618d02281ed1078c (patch) | |
| tree | 6f4f8fa046af49c319d68c012a078f3489ab92aa /src/export | |
| parent | a3c667895e4e5d5673931415397523b9615008d3 (diff) | |
Implement space extension (multipage) ➕
Diffstat (limited to 'src/export')
| -rw-r--r-- | src/export/pdf.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/export/pdf.rs b/src/export/pdf.rs index 3c718c2e..f029a37f 100644 --- a/src/export/pdf.rs +++ b/src/export/pdf.rs @@ -80,7 +80,7 @@ impl<'d, W: Write> ExportProcess<'d, W> { ) -> PdfResult<ExportProcess<'d, W>> { let (fonts, font_remap) = Self::subset_fonts(layouts, font_loader)?; - let offsets = Self::calculate_offset(layouts.count(), fonts.len()); + let offsets = Self::calculate_offsets(layouts.count(), fonts.len()); Ok(ExportProcess { writer: PdfWriter::new(target), @@ -155,7 +155,7 @@ impl<'d, W: Write> ExportProcess<'d, W> { /// We need to know in advance which IDs to use for which objects to cross-reference them. /// Therefore, we calculate them in the beginning. - fn calculate_offset(layout_count: usize, font_count: usize) -> Offsets { + fn calculate_offsets(layout_count: usize, font_count: usize) -> Offsets { let catalog = 1; let page_tree = catalog + 1; let pages = (page_tree + 1, page_tree + layout_count as Ref); @@ -203,7 +203,11 @@ impl<'d, W: Write> ExportProcess<'d, W> { )?; // The page objects (non-root nodes in the page tree). - for (id, page) in ids(self.offsets.pages).zip(self.layouts) { + let iter = ids(self.offsets.pages) + .zip(ids(self.offsets.contents)) + .zip(self.layouts); + + for ((page_id, content_id), page) in iter { let rect = Rect::new( 0.0, 0.0, @@ -212,10 +216,10 @@ impl<'d, W: Write> ExportProcess<'d, W> { ); self.writer.write_obj( - id, + page_id, Page::new(self.offsets.page_tree) .media_box(rect) - .contents(ids(self.offsets.contents)), + .content(content_id), )?; } |
