DSS engine: add background image layering, text auto-scaling, and tolerant field placement#433
DSS engine: add background image layering, text auto-scaling, and tolerant field placement#433sam2kb wants to merge 3 commits into
Conversation
…erant field placement
- JSignPdfSignatureImageParameters: extends DSS SignatureImageParameters
with backgroundImage, backgroundScale, and overrides isEmpty() so
background-only signatures are not silently skipped.
- JSignPdfOverlaySignatureDrawer: custom PDFBox drawer that renders
background image → foreground graphic → text in layers, capped at
the user's preferred font size when FILL_BOX_AND_LINEBREAK is used.
- JSignPdfPdfObjFactory / JSignPdfSignatureDrawerFactory: wire the
custom drawer into PdfBoxSignatureService.
- DssSigningEngine changes:
* Use JSignPdfPdfObjFactory with LogOnStatusAlert (warn instead of
throw) when the signature field overlaps existing annotations.
* Use JSignPdfSignatureImageParameters for background+foreground
image support (upstream limits to a single image).
* Set TextWrapping.FILL_BOX_AND_LINEBREAK so text auto-scales to
fit the signature rectangle.
* Set text background to transparent so the background image shows
through the signature text.
…ignPdfOverlaySignatureDrawer.java
…ignPdfOverlaySignatureDrawer.java
|
Thanks for this — background layering + autoscaling text are genuinely useful additions to the DSS engine. Since the DSS engine hasn't shipped yet (targeting 3.1), I've focused on intrinsic correctness, licensing, and structure. A few things I'd like to see addressed before this lands as the shipped engine: Please fix before merge
Structural concern
Suggestion: select the drawer automatically instead of always replacing itRight now public class JSignPdfSignatureDrawerFactory implements PdfBoxSignatureDrawerFactory {
@Override
public PdfBoxSignatureDrawer getSignatureDrawer(SignatureImageParameters p) {
// Only use the custom layering drawer when a background image is actually configured
if (p instanceof JSignPdfSignatureImageParameters jp && jp.getBackgroundImage() != null) {
return new JSignPdfOverlaySignatureDrawer();
}
// Otherwise fall back to DSS's stock native drawer
return new NativePdfBoxVisibleSignatureDrawer();
}
}Why this is worth doing:
Separately, the overlap relaxation ( |
Add background image layering, text auto-scaling & tolerant placement to DSS engine
What
Background image support. The DSS engine currently only allows a single image - either a signature graphic or a background. This PR adds proper layering: you can now set a background image (with scale control) that renders behind the signature graphic behind the text, all in one signature block.
Text that fits any rectangle. DSS defaults to a fixed font size - text gets cut off on small signature boxes. This switches to auto-scaling mode (FILL_BOX_AND_LINEBREAK), where the font shrinks to fit whatever rectangle you draw, wrapping lines naturally. The user's font size preference still acts as an upper cap (no giant text on huge boxes).
Transparent text background. DSS draws a solid white rectangle behind signature text, which covers any background image underneath. This sets it to transparent so the background image shows through.
Friendlier annotation overlap. If your visible signature rectangle overlaps an existing PDF annotation (e.g. an Adobe stamp), DSS throws an error and refuses to sign. This changes it to a warning - signing proceeds, and the signature appears on top.
Why
These are the features our users needed to fully replace the old OpenPdf engine with DSS:
Background images are essential for professional stamps, seals, and letterhead
Auto-scaling text is critical for workflows with varying signature box sizes
Overlap tolerance is needed when signing over documents that already have annotations
How
Four new classes in engines/dss/.../pdfbox/ plus changes to DssSigningEngine.java to wire them in. All behaviour is opt-in via the existing GUI controls - nothing changes for users who don't use these features.