Resolve XDV named destinations at PDF shipout

This commit is contained in:
gloamxun committed 2026-11-25 19:47:17 +08:00
1 parent dd695a8945
commit cc147e93d8
12 files changed
+456 -9

No files matched your search

@@ -49,6 +49,42 @@ impl Executor {
})
}
pub(super) fn xdv_destination_special(
&mut self,
special: &ShipoutSpecial,
point: [i64; 2],
links: &mut crate::pdf_device::links::PageLinks,
) -> Result<bool, Error> {
use crate::pdf_device::xdv_destination::Destination;
let data = special.bytes.trim_ascii_start();
if let Some(body) = data.strip_prefix(b"pdf:").map(<[u8]>::trim_ascii_start) {
if let Some(operands) = xdv_operand(body, b"dest").or_else(|| xdv_operand(body, b"destination")) {
let destination = Destination::parse(operands, self.shipped_pages + 1, point)
.map_err(|error| self.error(error, special.span))?;
links.xdv_destinations.push(destination);
return Ok(true);
}
for (name, major) in [(b"majorversion".as_slice(), true), (b"minorversion", false)] {
if let Some(operands) = xdv_operand(body, name) {
if self.shipped_pages == 0 {
self.state.xdv_setup.set_version(major, operands)
.map_err(|error| self.error(error, special.span))?;
}
return Ok(true);
}
}
} else if let Some(body) = data.strip_prefix(b"dvipdfmx:").map(<[u8]>::trim_ascii_start)
&& let Some(operands) = xdv_operand(body, b"config")
{
if self.shipped_pages == 0 {
self.state.xdv_setup.configure(operands)
.map_err(|error| self.error(error, special.span))?;
}
return Ok(true);
}
Ok(false)
}
pub(super) fn render_special(
&mut self,
special: &ShipoutSpecial,