iTextSharp签名图像未显示在PDF签名字段中

时间:2012-06-20 22:32:10

标签: itextsharp itext

我一天中的大部分时间都在研究这个问题。我有一个使用iTextSharp签署PDF文档的现有应用程序。存在数字签名,文本表示显示在PDF上的签名字段中,但签名的图像不显示。

以下是相关代码。我感谢您提供的任何帮助/建议。

if (signatureBitmap != null)
{
    if (reader == null) reader = new PdfReader(PDFByteArray);

    pdfStamper = PdfStamper.CreateSignature(reader, outputStream, PDFVersion, null, true);

    PdfSignatureAppearance signatureAppearance = pdfStamper.SignatureAppearance;

    //Add digital certificate to field
    signatureAppearance.SetCrypto(Key, Certificate, null, PdfSignatureAppearance.SELF_SIGNED);
    signatureAppearance.Reason = Reason;
    signatureAppearance.Location = Location;

    signatureAppearance.Render = PdfSignatureAppearance.SignatureRender.GraphicAndDescription;

    if (signatureBitmap != null)
    {
        iTextSharp.text.Image signatureFieldImage = iTextSharp.text.Image.GetInstance(signatureBitmap, System.Drawing.Imaging.ImageFormat.Bmp);
        signatureAppearance.SignatureGraphic = signatureFieldImage;
    }

    signatureAppearance.Acro6Layers = acroLayer;
    signatureAppearance.SetVisibleSignature(acrobatSignatureFieldName);
    pdfStamper.Close();
    reader.Close();
    reader = null;

}

1 个答案:

答案 0 :(得分:0)

你需要关于你签名的立场,试试这个:

Rectangle rSignature= new Rectangle(100,100);
signatureAppearance.setVisibleSignature(rSignature, 1, "a name");