Allocate indirect PDF import objects during native writes
This commit is contained in:
1 parent
5a2df6781a
commit
861c9dbfc9
14 files changed
+588
-32
No files matched your search
@@ -1309,7 +1309,9 @@ fn metadata_object(metadata: &PdfMetadata) -> Option<String> {
|
||||
Some(format!("<< {} >>", fields.join(" ")))
|
||||
}
|
||||
|
||||
fn native_information_dictionary(info: crate::pdf_device::PdfInfo<'_>) -> Vec<u8> {
|
||||
fn native_information_dictionary(
|
||||
info: crate::pdf_device::PdfInfo<'_>, banner_separator: Option<char>,
|
||||
) -> Vec<u8> {
|
||||
// pdfTeX suppresses defaults based on the raw byte spelling anywhere in
|
||||
// the expanded list. Preserve the supplied PDF syntax verbatim.
|
||||
let supplied = |key: &[u8]| info.entries.windows(key.len()).any(|value| value == key);
|
||||
@@ -1335,6 +1337,9 @@ fn native_information_dictionary(info: crate::pdf_device::PdfInfo<'_>) -> Vec<u8
|
||||
if !supplied(b"/Trapped") {
|
||||
object.extend_from_slice(b"/Trapped /False\n");
|
||||
}
|
||||
if let Some(separator) = banner_separator {
|
||||
writeln!(&mut object, "/PTEX{separator}Fullbanner (texrra Route-D native)").unwrap();
|
||||
}
|
||||
object.extend_from_slice(b">>");
|
||||
object
|
||||
}
|
||||
@@ -2314,7 +2319,10 @@ fn write_pdf(
|
||||
// retains its measured source image and can precede that registration.
|
||||
let declarations = paint_lists.iter().flat_map(|list| &list.items).filter_map(|item| {
|
||||
if let DisplayItem::PdfImageObject(object) = item {
|
||||
Some((object.image.as_ref(), object.attributes.as_slice(), object.compression, object.png_auxiliary))
|
||||
Some((
|
||||
object.image.as_ref(), object.attributes.as_slice(), object.compression,
|
||||
object.png_auxiliary, object.imports.as_ref(),
|
||||
))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@@ -2323,7 +2331,7 @@ fn write_pdf(
|
||||
let compression = list.pdf.as_ref().map_or(0, |pdf| pdf.stream_compression);
|
||||
list.items.iter().filter_map(move |item| {
|
||||
if let DisplayItem::PdfImage { image, .. } = item {
|
||||
Some((image.as_ref(), &[][..], compression, None))
|
||||
Some((image.as_ref(), &[][..], compression, None, None))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@@ -2566,7 +2574,7 @@ fn write_pdf(
|
||||
}
|
||||
const PNG_GROUP: &[u8] = b"<< /Type /Group /S /Transparency /CS /DeviceRGB /I true >>";
|
||||
if let Some(registry) = registry {
|
||||
for number in registry.png_object_numbers() {
|
||||
for number in registry.png_object_numbers().chain(registry.imported_image_numbers()) {
|
||||
objects.push(Vec::new());
|
||||
device_objects.insert(number, objects.len() as u32);
|
||||
}
|
||||
@@ -2633,11 +2641,12 @@ fn write_pdf(
|
||||
.and_then(|page| page.pdf.as_ref())
|
||||
.map_or((1, 4), |pdf| (pdf.file.major, i32::from(pdf.file.minor)));
|
||||
let mut unwritten_color_spaces = BTreeMap::new();
|
||||
let form_ids: BTreeMap<_, _> = images.into_iter().map(|(image, attributes, compression, auxiliary)| {
|
||||
let form_ids: BTreeMap<_, _> = images.into_iter().map(|(image, attributes, compression, auxiliary, imports)| {
|
||||
let physical = |number: u32| device_objects[&number] as usize;
|
||||
let targets = crate::pdf_image::PdfImageTargets {
|
||||
image: image.pdf_object_number.map(physical),
|
||||
png_auxiliary: auxiliary.map(physical),
|
||||
imports: imports.map(|imports| (imports, &device_objects)),
|
||||
};
|
||||
let color_space = image.image.color_space.map(|number| {
|
||||
let Ok(reference) = u32::try_from(number) else {
|
||||
@@ -3313,7 +3322,7 @@ fn write_pdf(
|
||||
if device.driver == crate::pdf_device::PdfDriver::Xdv {
|
||||
crate::pdf_device::xdv_document::information_dictionary(info, diagnostics)?
|
||||
} else {
|
||||
native_information_dictionary(info)
|
||||
native_information_dictionary(info, options.ptex_banner_separator)
|
||||
}
|
||||
}
|
||||
None => metadata_object(metadata)
|
||||
|
||||
Reference in new issue
Block a user