Use PdfCopy.
Best Regards,
Paulo Soares
-----Original Message-----
From: [EMAIL PROTECTED] [SMTP:[EMAIL PROTECTED] On Behalf Of Rémi Guilbert
Sent: Wednesday, January 28, 2004 19:49
To: itext
Subject: [iText-questions] problem with concat pdf files into a LEGAL size document
Hi, I try to concat a LETTER size document, LEGAL size document and other documents larger than LEGAL. I use this mehod to concat files.
public void concatPDF (String args[], Log log)
{
try {
int f = 1;
// we create a reader for a certain document
PdfReader reader = new PdfReader(args[f]);
// we retrieve the total number of pages
int n = reader.getNumberOfPages();
// System.out.println("There are " + n + " pages in the original file.");
// step 1: creation of a document-object
Document document = new Document(PageSize.LEGAL);
// step 2: we create a writer that listens to the document
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(args[0]));
// step 3: we open the document
document.open();
PdfContentByte cb = writer.getDirectContent();
PdfImportedPage page;
int rotation;
// step 4: we add content
while (f < args.length) {
int i = 0;
while (i < n) {
i++;
document.setPageSize(PageSize.LEGAL);
document.newPage();
page = writer.getImportedPage(reader, i);
rotation = reader.getPageRotation(i);
float height = reader.getPageSize(i).height();
float width = reader.getPageSize(i).width();
if (width > height) {
cb.addTemplate(page, 0, -1f, 1f, 0, 0, 1000);
}
else {
cb.addTemplate(page, 0, 0);
}
}
f++;
if (f < args.length) {
reader = new PdfReader(args[f]);
// we retrieve the total number of pages
n = reader.getNumberOfPages();
}
}
// step 5: we close the document
document.close();
}
catch(Exception e) {
log.enregistrerMessage("Message d'erreur de la méthode concatPDF : " + e.getMessage(),"dev");
//System.err.println(e.getClass().getName() + ": " + e.getMessage());
}
}
The result pdf files is not correct. The header of each LEGAL size document doesn't appear. Only the LETTER size document seems ok. Can you help me ?
Thank's !!
Rémi