Hello all, I'm pretty new to iTextSharp and I'm trying to add the image of a
signature, it's a simple windows image, to a PDF signature field.
When I go to close the stamper, I get a null reference exception, and the pdf
is not written to the memory stream. All the sample's I've found include
setting a certificate when doing the image. (I'd prefer not to have to do this
yet.) This code is in C#. Here's my code.
using (System.IO.MemoryStream output = new
System.IO.MemoryStream())
{
PdfReader reader = new
PdfReader(Request.PhysicalApplicationPath + "\\SamplePDFs\\" + document.Name);
PdfStamper stamper =
PdfStamper.CreateSignature(reader, output, '\0');
PdfSignatureAppearance appearance =
stamper.SignatureAppearance;
System.Drawing.Image signatureImage
= null;
//convert the signature into a .NET
image
Topaz.SigPlusNET sigpad = new
Topaz.SigPlusNET();
sigpad.SetSigCompressionMode(0);
//no compression.
sigpad.SetImageXSize(400);
sigpad.SetImageYSize(100);
sigpad.SetImagePenWidth(1);
sigpad.SetJustifyMode(5);
sigpad.SetSigString(Request["signature"]);
signatureImage =
sigpad.GetSigImage();
stamper.FormFlattening = true;
//set the signature appearance info
appearance.SetVisibleSignature("Signature1");
appearance.Reason = "It's Personal";
appearance.Location = "A location";
appearance.SignatureGraphic =
Image.GetInstance(signatureImage, BaseColor.WHITE);
appearance.Acro6Layers = true;
appearance.Render =
PdfSignatureAppearance.SignatureRender.Graphic;
//write the stamped pdf to the
memory stream
stamper.Close();
//set the browser content type and
attachment. write the memory stream to the browser
Response.ContentType =
"Application/pdf";
Response.AddHeader("Content-Disposition", "attachment;filename=\"" +
document.Name + "\"");
// write the memory stream to the
browser
Response.BinaryWrite(output.GetBuffer());
Response.Flush();
Response.End();
return null;
}
Does anybody have any thoughts? Is the certificate piece required? I was hoping
to not need to put it on there. If it is required, does the root certificate
have to be trusted by the receiver of the document, or is there some kind of
adobe self-signed cert that would work? How does adobe acrobat do the
encryption/signing if it's required? Or could it be an internal CA that the
outside world doesn't know about?
Thanks in advance,
-Ed-
[https://images.mtnam.org/images/image.aspx/2735/e913f29f/1/100/126/1] Edward
Cooke
Programmer II, Information Systems
+1 801-325-6143 tel
+1 801-898-5940 cell
eco...@macu.com
http://www.macu.com
[https://images.mtnam.org/marketing/image.aspx/e913f29f]<https://images.mtnam.org/marketing/image.aspx/1>
[https://images.mtnam.org/marketing/image.aspx/2/fb]<https://images.mtnam.org/marketing/image.aspx/3/fb>
[https://images.mtnam.org/marketing/image.aspx/2/tw]
<https://images.mtnam.org/marketing/image.aspx/3/tw>
________________________________
***Confidentiality and Security Notice: This message and any attachments are
intended only for the use of the individual or entity to which it is addressed
and may contain confidential and/or privileged information. If you are not the
intended recipient you are hereby notified that any dissemination, copying, or
distribution of this message, or attachments, is strictly prohibited. If you
have received this message in error, please notify the sender immediately by
e-mail and delete it from your computer. Do not send sensitive data via
unencrypted email as it may be intercepted in transit***
------------------------------------------------------------------------------
FREE DOWNLOAD - uberSVN with Social Coding for Subversion.
Subversion made easy with a complete admin console. Easy
to use, easy to manage, easy to install, easy to extend.
Get a Free download of the new open ALM Subversion platform now.
http://p.sf.net/sfu/wandisco-dev2dev
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php