I'm using iTextSharp 5.3.2.0 to add information to an existing PDF file
that contains a W-2 form. Everything is working perfectly and the PDF
file looks great when written into the browser's response stream;
however, when the user is done looking at the PDF, he is asked "Do you
want to save changed to 'W2.pdf' before closing?" every time he views
the document from the web page.

In trying to narrow the problem down, I've actually stripped out all of
my modifications but the problem continues. Here's the simple version of
my code, with my data-writing call commented out:

        PdfReader pdfReader = new PdfReader(dataSource.ReportTemplate);

        using(MemoryStream outputStream = new MemoryStream())
        using (PdfStamper pdfStamper = new PdfStamper(pdfReader,
outputStream))
        {
            //dataSource.DrawDataFields(pdfStamper);
            pdfStamper.FormFlattening = true;
            return outputStream;
        }

In this case, the "empty" PDF is written to the browser and looks good,
but I still get asked, "Do you want to save" when I close the Acrobat
window.

At this point I was thinking that there was something wrong with the
source PDF file. However, when I send back the PDF file's raw bytes to
the browser, I am NOT asked the "Do you want to save question.

        byte[] bytes = File.ReadAllBytes(dataSource.ReportTemplate);

        using (MemoryStream outputStream = new MemoryStream())
        {
            outputStream.Write(bytes, 0, bytes.Length);
            return outputStream;
        }

My conclusion is that iTextSharp is doing something "bad" to the PDF in
the process of opening it and writing the bytes to the stream, but I'm
new to iTextSharp and could easily be missing something. Help!!!

FWIW, this is Acobat Reader 10.1.4 that we're talking about.

 

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
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

Reply via email to