Write XeLaTeX named PDF objects and streams in native shipout
This commit is contained in:
1 parent
c02f678bf7
commit
e14361fec6
8 files changed
+551
-43
No files matched your search
@@ -1,6 +1,7 @@
|
||||
//! TeX special whatsits and PDF driver dispatch at shipout.
|
||||
use super::*;
|
||||
use crate::pdf_device::{PdfDriver, PdfGraphics, PdfLiteralMode, PdfMatrix};
|
||||
use crate::resources::ResourceKind;
|
||||
|
||||
impl Executor {
|
||||
pub(super) fn scan_special(
|
||||
@@ -68,11 +69,30 @@ impl Executor {
|
||||
return Ok(());
|
||||
}
|
||||
self.reads.insert(Dependency::PdfCatalogState);
|
||||
let navigation = Arc::make_mut(self.state.xdv_navigation.get_or_insert_with(Default::default));
|
||||
let warnings = if kind == b"docview" {
|
||||
navigation.merge_catalog(operands, position, self.limits.tokens)
|
||||
let warnings = if matches!(kind, b"docview" | b"outline") {
|
||||
let navigation = Arc::make_mut(self.state.xdv_navigation.get_or_insert_with(Default::default));
|
||||
if kind == b"docview" {
|
||||
navigation.merge_catalog(operands, position, self.limits.tokens)
|
||||
} else {
|
||||
navigation.add_outline(operands, position, (position.page, graphics_step, 1), self.limits.tokens)
|
||||
}
|
||||
} else {
|
||||
navigation.add_outline(operands, position, (position.page, graphics_step, 1), self.limits.tokens)
|
||||
use crate::pdf_device::xdv_navigation::ObjectCommand;
|
||||
let mut command = ObjectCommand::parse(kind, operands, position)
|
||||
.map_err(|error| self.error(error, special.span))?;
|
||||
let size = command.load_file(|name| {
|
||||
let from = self.source_name(special.span);
|
||||
self.reads.insert(Dependency::FileLookup {
|
||||
name: name.to_owned(),
|
||||
from: from.clone(),
|
||||
});
|
||||
files.resource(ResourceKind::PdfImage, name, &from)
|
||||
.map(|resource| resource.data)
|
||||
.map_err(|error| format!("cannot open XDV PDF stream file {name}: {error}"))
|
||||
}).map_err(|error| self.error(error, special.span))?;
|
||||
self.check_cancellation()?;
|
||||
let navigation = Arc::make_mut(self.state.xdv_navigation.get_or_insert_with(Default::default));
|
||||
navigation.apply_object(command, operands.len().saturating_add(size), self.limits.tokens)
|
||||
}.map_err(|error| self.error(error, special.span))?;
|
||||
for warning in warnings {
|
||||
files.observe_diagnostic(WriteDestination::TerminalAndLog, &warning)
|
||||
@@ -318,6 +338,8 @@ pub(super) fn xdv_navigation_operand(data: &[u8]) -> Option<(&'static [u8], &[u8
|
||||
for (name, kind) in [
|
||||
(b"dest".as_slice(), b"dest".as_slice()), (b"destination", b"dest"),
|
||||
(b"docview", b"docview"), (b"outline", b"outline"), (b"out", b"outline"),
|
||||
(b"obj", b"obj"), (b"object", b"obj"), (b"put", b"put"), (b"close", b"close"),
|
||||
(b"stream", b"stream"), (b"fstream", b"fstream"),
|
||||
] {
|
||||
if let Some(operands) = xdv_operand(body, name) {
|
||||
return Some((kind, operands));
|
||||
|
||||
Reference in new issue
Block a user