iText7数字签名图像对齐 [英] iText7 Digital Signature Image Alignment

查看:121
本文介绍了iText7数字签名图像对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iText7中,当我将图像添加到数字签名中时,该图像默认位于我定义的Rect的中心,并且任何文本都向右对齐.有没有办法将图像移动到与数字签名的Rect左侧对齐的位置?

In iText7 when I add an image to a digital signature the image defaults to being right in the center of the Rect I've defined with any text aligned to the right. Is there a way to shift the image to aligned to the left of the digital signature's Rect?

com.itextpdf.layout.element.Image有一种使自身向左对齐的方法.但是PdfSignatureAppearance.setSignatureGraphic()需要ImageData参数.

com.itextpdf.layout.element.Image has a way to align itself to the left. But the PdfSignatureAppearance.setSignatureGraphic() requires an ImageData param.

推荐答案

您可以通过检索 PdfFormXObject 第2层并进行绘制,以完全自定义的方式设计签名外观.在上面:

You can design the signature appearance in a completely custom manner by retrieving the PdfFormXObject Layer 2 and drawing on it:

PdfSigner signer = ...
PdfSignatureAppearance appearance = signer.getSignatureAppearance();
PdfFormXObject layer2 = appearance.getLayer2();
try (Canvas layer2Canvas = new Canvas(layer2, signer.getDocument())) {
    [... design your signature appearance on layer2Canvas ...]
}

但是,如果您不想这样做,iText本身就几乎不会为您提供任何选择.

If you don't want to do that, though, iText designs it itself hardly leaving you any options.

这篇关于iText7数字签名图像对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆