I am using iText C# version  (iTextSharp) to write a ASP.NET application.
 
Basically, I have a template file (created with Acrobat 7.0 pro) containing several user editable textboxes, some of them are multi-line ones. I use PdfStamper to read in the template file, and write to another file, then set fields from database by SetField(String name, String value) from AcroFields.
 
When the pdf file is loaded up inside client browser, I click inside the multi-line text box (font is times roman), the characters shift down. Clicking outside the field, the characters shift up to their original position. If I edit the data, say add just one character or space at the end, I no longer see the shift.
 
I do not know whether this is related to iText way manipulating pdf file, since if I open the template file directly, I do not see the character shift. Has anyone seen such problem, or I missed something. Thanks.
 
Here is my code:
 
      
   // we create a reader for a certain document
   PdfReader reader = new PdfReader( "template.pdf");

   //Set export file name, which is identified by session id
   String  myExportFile ="test" + Session.SessionID.ToString()  + ".pdf";
 
   //Create a file stream with the export file. 
   FileStream myFileStream= new FileStream(myExportFile, FileMode.Create);
 
   //Create a PdfStamper, which read in template pdf from reader, and output to export file
   PdfStamper myStamp = new PdfStamper(reader, myFileStream);
 
   //Get all fields from the pdf file
   AcroFields afFormFields = myStamp.AcroFields;
 
   if(Request.QueryString["print"]=="1")
   {
    //Add _javascript_ to the pdf file, so it will be automatically printed without prompting user
    myStamp._javascript_ = "this.print(false);";
   }
 
   //Get the working object id
   int ID = Convert.ToInt32( Request.QueryString["g_ID"] );
 
   //Construct working object
   TWorking temp = new TWorking (ID);
 
   // filling in the form with setfileds(string, string)
   temp.FillFormWithData(afFormFields);

   //close the stamper
   myStamp.Close();

   //close the reader
   reader.Close();
 
   Response.ClearContent();
   Response.ClearHeaders();
   Response.ContentType = "application/pdf";
   Response.WriteFile(myExportFile);
   Response.Flush();
   Response.Close();
   System.IO.File.Delete(myExportFile);
 


Yahoo! Music Unlimited - Access over 1 million songs. Try it free.

Reply via email to