Implement native PDF links and vertical discard lists
This commit is contained in:
1 parent
b6567f67e2
commit
a53d9c9bf9
29 files changed
+980
-109
No files matched your search
@@ -271,6 +271,8 @@ impl Executor {
|
||||
let mut pdf_graphics_steps = Vec::new();
|
||||
let mut graphics_stack = Vec::new();
|
||||
let outputs = b.output_nodes();
|
||||
let mut link_depth = self.pdf_link_stack.len();
|
||||
let has_link_material = link_depth != 0 || outputs.iter().any(|node| node.is_pdf_link());
|
||||
let mut graphics_positions = if outputs.iter().any(|node| node.is_pdf_graphics()) {
|
||||
b.pdf_graphics_positions().into_iter()
|
||||
} else {
|
||||
@@ -295,6 +297,20 @@ impl Executor {
|
||||
&mut graphics_stack,
|
||||
files,
|
||||
)?);
|
||||
} else if let OutputOperation::PdfLink(link) = &output.operation {
|
||||
use crate::pdf_device::links::LinkNode;
|
||||
self.current = output.span;
|
||||
self.tick()?;
|
||||
if device.pdf.is_none() {
|
||||
return self.fail("cannot ship a PDF link operation to DVI");
|
||||
}
|
||||
match link {
|
||||
LinkNode::Start(_) if link_depth == 10 => return self.fail("PDF link stack capacity exceeded"),
|
||||
LinkNode::Start(_) => link_depth += 1,
|
||||
LinkNode::End if link_depth == 0 => return self.fail("\\pdfendlink used without \\pdfstartlink"),
|
||||
LinkNode::End => link_depth -= 1,
|
||||
LinkNode::Destination { .. } => {}
|
||||
}
|
||||
} else {
|
||||
self.output_node(output, files)?;
|
||||
}
|
||||
@@ -311,6 +327,11 @@ impl Executor {
|
||||
*span,
|
||||
));
|
||||
}
|
||||
let pdf_links = if has_link_material {
|
||||
self.ship_pdf_link_material(&b, &device, &pdf_graphics_steps, files)?
|
||||
} else {
|
||||
Default::default()
|
||||
};
|
||||
self.current = current;
|
||||
self.native_page.as_mut().unwrap().dead_cycles = 0;
|
||||
let before = self.statistics_before_shipout(&b, files)?;
|
||||
@@ -320,6 +341,7 @@ impl Executor {
|
||||
pdf_color_start,
|
||||
pdf_color_steps,
|
||||
pdf_graphics_steps,
|
||||
pdf_links,
|
||||
})));
|
||||
self.statistics_after_shipout(before, files)?;
|
||||
Ok(())
|
||||
|
||||
Reference in new issue
Block a user