Support native PDF font dictionaries and running link controls
This commit is contained in:
1 parent
60d7411dfe
commit
b647bd8dcd
19 files changed
+180
-13
No files matched your search
@@ -1325,7 +1325,12 @@ fn native_pdf(
|
||||
return Err("invalid native PDF final stream compression level".into());
|
||||
}
|
||||
let raw_objects = unicode.and_then(|options| options.objects);
|
||||
let font_attributes: BTreeMap<_, _> = fonts.keys().filter_map(|&font| {
|
||||
let settings = unicode?.fonts.pdf_settings(font)?;
|
||||
(!settings.attributes.is_empty()).then_some((font, settings.attributes.as_slice()))
|
||||
}).collect();
|
||||
let resources = if raw_objects.is_some()
|
||||
|| !font_attributes.is_empty()
|
||||
|| pages.iter().any(|page| !page.pdf_resources.entries.is_empty())
|
||||
{
|
||||
let (catalog, info) = if raw_objects.is_some() {
|
||||
@@ -1337,7 +1342,7 @@ fn native_pdf(
|
||||
(None, None)
|
||||
};
|
||||
Some(crate::pdf_device::page_resources::ResourceOutput::prepare(
|
||||
pages, raw_objects, catalog, info,
|
||||
pages, raw_objects, font_attributes, catalog, info,
|
||||
)?)
|
||||
} else {
|
||||
None
|
||||
@@ -1566,7 +1571,9 @@ fn write_native_font(
|
||||
.collect::<Vec<_>>()
|
||||
.join(" ");
|
||||
let cmap = if let Some(options) = options {
|
||||
if options.generate_unicode > 0 && !options.glyph_unicode.is_empty() {
|
||||
if options.fonts.pdf_settings(face.id).is_some_and(|settings| settings.omit_builtin_unicode) {
|
||||
None
|
||||
} else if options.generate_unicode > 0 && !options.glyph_unicode.is_empty() {
|
||||
let texts = paint
|
||||
.encoding
|
||||
.iter()
|
||||
@@ -2089,6 +2096,17 @@ fn write_pdf(
|
||||
}
|
||||
|
||||
let remapped = resources.map(|resources| resources.append(&mut objects, diagnostics));
|
||||
if let Some(resources) = &remapped {
|
||||
for (font, entries) in &resources.fonts {
|
||||
if !entries.is_empty() {
|
||||
let body = &mut objects[native_font_ids[font] - 1];
|
||||
body.truncate(body.len() - 2);
|
||||
body.extend_from_slice(b"\n");
|
||||
body.extend_from_slice(entries);
|
||||
body.extend_from_slice(b"\n>>");
|
||||
}
|
||||
}
|
||||
}
|
||||
let mut kids = Vec::new();
|
||||
let mut page_ids: Vec<usize> = Vec::new();
|
||||
let mut destinations = BTreeMap::new();
|
||||
|
||||
Reference in new issue
Block a user