Hello experts,
below code tested on itextsharp 5.2.1 and 5.3.2 with same result.
All markups (lines, polygons, text, arrows) done on top of the original
content are MISSING in the output file.
content itself is fine and the code works with no errors. PDFs with no
markup & annotation content work fine with below code.
what can be done about this ?
Is this a bug (or by design) in the iText engine, or do the annotation
objects require special treatment ?
*I would like to preserve all markup & annotations in the outputfile.*
If that is not possible, I would like to at least detect the existence of
them.
I own the itext in action 2nd edition book and the code below is written
with guidance from the book - pages 90,91 (adding objects from template and
wrapping into an image for easier transformation)
thank you in advance,
Hakan
Imports iTextSharp.text.pdf
Imports iTextSharp.text
Dim inputfile As String = "C:\filewithmarkups.pdf"
Dim outputfile As String = "C:\output.pdf"
Dim reader As New PdfReader(inputfile)
Dim NewPageSize As Rectangle = reader.GetPageSizeWithRotation(1)
Dim Zoom As Single = 50
Dim offset_x As Single = 72
Dim offset_y As Single = 72
Dim rotation As Integer = 90
Dim doc As New Document(New Rectangle(0, 0, NewPageSize.Width,
NewPageSize.Height))
Dim writer As PdfWriter = PdfWriter.GetInstance(doc, New
IO.FileStream(outputfile, IO.FileMode.Create))
doc.Open()
Dim page As PdfImportedPage
Dim img As Image
Dim PdfTemp As PdfTemplate
page = writer.GetImportedPage(reader, 1)
PdfTemp = page.CreateTemplate(page.Width, page.Height)
PdfTemp.AddTemplate(page, 1, 0, 0, 1, 0, 0)
writer.ReleaseTemplate(PdfTemp)
img = Image.GetInstance(PdfTemp) 'wrap template into image to make
rotation transformation easier - according to recommendation in book
img.ScalePercent(Zoom)
img.SetAbsolutePosition(offset_x, offset_y)
img.RotationDegrees = rotation
doc.Add(img)
'cleanup
doc.Close()
reader.Close()
writer.Close()
img = Nothing
doc = Nothing
--
View this message in context:
http://itext-general.2136553.n4.nabble.com/pdfWriter-and-pdfReader-is-missing-all-Markup-Annotation-objects-when-using-via-template-tp4656102.html
Sent from the iText - General mailing list archive at Nabble.com.
------------------------------------------------------------------------------
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