Write XeLaTeX named PDF objects and streams in native shipout

This commit is contained in:
gloamxun committed 2026-11-28 18:22:15 +08:00
1 parent c02f678bf7
commit e14361fec6
8 files changed
+551 -43

No files matched your search

+17 -3
View File
@@ -3510,13 +3510,27 @@ fn write_pdf(
xdv_names.entry(name.to_vec()).or_insert_with(|| format!("{index:x}").into_bytes());
}
}
let empty_xdv = crate::pdf_device::xdv_navigation::Navigation::default();
let xdv_objects = xdv.unwrap_or(&empty_xdv);
let mut pending = Vec::new();
xdv_objects.collect_references(&mut pending);
for (_, annotation) in &xdv_annotations {
annotation.collect_references(&mut pending);
}
let named_objects = xdv_objects.reserve_objects(pending, &mut objects)?;
let references = crate::pdf_device::xdv_object::References {
pages: &navigation.pages,
named: &named_objects,
};
let compression = pages[0].pdf.as_ref().map_or(0, |pdf| pdf.stream_compression);
xdv_objects.write_objects(&references, &mut objects, compression, diagnostics)?;
for (id, annotation) in xdv_annotations {
objects[id - 1] = annotation.pdf(&navigation.pages, &xdv_names)?;
objects[id - 1] = annotation.pdf(&references, &xdv_names)?;
}
if let Some(xdv) = xdv {
let open_depth = unicode.unwrap().xdv_outline_open_depth;
if let Some(outlines) = xdv.write_outlines(
&navigation.pages, &mut objects, &xdv_names, open_depth,
&references, &mut objects, &xdv_names, open_depth,
)? {
catalog.push_str(&format!(" /Outlines {outlines} 0 R"));
}
@@ -3593,7 +3607,7 @@ fn write_pdf(
}
}
objects[0] = if let Some(xdv) = xdv {
xdv.finish_catalog(&catalog, &navigation.pages)?
xdv.finish_catalog(&catalog, &references)?
} else {
let mut catalog = catalog.into_bytes();
if let Some(extra) = extra {