Hello,
I want to generate a pdf with title
"My new title" from a pdf existant (= pdfToClone)
but the title is not add to the new
document
what's the problem? (see sample :
makeCloneWithProperties)
another problem: if I have internal navigation link
in my first document, those link are lose in the new document. why?
thanks
jf
public void
makeCloneWithProperties(byte[] pdfToColone, OutputStream pdfOutputStream)
throws Exception
{ PdfReader pdfReader = new PdfReader(pdfToColone); int nbPageToClone = pdfReader.getNumberOfPages(); if(nbPageToClone == 0){ return; } System.out.println("There are " + nbPageToClone + " pages in the original file."); //
step 1: creation of a
document-object
Document pdfDocumentResult = new Document();
pdfDocument.addTitle("My new title"); //
step 2: we create a writer that listens to the
document
PdfWriter pdfWriter = PdfWriter.getInstance(pdfDocumentResult, pdfOutputStream); //
step 3: we open the document
pdfDocumentResult.open(); PdfContentByte pdfResultContentByte = pdfWriter.getDirectContent(); PdfImportedPage pageToClone; int i = 0; // step 4: we add content while (i < nbPageToClone) { i++; pdfDocumentResult.setPageSize(pdfReader.getPageSize(i)); pdfDocumentResult.newPage(); pageToClone = pdfWriter.getImportedPage(pdfReader, i); pdfResultContentByte.addTemplate(pageToClone, 1f, 0, 0, 1f, 0, 0); System.out.println("Processed page " + i); } // step 5: we close the document pdfDocumentResult.close(); } |
- RE: [iText-questions] pb to add document properties a... Jean-François Selber
- RE: [iText-questions] pb to add document propert... Paulo Soares