Hi, I am doing one sample project using iTextSharp (using version 5.4.5.0) to fill acrobat fields in PDF template.
1. See from and tom dates in attached image. It will be 10 digit string. but
it is not displaying properly. Do I need to do any fix to display it correctly?
2. After filling acrobat fields, we are not able save the updated PDF template
to local path by clicking "SAVE" button on pdf. It is giving error message "The
document could not be saved. There was a problem reading this document (26)".
Could you please suggest to overcome this error.
public EmptyResult Index(FormCollection form)
{
PdfReader reader = new PdfReader(Server.MapPath(P_InputStream3));
using (MemoryStream ms = new MemoryStream())
{
reader.RemoveUsageRights();
PdfStamper stamper = new PdfStamper(reader,ms);
// Dim stamper As New PdfStamper(reader, New
FileStream(sOutputFile, FileMode.Open), Chr(0), True)
AcroFields fields = stamper.AcroFields;
fields.SetField("1_Efternamn", "surya firstname");
fields.SetField("1_Fornamn", "surya lastname");
fields.SetField("pnummer", "1234567890");
fields.SetField("2_anstallning_from",
System.DateTime.Now.Date.ToString("yyyyMMdd"));
fields.SetField("2_anstalld_tom",
System.DateTime.Now.AddYears(2).Date.ToString("yyyyMMdd"));
fields.SetField("2_chk_ff_anstalld", "true");
fields.SetField("2_arbetsuppgift", "sample test ");
//stamper.FormFlattening = true;2_arbetsuppgift
stamper.Close();
DownloadAsPDF(ms);
reader.Close();
}
return null;
}
private void DownloadAsPDF(MemoryStream ms)
{
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "application/pdf";
Response.AppendHeader("Content-Disposition",
"attachment;filename=certificate.pdf");
Response.OutputStream.Write(ms.GetBuffer(), 0,
ms.GetBuffer().Length);
Response.OutputStream.Flush();
Response.OutputStream.Close();
Response.End();
ms.Close();
}
Thanks in advance.
Regards,
Surya
DISCLAIMER: This email message and all attachments are confidential and may
contain information that is Privileged, Confidential or exempt from disclosure
under applicable law. If you are not the intended recipient, you are notified
that any dissemination, distribution or copying of this email is strictly
prohibited. If you have received this email in error, please notify us
immediately by return email to [email protected] and destroy the
original message. Opinions, conclusions and other information in this message
that do not relate to the official of SPAN, shall be understood to be nether
given nor endorsed by SPAN.
<<attachment: GeneratedPDF.png>>
------------------------------------------------------------------------------ Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________ iText-questions mailing list [email protected] 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
