Skip to content

PdfCraft: An open-source PDF reader and editor written by scratch in pure Rust

M2: integrate current main into PR #3116 and add raster clip-only test

jonathanwxh-celle22d7066c060
diff --cc ROADMAP.md
index 6d67ad441,bad75fc3b..8be3485b1
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@@ -164,7 -170,10 +170,12 @@@ Ranked; detail and the full milestone t
| 8 | 1.0 polish: performance, right-to-left, missing languages, keyboard-only (M14) | 55–95 |
## Progress log
-
+ - **2026-10-18 (M6, #2892):** Push-button normal labels are editable per widget through Options and form_set_props, independently of field names; rendering, undo/redo and incremental/full save/reopen are covered. Estimates unchanged.
+
+ - **2026-10-18 (M7, #3212):** Headers, Bates numbers, watermarks and added text stay visible after unfinished marked content, with original content preserved.
++
+- **2026-10-18 (M2, #3116):** Distinguish clipping-only text from invisible OCR so image-filtered extraction retains clipped headings and ActualText. Vendor changes and regression coverage are documented; estimates unchanged.
++
- **2026-10-15 (M7, Edit text caret):** In a text region that mixes sizes (a 24 pt title over 12 pt lines), the inline editor's caret on a small row was as tall as the region's first size and reached into the row below: egui draws the caret at least one row of the text field's font tall, and that font had the paragraph's first size. The field's font is now half the region's smallest size, so each row's own height decides. Kittest regression; checked in the app on a real document. Estimates unchanged.
- **2026-10-16 (M3, #2781):** The Pages panel follows the current page, as Acrobat's page thumbnails do: going to a page whose thumbnail is out of sight (scrolling, Page Down, Go to page, a bookmark) scrolls the panel just enough to show it. A thumbnail already in view, or clicked, leaves the panel where it is, and a page change while the user scrolls the panel or drags thumbnails does not move it. Estimates unchanged.
- **2026-10-16 (M12, #1645):** CLI info, text and render use the engine's dynamic XFA layout rather than placeholder pages. Synthetic two-page and encrypted-form regressions cover counts, text, pixels, copy permissions and unchanged input bytes. Estimates unchanged.
diff --cc crates/render/src/raster.rs
index b2127894f,13cc5ef69..1e4747ef1
--- a/crates/render/src/raster.rs
+++ b/crates/render/src/raster.rs
@@@ -6852,4 -6892,4 +6892,36 @@@ trailer << /Root 1 0 R >
assert!(render(glyph, 3).as_chunks::<4>().0.iter().all(|p| p[..3] == [255, 255, 255]), "{glyph}: 3 Tr hides the glyph");
}
}
++
++ /// #3109 / #3116: clipping-only text (`7 Tr`) installs a clip for subsequent painting
++ /// but draws no pixels itself.
++ #[test]
++ fn test_clip_only_text_raster_preserves_clipping_without_painting() {
++ let pdf_bytes = |content: &str| {
++ Arc::new(
++ format!(
++ "%PDF-1.7\n1 0 obj << /Type /Catalog /Pages 2 0 R >> endobj\n2 0 obj << /Type /Pages /Kids [3 0 R] /Count 1 >> endobj\n3 0 obj << /Type /Page /Parent 2 0 R /MediaBox [0 0 200 100] /Contents 4 0 R /Resources << /Font << /F1 5 0 R >> >> >> endobj\n4 0 obj << /Length {} >> stream\n{content}\nendstream endobj\n5 0 obj << /Type /Font /Subtype /Type1 /BaseFont /Helvetica /Encoding /WinAnsiEncoding >> endobj\ntrailer << /Root 1 0 R >>\n%%EOF",
++ content.len()
++ )
++ .into_bytes(),
++ )
++ };
++ let render = |content: &str| {
++ let mut r = PageRenderer::new(pdf_bytes(content), RenderConfig::default());
++ let p = r.render(RenderRequest { page: 0, kind: RequestKind::Pixels, tile: None, scale: 1.0, tag: 0, ..Default::default() });
++ assert!(p.error.is_none(), "{content}: {:?}", p.error);
++ p
++ };
++ let white = [255, 255, 255, 255];
++
++ // The text alone paints nothing.
++ let p = render("BT /F1 40 Tf 7 Tr 20 60 Td (Hi) Tj ET");
++ assert!(p.rgba.as_chunks::<4>().0.iter().all(|c| *c == white), "7 Tr alone leaves the page blank");
++
++ // A fill afterwards shows only through the text-shaped clip.
++ let p = render("q BT /F1 40 Tf 7 Tr 20 60 Td (Hi) Tj ET 0 0 1 rg 0 0 200 100 re f Q");
++ let pixels = p.rgba.as_chunks::<4>().0;
++ assert!(pixels.contains(&[0, 0, 255, 255]), "fill shows through the 7 Tr clip");
++ assert!(pixels.contains(&white), "the clip is text-shaped, not the whole page");
++ }
}
diff --cc docs/roadmap.md
index b8c0403e3,e1fdce650..696e0c5d7
--- a/docs/roadmap.md
+++ b/docs/roadmap.md
@@@ -1,10 -1,12 +1,13 @@@
# PdfCraft roadmap: milestones and what's next
+> **2026-10-18:** M2 / #3116: clipping-only glyphs stay extractable with the image filter; invisible OCR remains excluded. Estimates unchanged.
> **Last reviewed:** 2026-10-15 · **Last updated:** 2026-10-15 · **Change:** minor (M14/#2383 GPU-limit candidate; estimates unchanged) · **Target:** Adobe Acrobat Pro (Acrobat DC, continuous track 26.002.21931, macOS)
> **Last reviewed:** 2026-10-15 · **Last updated:** 2026-10-15 · **Change:** minor (M7: the Edit text caret is as tall as the row it is on; estimates unchanged) · **Target:** Adobe Acrobat Pro (Acrobat DC, continuous track 26.002.21931, macOS)
+ > **Last reviewed:** 2026-10-15 · **Last updated:** 2026-10-15 · **Change:** minor (M6: CSV tab-containing headers; estimates unchanged)
+ > **Last reviewed:** 2026-10-15 · **Last updated:** 2026-10-18 · **Change:** minor (M4, #1919: repeated page indices accumulate rotations; M4: indirect page rotations refreshed upstream; M13: CLI check visits each directory once through aliases and cycles; estimates unchanged) · **Target:** Adobe Acrobat Pro (Acrobat DC, continuous track 26.002.21931, macOS)
> **Last reviewed:** 2026-10-18 · **Last updated:** 2026-10-18 · **Change:** minor (M3, #3149: discard render demand after page geometry changes and check the GPU texture limit before upload; estimates unchanged)
> **Last reviewed:** 2026-10-18 · **Last updated:** 2026-10-18 · **Change:** minor (M8, #1350: named replacement descriptions retired during Sanitize and across shared resources; estimates unchanged)
+ > **Last reviewed:** 2026-10-17 · **Last updated:** 2026-10-17 · **Change:** minor (M4 #2997: Ctrl-drag (Option on macOS) in the Organize grid copies the pages into the drop gap; `page_duplicate` takes `at`; estimates unchanged) · **Target:** Adobe Acrobat Pro (Acrobat DC, continuous track 26.002.21931, macOS)
> **Last reviewed:** 2026-10-15 · **Last updated:** 2026-10-15 · **Change:** minor (M6: AcroForm XML text; estimates unchanged)
> **Last reviewed:** 2026-10-15 · **Last updated:** 2026-10-15 · **Change:** minor (M6: preserve XML/XFDF attribute whitespace; refreshed upstream; estimates unchanged) · **Target:** Adobe Acrobat Pro (Acrobat DC, continuous track 26.002.21931, macOS)
> **Last reviewed:** 2026-10-15 · **Last updated:** 2026-10-15 · **Change:** minor (M1: raw-deflate fallback preserves decoding-limit errors; refreshed upstream; estimates unchanged) · **Target:** Adobe Acrobat Pro (Acrobat DC, continuous track 26.002.21931, macOS)