mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-09 04:22:20 +00:00
1 parent
b8c8616d05
commit
8c7ea6377e
2 files changed
+6
-4
No files matched your search
@@ -195,9 +195,10 @@ fn redraws_of_a_long_replacement_share_a_text_budget() {
|
||||
fn text_after_an_inline_image_survives_a_non_ascii_byte_before_a_later_ei() {
|
||||
// Everyday content both ways: a string with a byte above 0x7F, and a later word holding
|
||||
// a capital "EI". The end-of-data look-ahead used to read the string's bytes as image
|
||||
// data, so the image swallowed the rest of the page.
|
||||
// data, so the image swallowed the rest of the page. The image is filtered, so its
|
||||
// length isn't known up front and the look-ahead decides.
|
||||
let pdf = marked_pages(&[
|
||||
"BI /W 1 /H 1 /BPC 8 /CS /DeviceGray ID \0 EI BT /F1 20 Tf 1 0 0 1 20 200 Tm (Gr\u{fc}\u{df}e) Tj 1 0 0 1 20 150 Tm (EINGANG) Tj ET",
|
||||
"BI /W 1 /H 1 /BPC 8 /CS /DeviceGray /F /AHx ID 00> EI BT /F1 20 Tf 1 0 0 1 20 200 Tm (Gr\u{fc}\u{df}e) Tj 1 0 0 1 20 150 Tm (EINGANG) Tj ET",
|
||||
]);
|
||||
|
||||
assert!(marked_text(&pdf, 0).plain_text().contains("EINGANG"), "the text after the inline image was not extracted");
|
||||
|
||||
+3
-2
@@ -1170,8 +1170,9 @@ mod tests {
|
||||
#[test]
|
||||
fn an_inline_image_ends_at_its_own_ei_when_later_text_holds_a_non_ascii_byte() {
|
||||
// `(Grüße)` in WinAnsi, then a word holding a capital "EI": both are everyday content,
|
||||
// and the look-ahead used to read the non-ASCII bytes of the string as image data.
|
||||
let data = b"BI /W 1 /H 1 /BPC 8 /CS /DeviceGray ID \x00 EI BT /F1 12 Tf (Gr\xFC\xDFe) Tj (EINGANG) Tj ET";
|
||||
// and the look-ahead used to read the non-ASCII bytes of the string as image data. The
|
||||
// image is filtered, so its length isn't known up front and the look-ahead decides.
|
||||
let data = b"BI /W 1 /H 1 /BPC 8 /CS /DeviceGray /F /AHx ID 00> EI BT /F1 12 Tf (Gr\xFC\xDFe) Tj (EINGANG) Tj ET";
|
||||
|
||||
assert_eq!(
|
||||
operators(data),
|
||||
|
||||
Reference in new issue
Block a user