Ship native PDF annotations with reserved object numbers
This commit is contained in:
1 parent
975dbc8060
commit
de4bd1fa76
14 files changed
+299
-67
No files matched your search
@@ -3079,7 +3079,7 @@ fn write_pdf(
|
||||
let native_annotation_ids: Vec<_> = list.pdf_links.annotations.iter().enumerate()
|
||||
.map(|(index, _)| {
|
||||
remapped.as_ref()
|
||||
.and_then(|resources| resources.link_objects.get(&(page_index, index)).copied())
|
||||
.and_then(|resources| resources.annotation_objects.get(&(page_index, index)).copied())
|
||||
.unwrap_or_else(|| {
|
||||
let id = next_annotation;
|
||||
next_annotation += 1;
|
||||
@@ -3215,7 +3215,12 @@ fn write_pdf(
|
||||
let coordinates = [left, height - bottom, right, height - top].map(physical);
|
||||
let entries = remapped.as_ref().and_then(|resources|
|
||||
resources.annotations[page_index][index].as_deref());
|
||||
let mut body = if let Some(entries) = entries {
|
||||
let mut body = if let AnnotationAction::Direct(raw) = &annotation.action {
|
||||
let mut body = b"<< /Type /Annot\n".to_vec();
|
||||
body.extend_from_slice(entries.unwrap_or(raw));
|
||||
write!(&mut body, "\n/Rect [{}]", coordinates.join(" ")).unwrap();
|
||||
body
|
||||
} else if let Some(entries) = entries {
|
||||
let mut body = format!("<< /Type /Annot /Rect [{}] ", coordinates.join(" ")).into_bytes();
|
||||
body.extend_from_slice(entries);
|
||||
body
|
||||
@@ -3225,7 +3230,7 @@ fn write_pdf(
|
||||
};
|
||||
match &annotation.action {
|
||||
AnnotationAction::User(raw) if entries.is_none() => body.extend_from_slice(raw.as_bytes()),
|
||||
AnnotationAction::User(_) => {}
|
||||
AnnotationAction::User(_) | AnnotationAction::Direct(_) => {}
|
||||
AnnotationAction::GotoName(name) => {
|
||||
write!(&mut body, " /Subtype /Link /A << /S /GoTo /D {} >>", pdf_text(name)).unwrap();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user