Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support signing using PDF signatures (depends on upstream openpdf changes) #185

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions jsignpdf/src/main/java/net/sf/jsignpdf/SignerLogic.java
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,15 @@ public boolean signFile() {
final String tmpImgPath = options.getImgPath();
if (tmpImgPath != null) {
LOGGER.info(RES.get("console.createImage", tmpImgPath));
final Image img = Image.getInstance(tmpImgPath);
LOGGER.info(RES.get("console.setSignatureGraphic"));
sap.setSignatureGraphic(img);
if (tmpImgPath.endsWith(".pdf")) {
PdfReader sigreader = new PdfReader(tmpImgPath);
LOGGER.info(RES.get("console.setSignatureGraphic"));
sap.setSignaturePDF(sigreader, 1);
} else {
final Image img = Image.getInstance(tmpImgPath);
LOGGER.info(RES.get("console.setSignatureGraphic"));
sap.setSignatureGraphic(img);
}
}
final String tmpBgImgPath = options.getBgImgPath();
if (tmpBgImgPath != null) {
Expand Down Expand Up @@ -319,7 +325,7 @@ public boolean signFile() {
sap.setLayer4Text(options.getL4Text());
LOGGER.info(RES.get("console.setRender"));
RenderMode renderMode = options.getRenderMode();
if (renderMode == RenderMode.GRAPHIC_AND_DESCRIPTION && sap.getSignatureGraphic() == null) {
if (renderMode == RenderMode.GRAPHIC_AND_DESCRIPTION && !sap.hasValidSignatureGraphic()) {
LOGGER.warning(
"Render mode of visible signature is set to GRAPHIC_AND_DESCRIPTION, but no image is loaded. Fallback to DESCRIPTION_ONLY.");
LOGGER.info(RES.get("console.renderModeFallback"));
Expand Down