You need to flatten the annotations before you start grabbing the pages.
-----Original Message-----
From: Matthew Atherton [mailto:[email protected]]
Sent: Tuesday, April 05, 2011 5:59 PM
To: [email protected]
Subject: Re: [iText-questions] PDF to PDFA Conversion
Leonard Rosenthol-3 wrote:
>
> If the original file has a digital signature, then any conversion will
> break it (as you would expect!). If you want to new file to have a
> signature, you'd need to resign it with the relevant credentials.
>
Hoping you can help. We have an entire system built, regrettably, using
PDFSharp, which cannot handle the newer PDF format that includes IRef
streams.
So, I collaborated with another user on the PDFSharp forum to create some
conversion code usingiTextSharp that takes a newer PDF and converts it down
to "PDF_VERSION_1_4" so that PDFSharp can use the file.
Now, however, one of our vendors has started to digitally sign and annotate
the PDF files that we send to them, and when I use the following code, the
annotation and the digital signature are "stripped off" of the PDF file.
Can you please help me figure out what additional steps I would need to take
to preserve the image of the digital signature and keep the annotation from
being stripped off? (In our case, just having the image of the digital
signature is sufficient).
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
Dim reader As New iTextSharp.text.pdf.PdfReader(myStream)
Dim output_stream As New MemoryStream
' we retrieve the total number of pages
Dim n As Integer = reader.NumberOfPages
' step 1: creation of a document-object
Dim document As New
iTextSharp.text.Document(reader.GetPageSizeWithRotation(1))
' step 2: we create a writer that listens to the document
Dim writer As iTextSharp.text.pdf.PdfWriter =
iTextSharp.text.pdf.PdfWriter.GetInstance(document, output_stream)
'write pdf that pdfsharp can understand
writer.SetPdfVersion(iTextSharp.text.pdf.PdfWriter.PDF_VERSION_1_4)
' step 3: we open the document
document.Open()
Dim cb As iTextSharp.text.pdf.PdfContentByte = writer.DirectContent
Dim page As iTextSharp.text.pdf.PdfImportedPage
Dim rotation As Integer
Dim i As Integer = 0
While i < n
i += 1
document.SetPageSize(reader.GetPageSizeWithRotation(i))
document.NewPage()
page = writer.GetImportedPage(reader, i)
rotation = reader.GetPageRotation(i)
If rotation = 90 OrElse rotation = 270 Then
cb.AddTemplate(page, 0, -1.0F, 1.0F, 0, 0, _
reader.GetPageSizeWithRotation(i).Height)
Else
cb.AddTemplate(page, 1.0F, 0, 0, 1.0F, 0, _
0)
End If
End While
'---- Keep the stream open!
writer.CloseStream = False
' step 5: we close the document
document.Close()
output_stream.Position = 0
Return output_stream
End Function
Here's what comes in, with red outlines around what is getting stripped off.
http://itext-general.2136553.n4.nabble.com/file/n3429590/Original_PDF.png
Here's what we end up with...
http://itext-general.2136553.n4.nabble.com/file/n3429590/Converted_PDF.png
Thank you so much for your help.
Matthew
--
View this message in context:
http://itext-general.2136553.n4.nabble.com/PDF-to-PDFA-Conversion-tp3303633p3429590.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
------------------------------------------------------------------------------
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