This is the first time I've used iText so bear with me. While I'm at it
I'll tell you that my Java experience is quite limited as well.
I'm trying to use an existing PDF as a template. I used the example
TwoOnOne.java to get started. I'm able to add the template to the new
pdf document but the size isn't the same as the original. I know it is
because I don't have the correct values on the AddTemplate() method. No
matter what I set the values to I can't seem to get the size right. I've
read the documentation on the transformation matrix but I'm having a
hard time understanding it. Can someone explain to me how I would go
about getting the written page the same size as the reader page? 

// we create a reader for Invoice.pdf
PdfReader reader = new PdfReader("Invoice.pdf");
// we retrieve the size of the first page
Rectangle psize = reader.getPageSize(1);
float width = psize.height();
float height = psize.width();
            
// create document-object
Document document = new Document(new Rectangle(width, height));
// create a writer that listens to the document
PdfWriter writer = PdfWriter.getInstance(document, new
FileOutputStream("InvoiceCopy.pdf"));
// open the document
document.open();
// add content
PdfContentByte cb = writer.getDirectContent();
document.newPage();
PdfImportedPage page1 = writer.getImportedPage(reader, 1);
cb.addTemplate(page1, 0, 0);
document.close();


All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to