2012-06-20 184 views
0

我在一天中的大部分時間都研究了此問題。我有一個使用iTextSharp簽署PDF文檔的現有應用程序。數字簽名存在,文本表示顯示在PDF上的簽名字段內,但簽名的圖像不顯示。iTextSharp簽名圖像不顯示在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; 

} 

回答

0

您需要了解您的簽名的位置,嘗試這樣的:

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