|
I need to copy using PdfWriter since modification is required. However contents change with pdfwriter and all pdfs are not copied as well. Below is my code.
How can I do it ?
with PdfCopy:
for (int i = 0; i < n; ) { ++i; page = writer.getImportedPage(reader, i); writer.addPage(page); // pw.println("<br>Processed page " + i); } PRAcroForm form = reader.getAcroForm(); if (form != null) writer.copyAcroForm(reader);
equivalent is :
for (int i = 0; i < n; ) { ++i; page = writer.getImportedPage(reader, i); cb = writer.getDirectContent(); document.setMargins(0,0,0,0); // document.newPage(); int rotation = reader.getPageRotation(i); if (rotation == 90 || rotation == 270) cb.addTemplate(page, 0, -1f, 1f, 0, 0,reader.getPageSizeWithRotation(i).height()); else cb.addTemplate(page, 1f, 0, 0, 1f, 0,0); }
here is the problem, with pdfwriter doesn't copy all forms and anchors and position as pdfCopy.
How can I do it ?
Nilesh
|