PdfCopy only appends existing documents. If you want an empty page, create in memory a new pdf with a blank page, read it and include it with PdfCopy.
Best Regards,
Paulo Soares
-----Original Message-----
From: [EMAIL PROTECTED] [SMTP:[EMAIL PROTECTED] On Behalf Of Sascha Schmidt
Sent: Thursday, December 04, 2003 10:05
To: [EMAIL PROTECTED]
Subject: Antwort: AW: [iText-questions] Merging PDFs with blank pages
Hello again!
Forget my last mail, it was non-sense. But I'm still unable to insert an empty page after an imported document. I've debugged a little bit but cannot find the reason.
Has somebody else an idea? This is my new snippet:
� private void append(PdfReader reader) throws BadPdfFormatException,
� � � IOException, DocumentException {
� � reader.consolidateNamedDestinations();
� � if (document == null) {
� � � document = new Document(reader.getPageSizeWithRotation(1));
� � � writer = new MyPdfCopy(document, out);
� � � document.open();
� � }
� � final int n = reader.getNumberOfPages();
� � for (int i = 0; i < n; )
� � � writer.addPage(writer.getImportedPage(reader, ++i));
� � �
� � if (reader.getAcroForm() != null)
� � � writer.copyAcroForm(reader);
� � //if (forceEvenPageCount && (n%2 ==1) ){
� � � document.add(new Chunk(" "));
� � � document.newPage();
� � //}
� }
Thanks a lot guys.
Sascha
Sascha Schmidt <[EMAIL PROTECTED]>
Gesendet von: [EMAIL PROTECTED]
04.12.2003 07:36 An
[EMAIL PROTECTED]
Kopie
Thema
Antwort: AW: [iText-questions] Merging PDFs with blank pages
Hi Peter,
Thanks for the fast response. Unfortunately this doesn't work and I think the reason is:
When calling newPage() on a document, method newPage() is invoked for all document-listeners (interface DocListener). In my scenario the PdfCopy object (the writer) is the DocListener and for this class (super class DocWriter) method newPage() has an empty implementation...
Do I have to override methode newPage() in class PdfCopy? And the big question ist: what to do there?! Paulo?
Sascha
"S�lter, Peter" <[EMAIL PROTECTED]> �
Gesendet von: [EMAIL PROTECTED]
03.12.2003 15:37
An
[EMAIL PROTECTED]
Kopie
Thema
AW: [iText-questions] Merging PDFs with blank pages
Hi Sascha,
You need to add an empty Chunk to the new Page like this:
�
document.newPage();
document.add(new Chunk(""));
If you don't, the new page is not added.
Peter
-----Urspr�ngliche Nachricht-----
Von: Sascha Schmidt [mailto:[EMAIL PROTECTED]]
Gesendet: Mittwoch, 3. Dezember 2003 14:35
An: [EMAIL PROTECTED]
Betreff: [iText-questions] Merging PDFs with blank pages
�
Hi!
�
I'm merging PDFs with iText and want to insert a blank page if a pdf file
has an odd total number of pages. It's needed for duplex printing...
Unfortunately it seems to me that method document.newPage() doesn't work
properly here?!?
Here is a snippet of my PDF-Merger; this method is called for each PDF
document:
�
private void append(PdfReader reader) throws BadPdfFormatException,
IOException, DocumentException {
reader.consolidateNamedDestinations();
�
if (document == null) {
document = new Document(reader.getPageSizeWithRotation(1));
writer = new PdfCopy(document, out);
document.open();
}
�
final int n = reader.getNumberOfPages();
for (int i = 0; i < n; ) {
writer.addPage(writer.getImportedPage(reader, ++i));
}
if (reader.getAcroForm() != null)
writer.copyAcroForm(reader);
//if (forceEvenPageCount && (n%2 ==1) ){
document.newPage();
//}
�
}
�
Can somebody help me please? Thanks in advance.
Sascha
�
-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive? �Does it
help you create better code? �SHARE THE LOVE, and help us help
YOU! �Click Here: http://sourceforge.net/donate/
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions
