如何更改 iText 中 pdfsignature 的矩形样式和默认字段描述?
How do I change the rectangle style and default field descriptions of a pdfsignature in iText?
在执行延迟签名时,我在我的 pdf 中创建了这个空签名
public byte[] emptySignature(String src, String dest, String fieldname)
throws IOException, GeneralSecurityException, DocumentException {
PdfReader reader = new PdfReader(src);
FileOutputStream os = new FileOutputStream(dest);
PdfStamper stamper = PdfStamper.createSignature(reader, os, '[=10=]');
PdfSignatureAppearance appearance = stamper.getSignatureAppearance();
appearance.setLocation("Office");
appearance.setReason("For testing");
Rectangle r = new Rectangle(36, 748, 244, 680);
r.setBackgroundColor(BaseColor.WHITE);
r.setBorderColor(BaseColor.RED);
r.setBorder(1);
r.setBorder(2);
r.setBorder(3);
r.setBorder(4);
appearance.setVisibleSignature(r, 1, fieldname);
ExternalSignatureContainer external = new ExternalBlankSignatureContainer(PdfName.ADOBE_PPKLITE, PdfName.ADBE_PKCS7_DETACHED);
MakeSignature.signExternalContainer(appearance, external, 8192);
byte[] data = IOUtils.toByteArray(appearance.getRangeStream());
return data;
}
签名后我的 pdf 有这个带有默认文本的图章,例如 "Digitally signed by...Date:...Reason:...Location"。
- 如何更改此文本?显然我可以用 setLocation 修改 Location,但是我怎样才能将字段描述和 "Digitally signed" 更改为其他内容?
- 我可以更改签名矩形的样式吗?在执行 setVisibleSignature 之前尝试将边框和背景颜色设置为矩形不起作用
我用 itext 5.5
How do I change this text? Obviously I can modify Location with setLocation, but how can I change field descriptions and "Digitally signed" to something else?
您可以设计完全属于您自己的签名外观,请参阅 , this answer, 等示例。
Can I change the style of a signature rectangle? Trying to set border and background color to rectangle before doing setVisibleSignature doesn't work
仅使用您使用 appearance.setVisibleSignature
设置的矩形的位置和尺寸。对于自定义外观,请参见上文。
在执行延迟签名时,我在我的 pdf 中创建了这个空签名
public byte[] emptySignature(String src, String dest, String fieldname)
throws IOException, GeneralSecurityException, DocumentException {
PdfReader reader = new PdfReader(src);
FileOutputStream os = new FileOutputStream(dest);
PdfStamper stamper = PdfStamper.createSignature(reader, os, '[=10=]');
PdfSignatureAppearance appearance = stamper.getSignatureAppearance();
appearance.setLocation("Office");
appearance.setReason("For testing");
Rectangle r = new Rectangle(36, 748, 244, 680);
r.setBackgroundColor(BaseColor.WHITE);
r.setBorderColor(BaseColor.RED);
r.setBorder(1);
r.setBorder(2);
r.setBorder(3);
r.setBorder(4);
appearance.setVisibleSignature(r, 1, fieldname);
ExternalSignatureContainer external = new ExternalBlankSignatureContainer(PdfName.ADOBE_PPKLITE, PdfName.ADBE_PKCS7_DETACHED);
MakeSignature.signExternalContainer(appearance, external, 8192);
byte[] data = IOUtils.toByteArray(appearance.getRangeStream());
return data;
}
签名后我的 pdf 有这个带有默认文本的图章,例如 "Digitally signed by...Date:...Reason:...Location"。
- 如何更改此文本?显然我可以用 setLocation 修改 Location,但是我怎样才能将字段描述和 "Digitally signed" 更改为其他内容?
- 我可以更改签名矩形的样式吗?在执行 setVisibleSignature 之前尝试将边框和背景颜色设置为矩形不起作用
我用 itext 5.5
How do I change this text? Obviously I can modify Location with setLocation, but how can I change field descriptions and "Digitally signed" to something else?
您可以设计完全属于您自己的签名外观,请参阅
Can I change the style of a signature rectangle? Trying to set border and background color to rectangle before doing setVisibleSignature doesn't work
仅使用您使用 appearance.setVisibleSignature
设置的矩形的位置和尺寸。对于自定义外观,请参见上文。