如何获得PDVisibleSigProperties将第3页上的签名写到签名框中 [英] How can I get PDVisibleSigProperties to write the signature on the 3 page into the signature box

查看:109
本文介绍了如何获得PDVisibleSigProperties将第3页上的签名写到签名框中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用pdfbox示例签名CreateVisableSignature,并且我希望代码将签名的图像写入到第三页上名为 ApplicantSignature的签名字段中。

I am working with the pdfbox example signature CreateVisableSignature and I would like the code to write the image of the signature into a signature field called "ApplicantSignature" on the third page.

有人能提供线索为什么将签名写在首页的左上角吗?

Can someone give a clue as to why it writes the signature in the upper left corner of the first page?

这里是代码:

    public static void main(String[] args) throws KeyStoreException,
        NoSuchAlgorithmException, CertificateException,
        FileNotFoundException, IOException, COSVisitorException,
        SignatureException {

    if (args.length != 4) {
        usage();
        System.exit(1);
    } else {
        File ksFile = new File(args[0]);
        KeyStore keystore = KeyStore.getInstance("PKCS12", provider);
        char[] pin = args[1].toCharArray();
        keystore.load(new FileInputStream(ksFile), pin);
        File document = new File(args[2]);
        CreateVisibleSignature signing = new CreateVisibleSignature(
                keystore, pin.clone());
        String jpgFile = CreateVisibleSignature.convertPngToJpeg( args[3] );
        FileInputStream image = new FileInputStream( jpgFile );
        PDVisibleSignDesigner visibleSig = new PDVisibleSignDesigner(
                args[2], image, 1);
        visibleSig.xAxis(0).yAxis(0).zoom(-75)
                .signatureFieldName("ApplicantSignature");
        PDVisibleSigProperties signatureProperties = new PDVisibleSigProperties();
        signatureProperties.signerName("name").signerLocation("location")
                .signatureReason("Security").preferredSize(0).page(3)
                .visualSignEnabled(true).setPdVisibleSignature(visibleSig)
                .buildSignature();
        signing.signPDF(document, signatureProperties);
    }
}

我也尝试过:

    PDVisibleSignDesigner visibleSig = new PDVisibleSignDesigner(
                args[2], image, 3);
        visibleSig.xAxis(0).yAxis(0).zoom(-75)
                .signatureFieldName("ApplicantSignature");
        PDVisibleSigProperties signatureProperties = new PDVisibleSigProperties();
        signatureProperties.signerName("name").signerLocation("location")
                .signatureReason("Security").preferredSize(0).page(1)
                .visualSignEnabled(true).setPdVisibleSignature(visibleSig)
                .buildSignature();

我尝试过:

    PDVisibleSignDesigner visibleSig = new PDVisibleSignDesigner(
                args[2], image, 3);
        visibleSig.xAxis(0).yAxis(0).zoom(-75)
                .signatureFieldName("ApplicantSignature");
        PDVisibleSigProperties signatureProperties = new PDVisibleSigProperties();
        signatureProperties.signerName("name").signerLocation("location")
                .signatureReason("Security").preferredSize(0).page(3)
                .visualSignEnabled(true).setPdVisibleSignature(visibleSig)
                .buildSignature();

这是我要在第三页上签名的地方。

This is where I want the signature to go on the third page.

这是第一页上的问题页。

This is where it is going on the first page.

这些是表单中的字段名称。

These are the field names in the form.

推荐答案

基于给定的页面设置我是由回答我问题的人们组成的,我正在根据我对pdfbox中签名如何工作的当前知识发布答案。

Based on the page settings given to me by the folks that responded to my question I am posting an answer base on my current knowledge of how signatures work in pdfbox.

首先,预先存在的表单至少从pdfbox的角度来看,我正在使用的工具似乎只有一页。当我使用adobe DC pro显示坐标时,它仅显示直到第二页中间的坐标。因此,即使我将X,Y坐标设置为100、715,签名图像也会显示在第一页的底部,而不是第三页。

First of all, the pre-existing form that I am working with, at least from a pdfbox perspective, seems to only have one page it in. When I use adobe DC pro to show the coordinates, it only shows the coordinates up to about the middle of the second page. So even though I set the X,Y coordinates to 100, 715, the signature image appears on the bottom of the first page, not on the 3rd.

请更正我如果我错了,但我相信pdfbox仅允许您对整个文档进行签名,而不能对文档中已经存在的单个签名字段进行签名。预先存在的签名字段不受pdfbox的影响,因为pdfbox似乎无法引用它们。

Please correct me if I am wrong, but I believe that pdfbox only allows you sign the entire document and not individual signature fields that already exist in the document. Pre-existing signature fields are not affected by pdfbox as pdfbox appears not to be able to reference them.

如果您在adobe dc pro上调出pdf并单击在签名面板中,您可以看到pdf是由pdfbox签名的,但是预先存在的签名字段仍指示需要对其进行签名。

If you bring up the pdf on adobe dc pro and click on the Signature Panel, you can see that the pdf was signed by pdfbox, but the pre-existing signature fields still indicate that they need to be signed.

我还注意到pdfbox签名是不可见的,即使谁,位置已经设置了,原因和日期,并且您放置在pdfbox签名的签名中的图像是在输出结果pdf中唯一可见的唯一内容。如果没有图像,则硬拷贝打印输出不会显示该文档已签名。

I also noticed that the pdfbox signatures are invisible, even though the "who", "location", "reason", and date have been set, and that the image that you place in the the signature that pdfbox signs is the only thing that is actually visible in the resulting output pdf. If there is no image, then hard copy print outs don't show that the document is signed.

再次,如果我错了,请随时纠正我。

Again, please feel free to correct me if I am wrong.

这篇关于如何获得PDVisibleSigProperties将第3页上的签名写到签名框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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