Write XeLaTeX document name trees and attachments
This commit is contained in:
1 parent
d627614af8
commit
dcc6a3984c
9 files changed
+446
-14
No files matched your search
@@ -3610,16 +3610,31 @@ fn write_pdf(
|
||||
}
|
||||
}
|
||||
}
|
||||
for name in xdv_names.keys() {
|
||||
if !xdv_destinations.contains_key(name.as_slice()) {
|
||||
diagnostics.push(format!("xdvipdfmx: warning: PDF destination {:?} not defined.",
|
||||
String::from_utf8_lossy(name)));
|
||||
}
|
||||
}
|
||||
let empty_xdv = crate::pdf_device::xdv_navigation::Navigation::default();
|
||||
let xdv_objects = xdv.unwrap_or(&empty_xdv);
|
||||
let declared_names = xdv_objects.prepare_names(
|
||||
|key| xdv_destinations.get(key).map(|(destination, _, _)| destination.order),
|
||||
diagnostics,
|
||||
);
|
||||
xdv_destinations.retain(|key, _| {
|
||||
if declared_names.has_destination(key) {
|
||||
diagnostics.push(format!(
|
||||
"xdvipdfmx: warning: Object @{} already defined.",
|
||||
String::from_utf8_lossy(key),
|
||||
));
|
||||
false
|
||||
} else {
|
||||
true
|
||||
}
|
||||
});
|
||||
for name in xdv_names.keys() {
|
||||
if !xdv_destinations.contains_key(name.as_slice()) && !declared_names.has_destination(name) {
|
||||
diagnostics.push(format!("xdvipdfmx: warning: PDF destination {:?} not defined.", String::from_utf8_lossy(name)));
|
||||
}
|
||||
}
|
||||
let mut pending = Vec::new();
|
||||
xdv_objects.collect_references(&mut pending);
|
||||
declared_names.collect_references(&mut pending, &xdv_names, keep_xdv_destinations);
|
||||
for (_, annotation) in &xdv_annotations {
|
||||
annotation.collect_references(&mut pending);
|
||||
}
|
||||
@@ -3678,7 +3693,12 @@ fn write_pdf(
|
||||
.ok_or_else(|| format!("XDV destination refers to nonexistent page {}", destination.page))?;
|
||||
retained.insert(name, destination.array(*page_object, height, magnification, &references)?);
|
||||
}
|
||||
if !retained.is_empty() {
|
||||
let mut generated_names = lopdf::Dictionary::new();
|
||||
if !declared_names.is_empty() {
|
||||
generated_names = declared_names.write(
|
||||
retained, &xdv_names, keep_xdv_destinations, &references, &mut objects,
|
||||
)?;
|
||||
} else if !retained.is_empty() {
|
||||
let entries: Vec<_> = retained.into_iter().map(|(name, value)| {
|
||||
let name = format!("<{}>", name.iter().map(|byte| format!("{byte:02X}")).collect::<String>());
|
||||
(name, value)
|
||||
@@ -3706,7 +3726,7 @@ fn write_pdf(
|
||||
}
|
||||
}
|
||||
objects[0] = if let Some(xdv) = xdv {
|
||||
xdv.finish_catalog(&catalog, &references)?
|
||||
xdv.finish_catalog(&catalog, &references, generated_names, &mut objects, diagnostics)?
|
||||
} else {
|
||||
let mut catalog = catalog.into_bytes();
|
||||
if let Some(extra) = extra {
|
||||
|
||||
Reference in new issue
Block a user