M5: the placeholder for an unknown stamp name stays grey whatever its /C

An AP-less stamp whose /Name has no drawing got its placeholder frame in
the annotation's /C colour (/C [1 0 0] drew a red frame), while the doc
comment and parity note promise a neutral grey one. The frame now always
strokes PLACEHOLDER_GREY; the fourteen Table 184 names keep /C.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0175FWj4xFhMhSH3UpMU8DSC
This commit is contained in:
mtlcl410
2026-10-24 09:27:38 +08:00
co-authored by Claude Opus 5.5
parent 3db28cc4e3
commit 2f97fd2d59
2 changed files with 9 additions and 4 deletions
+6 -4
View File
@@ -843,9 +843,10 @@ fn standard_stamp(name: &[u8]) -> Option<(&'static str, Rgb)> {
const PLACEHOLDER_GREY: Rgb = [0.45, 0.45, 0.45];
/// The display appearance of a rubber stamp another program wrote without one: the stamp its
/// `/Name` names (Draft when there is none, Table 184's default), or for any other name a thin
/// grey frame with both diagonals, so the stamp stays visible and can be selected. The name is
/// never drawn as text.
/// `/Name` names (Draft when there is none, Table 184's default) in its `/C` colour or the
/// stamp's own, or for any other name a thin grey frame with both diagonals, so the stamp stays
/// visible and can be selected. The frame is grey whatever the `/C`: it stands in for a stamp
/// that cannot be drawn, so it takes none of that stamp's colour. The name is never drawn as text.
///
/// For display only ([`crate::with_missing_appearances`]): [`build`] declines these stamps, so
/// edits (restyling, flattening) never write this drawing into the file. `None` for any other
@@ -884,7 +885,8 @@ pub(crate) fn display_stamp(d: &Dict) -> Option<Stream> {
}
c.push_str(&format!(
"{}1 w\n{} {} {} {} re\n{} {} m {} {} l\n{} {} m {} {} l\nS\n",
rg_stroke(stroke.unwrap_or(PLACEHOLDER_GREY)),
// Grey whatever the `/C`: the placeholder is not the stamp, so it takes none of its colour.
rg_stroke(PLACEHOLDER_GREY),
n(a0),
n(b0),
n(a1 - a0),
+3
View File
@@ -1064,6 +1064,9 @@ fn a_stamp_without_an_appearance_draws_the_stamp_it_names() {
}
// `/C` colours the stamp, as it does PdfCraft's own.
assert!(drawn(&stamp_dict("/Name /Final /C [1 0 1]")).contains("1 0 1 RG"));
// The placeholder stays grey whatever the `/C`: it is not the stamp, so it takes none of its colour.
let placeholder = drawn(&stamp_dict("/Name /MyCustomStamp /C [1 0 0]"));
assert!(placeholder.contains("0.45 0.45 0.45 RG") && !placeholder.contains("1 0 0 RG"), "{placeholder}");
// A stamp's own artwork is never replaced, and the drawing is for display only: edits
// (restyling, flattening) still find nothing they may write.
assert!(appearance::display_stamp(&stamp_dict("/Name /Draft /AP << /N 9 0 R >>")).is_none());