Recalculate native running links from the current PDF geometry
This commit is contained in:
1 parent
cb8ed90df2
commit
975dbc8060
4 files changed
+139
-52
No files matched your search
@@ -750,3 +750,50 @@ fn pdf_navigation_uses_the_logical_matrix_across_shipouts() {
|
||||
assert_eq!(expected.1.len(), 2);
|
||||
assert_eq!(navigation(&native), expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn running_links_use_the_current_matrix_and_last_device_rectangle() {
|
||||
let (reference, native, diagnostics) = pair(
|
||||
r"\pdfdecimaldigits=4 \pdfpagewidth=200pt \pdfpageheight=200pt
|
||||
\pdflinkmargin=1.25pt \pdfdestmargin=2pt
|
||||
\shipout\hbox{\pdfdest name{jump} fit
|
||||
\pdfsave\pdfsetmatrix{0 1 -1 0}
|
||||
\pdfstartlink height3pt depth2pt goto name{jump}\vrule width8pt height3pt\kern-8pt
|
||||
\pdfrestore\kern6pt\pdfendlink\vrule width10pt height6pt}
|
||||
\shipout\hbox{\pdfsave\pdfsetmatrix{2 0 0 1}
|
||||
\pdfstartlink height6pt depth1pt goto name{jump}
|
||||
\kern3pt\pdfdest name{inside} fitr width4pt height9pt depth3pt
|
||||
\kern7pt\pdfendlink
|
||||
\pdfrestore\vrule width10pt height6pt}
|
||||
\shipout\hbox{\pdfsave\pdfsetmatrix{1 0 .5 1}
|
||||
\pdfstartlink height3pt depth1pt goto name{jump}
|
||||
\kern2pt\pdfstartlink width5pt height8pt depth2pt goto name{inside}
|
||||
\kern4pt\pdfendlink\kern3pt\pdfendlink
|
||||
\pdfrestore\vrule width10pt height6pt}
|
||||
\shipout\hbox{\pdfsave\pdfsetmatrix{0 1 -1 0}
|
||||
\kern5pt\pdfdest name{history} fitr width6pt height12pt depth4pt\kern-5pt
|
||||
\pdfrestore\vrule width10pt height6pt}
|
||||
\pdfpageheight=230pt
|
||||
\shipout\hbox{\pdfstartlink height3pt depth2pt goto name{jump}
|
||||
\pdfsave\pdfsetmatrix{1 0 .5 1}
|
||||
\kern9pt\pdfendlink\kern-9pt
|
||||
\pdfrestore\vrule width10pt height6pt}",
|
||||
);
|
||||
assert!(diagnostics.is_empty(), "{diagnostics:?}");
|
||||
|
||||
let page_rectangles = |doc: &Document| {
|
||||
doc.get_pages().values().map(|id| {
|
||||
let page = doc.get_dictionary(*id).unwrap();
|
||||
if page.get(b"Annots").is_err() {
|
||||
return Vec::new();
|
||||
}
|
||||
get(doc, page, b"Annots").as_array().unwrap().iter().map(|annotation| {
|
||||
let dict = doc.get_dictionary(annotation.as_reference().unwrap()).unwrap();
|
||||
comparable(get(doc, dict, b"Rect"))
|
||||
}).collect::<Vec<_>>()
|
||||
}).collect::<Vec<_>>()
|
||||
};
|
||||
let expected = page_rectangles(&reference);
|
||||
assert_eq!(expected.iter().map(Vec::len).collect::<Vec<_>>(), [1, 1, 2, 0, 1]);
|
||||
assert_eq!(page_rectangles(&native), expected);
|
||||
}
|
||||
Reference in new issue
Block a user