Thank you both. It suddenly just all made sense... Thank you for your help
- I couldn't have done it without you!!! Thanks!
Here's the final version of the code (and yes - it is much simpler and
shorter!) Please let me know if you see any glaring errors:
Public Function ReturnCompatiblePdfFromInputStream(ByVal FileUpload1 As
HtmlInputFile) As MemoryStream
Dim fileLen As Integer
Dim myStream As System.IO.Stream
' Get the length of the file.
fileLen = FileUpload1.PostedFile.ContentLength
' Create a byte array to hold the contents of the file.
Dim Input(fileLen) As Byte
' Initialize the stream to read the uploaded file.
myStream = FileUpload1.PostedFile.InputStream
' Read the file into the byte array.
myStream.Read(Input, 0, fileLen)
' Reset to position 0 before we pass it
myStream.Position = 0
' Create a reader to read the stream of the original PDF
Dim reader As New iTextSharp.text.pdf.PdfReader(myStream)
' Create the output stream
Dim output_stream As New MemoryStream
' Create a PDFStamper, which will grab the original contents of the
file and flatten it
Dim pdfStamper As iTextSharp.text.pdf.PdfStamper = New
iTextSharp.text.pdf.PdfStamper(reader, output_stream)
' This allows us to flatten the annotation and the signature
pdfStamper.FormFlattening = True
' We have to set the version of the PDF to be 1.4 so that PDFSharp
can do what it needs to do
pdfStamper.Writer.SetPdfVersion(iTextSharp.text.pdf.PdfWriter.PDF_VERSION_1_4)
' Don't close the stream, as we'll need to access it once the
pdfStamper closes
pdfStamper.Writer.CloseStream = False
' Close the pdfStamper
pdfStamper.Close()
' Reset the file stream to position 0 before we pass it
output_stream.Position = 0
Return output_stream
End Function
--
View this message in context:
http://itext-general.2136553.n4.nabble.com/PDF-to-PDFA-Conversion-tp3303633p3430448.html
Sent from the iText - General mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
_______________________________________________
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