英文:
Digital visible Sign with pdfbox 1.8.8
问题
我正在使用 pdfbox 1.8.8 生成 PDF 上的可见签名。
以下是我的代码。我无法在 PDF 中获得可见签名。
我得到的只是一个没有内容的矩形框。
PDDocument document = PDDocument.load(temp);
document.getCurrentAccessPermission().setCanModify(false);
PDSignature signature = new PDSignature();
signature.setFilter(PDSignature.FILTER_ADOBE_PPKLITE);
signature.setSubFilter(PDSignature.SUBFILTER_ADBE_PKCS7_DETACHED);
signature.setName("XyZ");
signature.setLocation("XYZ");
signature.setReason("test");
signature.setSignDate(Calendar.getInstance());
InputStream image = new FileInputStream("download.png");
PDVisibleSignDesigner signatureDesigner = new PDVisibleSignDesigner(
document, image, document.getNumberOfPages());
signatureDesigner.xAxis(0).yAxis(0).zoom(-80).signatureFieldName("signature");
PDVisibleSigProperties signatureProperties = new PDVisibleSigProperties();
signatureProperties.signerName("Xyz").signerLocation("Xyz")
.signatureReason("Test").preferredSize(100).page(1)
.visualSignEnabled(true).setPdVisibleSignature(signatureDesigner).buildSignature();
SignatureOptions options = new SignatureOptions();
options.setVisualSignature(signatureProperties);
document.addSignature(signature, (SignatureInterface) this, options);
/* Sign */
document.saveIncremental(tempIn, tempOut);
实际结果:
预期结果:我希望得到包含图像和签名字段内容的这个区块。
英文:
I'm using pdfbox 1.8.8 to generate Visible sign on PDF.
Here is my code. I'm not able to get visible Sign in pdf.
All I get is a rectangle box having no content.
PDDocument document = PDDocument.load(temp);
document.getCurrentAccessPermission().setCanModify(false);
PDSignature signature = new PDSignature();
signature.setFilter(PDSignature.FILTER_ADOBE_PPKLITE);
signature.setSubFilter(PDSignature.SUBFILTER_ADBE_PKCS7_DETACHED);
signature.setName("XyZ");
signature.setLocation("XYZ");
signature.setReason("test");
signature.setSignDate(Calendar.getInstance());
InputStream image = new FileInputStream("download.png");
PDVisibleSignDesigner signatureDesigner = new PDVisibleSignDesigner(
document, image, document.getNumberOfPages());
signatureDesigner.xAxis(0).yAxis(0).zoom(-80).signatureFieldName("signature");
PDVisibleSigProperties signatureProperties = new PDVisibleSigProperties();
signatureProperties.signerName("Xyz").signerLocation("Xyz")
.signatureReason("Test").preferredSize(100).page(1)
.visualSignEnabled(true).setPdVisibleSignature(signatureDesigner).buildSignature();
SignatureOptions options = new SignatureOptions();
options.setVisualSignature(signatureProperties);
document.addSignature(signature, (SignatureInterface) this, options);
/* Sign */
document.saveIncremental(tempIn, tempOut);
Actual Result :
Expected Result : I want this block with the Image and signature field content.
答案1
得分: 1
1.8.*版本的示例仅支持JPEG文件。
我建议使用2.0.*版本的PDFBox,其中包含两个数字签名示例(包括一个带文本的示例),它们更加灵活,提供了更多功能。
英文:
The example in 1.8.* supports only JPEG files.
I recommend to use the 2.0.* PDFBox version, there are two examples of digital signing (including one with text), and they are more flexible and offer more features.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论