Hi,

 

I have been using iTextSharp in an app I wrote for myself.  I have been
using it to produce various types of documents using data that I have stored
in a database.  I have numerous PDF document templates (PDF fillable forms),
and I use iTextSharp to populate the various input fields on the templates,
then I set the "FormFlattening" flag and close the document to produce a PDF
version of the document with no data entry fields.  This has worked just
fine up until I decided to create a template for Avery Labels.  

 

I have attached a "debug" version of my template with this email.  This
debug version of the template has been defined so that each text entry field
will be printed with a "box" around it.  In this way, it is VERY easy to see
the difference between printing the file from Acrobat and printing the
"flattened" version from iTextSharp.  If I print this template from within
Acrobat Reader or Live Cycle Designer, the boxes for each input field appear
on each label of an Avery 5160 sheet as expected.  If I print this same
template using an iTextSharp PdfStamper by opening the template with a
PdfReader, then using the reader to create a PdfStamper object with a
different destination file name, add text to each of the fields, then set
the FormFlattening flag on the PdfStamper to true and close the stamper
object, the boxes do NOT print on the labels in the expected positions.  

 

Based on what I am seeing, it appears that the margins are being handled
differently, and also the sizes of the text fields is different, as well as
the spacing between text boxes.  I have included a sample of my code below.
Any assistance in getting this issue fixed would be greatly appreciated.

 

Thanks,

 

Jim Marciniak

 

 

      private void printLabels()

      {

            //DateTime printDate =
DateTime.Parse(DateTime.Now.ToShortDateString());

            DateTime printDate = DateTime.Now;

            string pdfname = "temp_labels.pdf";

 

            PdfReader reader;

            PdfStamper stamper;

 

            reader = new PdfReader("Avery5160.pdf");

            stamper = new PdfStamper(reader, new
StreamWriter(pdfname).BaseStream);

            AcroFields form = stamper.AcroFields;

 

            string name_address = "John Doe" + Environment.NewLine + 

                                  "123 Any Street" + Environment.NewLine + 

                                  "Anytown, MI 99999";

 

            for (int i = 1; i <= 30; i++)

            {

                  form.SetField("txt_label_" + i.ToString("N0"),
name_address);

            }

 

            stamper.FormFlattening = true;

            stamper.Close();

      }

 

Attachment: Avery5160.pdf
Description: Adobe PDF document

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk
_______________________________________________
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

Reply via email to