I use attached code to manipulate an existing pdf (the code actually doesn't change anything, just copies the document into another, but it is enough to produce the problem). When opening the resulting pdf with acrobat reader (I tried last version and some others), I get the message "Error during page elaboration. A problem occured during reading this document (109)".
I attach the the source pdf to be copied (original.pdf), and a sample class which does the job (Copier.java).
Any help would be really appreciated. thank you. --cesare Paulo Soares wrote:
I need the original PDF.Paulo-----Original Message-----From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Cesare CantieriSent: Tuesday, April 15, 2008 7:48 AM To: Post all your questions about iText here Subject: Re: [iText-questions] adobe reader error 109I understand, attached is the PDF which is problematic with adobe reader.thank you --cesare Paulo Soares wrote:reading thisYou know that asking this without posting the PDF won't get you anywhere, don't you?Paulo-----Original Message-----From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Cesare CantieriSent: Monday, April 14, 2008 4:39 PM To: [email protected] Subject: [iText-questions] adobe reader error 109I have been using IText from a few days, it allowed me to produce nice pdf tested with Evince 0.5.2. But, when I tested them using Adobe Acrobat Reader 8 I got the following error: "Error during page elaboration. A problem occured duringdocument (109)" and I cannot see the document correctly.In my code I use Flying Saucer to create a pdf document from HTML (works fine in any reader) then I use following code to manipulate the Flying Saucer output (following code actually doesn't change anyting, just copies the document into another, but it is enough to produce the problem):ByteArrayOutputStream baos = new ByteArrayOutputStream(); Document doc = new Document(); PdfWriter copy = PdfWriter.getInstance(doc, baos); doc.open();PdfReader reader = new PdfReader(PDF_FromFlyingSaucer_Baos.toByteArray()); PdfContentByte cb = copy.getDirectContent(); for (int p = 1; p <= reader.getNumberOfPages(); p++) {doc.newPage(); PdfImportedPage page = copy.getImportedPage(reader, p); cb.addTemplate(page, 0, 0); copy.close(); doc.close(); baos.close();Where am I wrong? note that into the PDF_FromFlyingSaucer_Baos there is text and graphics (HTML tables converted by Flying Saucer).Thank you very much for help --cesareAviso 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.-------------------------------------------------------------------------------------------------------------------------------------------------This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone------------------------------------------------------------------------ _______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions Do you like iText? Buy the iText book: http://www.1t3xt.com/docs/book.php Or leave a tip: https://tipit.to/itexttipjar
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Rectangle;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfImportedPage;
import com.lowagie.text.pdf.PdfReader;
import com.lowagie.text.pdf.PdfWriter;
public class Copier {
public static void main(String[] args)
throws IOException, DocumentException {
new Copier().copy();
}
private void copy() throws IOException, DocumentException {
PdfReader pdfReader = new PdfReader(new FileInputStream("original.pdf"));
Rectangle pageSize = pdfReader.getPageSize(1);
Document doc = new Document(
new Rectangle(pageSize.width(), pageSize.height()));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfWriter copy = PdfWriter.getInstance(doc, baos);
doc.open();
PdfContentByte cb = copy.getDirectContent();
for (int p = 1; p <= pdfReader.getNumberOfPages(); p++) {
doc.newPage();
PdfImportedPage page = copy.getImportedPage(pdfReader, p);
cb.addTemplate(page, 0, 0);
}
copy.close();
doc.close();
FileOutputStream fos = new FileOutputStream("copied.pdf");
fos.write(baos.toByteArray());
fos.close();
}
}
original.pdf
Description: Adobe PDF document
------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions Do you like iText? Buy the iText book: http://www.1t3xt.com/docs/book.php Or leave a tip: https://tipit.to/itexttipjar
