You must take into account the crop margins and it may also be required to
scale the PDF to fit in the new page.
Paulo
________________________________
From: Matthew Hawkins [matthew.hawk...@patersons.net]
Sent: Thursday, March 11, 2010 11:36 AM
To: itext-questions@lists.sourceforge.net
Subject: [iText-questions] When creating new document based on pages of
existing, top gets cropped?
Hi,
I am creating several new PDF documents based on selected pages from a master
document using the following code:
private static byte[] getPDF(final int startPage, final int endPage, final
PdfReader reader) {
Document doc = new Document(reader.getPageSize(1));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
PdfWriter writer = PdfWriter.getInstance(doc, baos);
doc.open();
PdfContentByte cb = writer.getDirectContent();
PdfImportedPage p;
for(int i = startPage; i <= endPage; i++) {
doc.newPage();
p = writer.getImportedPage(reader, i);
cb.addTemplate(p, 0, 0);
}
//fos.flush();
doc.close();
//fos.close();
baos.flush();
baos.close();
} catch(IOException ex) {
throw new IllegalStateException("Error genereating new split PDF. "
+ ex.getMessage());
} catch(DocumentException ex) {
throw new IllegalStateException("Error genereating new split PDF. "
+ ex.getMessage());
}
return baos.toByteArray();
}
For some master PDFs, the new smaller PDFs generated are fine - however for
some PDFs, it appears that the tables on the document are getting stretched,
resulting in the top of the document appearing to be cropped.
Has anyone noticed this before and does anyone have a solution, and also is
there a better way of doing the above which guarantees I get a one to one copy
from the main PDF to the smaller PDFs?
Many thanks,
Matthew Hawkins
Email has been scanned for viruses
Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter
informação confidencial ou legalmente protegida. A incorrecta transmissão desta
mensagem não significa a perca de confidencialidade. Se esta mensagem for
recebida por engano, por favor envie-a de volta para o remetente e apague-a do
seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de
usar, revelar ou distribuir qualquer parte desta mensagem.
Disclaimer:
This message is destined exclusively to the intended receiver. It may contain
confidential or legally protected information. The incorrect transmission of
this message does not mean the loss of its confidentiality. If this message is
received by mistake, please send it back to the sender and delete it from your
system immediately. It is forbidden to any person who is not the intended
receiver to use, distribute or copy any part of this message.
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions:
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/