I am having a heck of a time trying to insert a page between pages 1 &
2. The inserted page has some dynamic content. The original document is
tagged so it can reflow for Pocket PC readers. Stamping works great to
preserve tagging, but I cannot figure out how to insert a page using the
stamper alone. I tried using a combination of a stamper to read and a
writer to write, but I kept getting errors opening the document. Any
ideas? Thanks.
Warning! VB code ahead!
Dim reader As PdfReader = New
PdfReader("C:\Jess\Documents\Showtime.pdf")
Dim rect As Rectangle = reader.getPageSize(1)
Dim xPos As Single = rect.width
Dim yPos As Single = rect.height
Dim m As java.io.ByteArrayOutputStream = New
ByteArrayOutputStream
Dim stamp As PdfStamper = New PdfStamper(reader,
m)
Dim arial As BaseFont =
BaseFont.createFont("C:\Windows\Fonts\arial.ttf", BaseFont.WINANSI,
BaseFont.EMBEDDED)
Dim i As Integer
Dim cb As PdfContentByte ' =
stamp.getWriter.getDirectContent
For i = 1 To reader.getNumberOfPages
If i = 2 Then
'build a table and add it to a
document
'Dim tbl As Table - create it's
contents etc...
Dim newDoc As Document = New
Document(New Rectangle(xPos, yPos))
Dim m2 As
java.io.ByteArrayOutputStream = New ByteArrayOutputStream
Dim w2 As PdfWriter =
PdfWriter.getInstance(newDoc, m2)
newDoc.open()
Dim cb2 As PdfContentByte =
w2.getDirectContent
newDoc.newPage()
newDoc.add(tbl)
newDoc.close()
Dim r2 As PdfReader = New
PdfReader(m2.buf)
cb = stamp.getOverContent(i)
Dim page As PdfImportedPage =
stamp.getImportedPage(r2, 1)
cb.addTemplate(page, 0, 0)
stamp.close()
Else
End If
cb = stamp.getUnderContent(i)
Dim pdfImportPage As PdfImportedPage =
stamp.getImportedPage(reader, i)
cb.addTemplate(pdfImportPage, 0, 0)
stamp.close()
Next
Dim f As FileOutputStream = New
FileOutputStream("test.pdf")
f.write(m.buf, 0, m.count)
f.flush()
f.close()
-------------------------------------------------------
This SF.Net email is sponsored by Sleepycat Software
Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to deliver
higher performing products faster, at low TCO.
http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions