0

I'm using iTextSharp to create a pdf form. When I use flattenform and look at the pdf in Preview, the fields are blank. In Acrobat they're filled in. If I don't flattenform, I can see the values in Preview, but the form is editable.

My question: how to make a pdf readonly yet visible?

var reader = new iTextSharp.text.pdf.PdfReader(originalFormLocation);

            using (var stamper = new PdfStamper(reader, new FileStream(outputFormLocation, FileMode.OpenOrCreate)))
            {
                //create instance of Acroform.Fields

                var formFields = stamper.AcroFields;
              //set field values.... 
       formFields.SetField("tPhone", Direct.Substring(5, 8));
               formFields.SetField("tTitle",Title));

              stamper.Writer.PdfVersion = PdfWriter.VERSION_1_7;
              stamper.FormFlattening = true;
              stamper.Close();
              reader.Close();

            }
user948060
  • 953
  • 3
  • 12
  • 25
  • 1
    Which *Preview*? It sounds like some light-weight PDF viewer; such programs are known for their incomplete implementation of the PDF specification. You might also want to supply a sample PDF illustrating the issue. – mkl Oct 14 '13 at 07:55
  • I think he refers to Apple Preview. – iPDFdev Oct 14 '13 at 08:21

0 Answers0