Discussion:
[iText-questions] About the performance issue of the iText
Imgen
2009-04-06 12:33:07 UTC
Permalink
I use iText to add bookmarks to an existing pdf file. It's about 750k. But it takes
25s for the PdfStamper.close() to write the file to the disk. My computer's configuration
is Intel Core2 Duo T7500 2.2GHZ + 2G Memory + Win7, not very bad. But the close method
takes too long to complete the action. Is there a way to improve this or I'm simply doomed.
Imgen
2009-04-06 12:33:07 UTC
Permalink
I use iText to add bookmarks to an existing pdf file. It's about 750k. But it takes
25s for the PdfStamper.close() to write the file to the disk. My computer's configuration
is Intel Core2 Duo T7500 2.2GHZ + 2G Memory + Win7, not very bad. But the close method
takes too long to complete the action. Is there a way to improve this or I'm simply doomed.
Alexis Pigeon
2009-04-06 16:15:17 UTC
Permalink
Hi Imgen,
Post by Imgen
I use iText to add bookmarks to an existing pdf file. It's about 750k. But it takes
25s for the PdfStamper.close() to write the file to the disk. My computer's configuration
is Intel Core2 Duo T7500 2.2GHZ + 2G Memory + Win7, not very bad. But the close method
takes too long to complete the action. Is there a way to improve this or I'm simply doomed.
Please provide a standalone piece of code + existing PDF file so that
we might have a chance to reproduce, and maybe pinpoint what's wrong.
If possible, you can also try on your side with another OS, developing
on an alpha/beta OS sounds to me just like asking for trouble...

Cheers,
alexis
Mike Marchywka
2009-04-06 16:26:40 UTC
Permalink
----------------------------------------
Date: Mon, 6 Apr 2009 18:15:17 +0200
Subject: Re: [iText-questions] About the performance issue of the iText
Hi Imgen,
Post by Imgen
I use iText to add bookmarks to an existing pdf file. It's about 750k. But it takes
25s for the PdfStamper.close() to write the file to the disk. My computer's configuration
is Intel Core2 Duo T7500 2.2GHZ + 2G Memory + Win7, not very bad. But the close method
takes too long to complete the action. Is there a way to improve this or I'm
simply doomed.
You may want to note first if it is CPU or VM limited or even run some
standard java tools to profile the code of check the heap contents.

Often, you run into IO limitations. Do you have your own file read/write
subclasses? These are often things like single byte read loops that take forever.
Please provide a standalone piece of code + existing PDF file so that
we might have a chance to reproduce, and maybe pinpoint what's wrong.
If possible, you can also try on your side with another OS, developing
on an alpha/beta OS sounds to me just like asking for trouble...
_________________________________________________________________
Quick access to your favorite MSN content and Windows Live with Internet Explorer 8.
http://ie8.msn.com/microsoft/internet-explorer-8/en-us/ie8.aspx?ocid=B037MSN55C0701A
Imgen
2009-04-07 03:01:58 UTC
Permalink
My code is like below
FileInputStream bmReader = new FileInputStream( "c:\\bookmarks.xml");
List bookmarks = SimpleBookmark.importFromXML( bmReader );
bmReader.close();
PdfReader reader = new PdfReader( "c:\\Testify Manual.pdf" );
reader.consolidateNamedDestinations();
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream("c:\\merged.pdf"));
stamper.setOutlines(bookmarks);
stamper.setViewerPreferences(reader.getSimpleViewerPreferences() | PdfWriter.PageModeUseOutlines);
stamper.close(); //this is the hot spot, it takes 25s to complete processing

About my pdf file, its size is about 750k, please see the attachment.

--------------------------------------------------
From: "Alexis Pigeon" <***@gmail.com>
Sent: Tuesday, April 07, 2009 12:15 AM
To: "Post all your questions about iText here" <itext-***@lists.sourceforge.net>
Subject: Re: [iText-questions] About the performance issue of the iText
Post by Alexis Pigeon
Hi Imgen,
Post by Imgen
I use iText to add bookmarks to an existing pdf file. It's about 750k. But
it takes
25s for the PdfStamper.close() to write the file to the disk. My computer's
configuration
is Intel Core2 Duo T7500 2.2GHZ + 2G Memory + Win7, not very bad. But the
close method
takes too long to complete the action. Is there a way to improve this or I'm
simply doomed.
Please provide a standalone piece of code + existing PDF file so that
we might have a chance to reproduce, and maybe pinpoint what's wrong.
If possible, you can also try on your side with another OS, developing
on an alpha/beta OS sounds to me just like asking for trouble...
Cheers,
alexis
------------------------------------------------------------------------------
_______________________________________________
iText-questions mailing list
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php
Benjamin Rein
2009-04-07 08:00:36 UTC
Permalink
Hi,

please don't use FileOutputStream directly as parameter for PDFStamper. I
would first try to use BufferedOutputStream in addition.

If you don't know enough about streams have a look here:
http://java.sun.com/docs/books/tutorial/essential/io/buffers.html

Best regards
Benjamin



Von:
"Imgen" <***@hotmail.com>
An:
"iText Questions" <itext-***@lists.sourceforge.net>
Datum:
07.04.2009 05:11
Betreff:
[iText-questions] About the performance issue of the iText



My code is like below
FileInputStream bmReader = new FileInputStream(
"c:\\bookmarks.xml");
List bookmarks = SimpleBookmark.importFromXML( bmReader );
bmReader.close();
PdfReader reader = new PdfReader( "c:\\Testify Manual.pdf" );
reader.consolidateNamedDestinations();
PdfStamper stamper = new PdfStamper(reader, new
FileOutputStream("c:\\merged.pdf"));
stamper.setOutlines(bookmarks);
stamper.setViewerPreferences(reader.getSimpleViewerPreferences() |
PdfWriter.PageModeUseOutlines);
stamper.close(); //this is the hot spot, it takes 25s to
complete processing

About my pdf file, its size is about 750k, please see the attachment.

--------------------------------------------------
From: "Alexis Pigeon" <***@gmail.com>
Sent: Tuesday, April 07, 2009 12:15 AM
To: "Post all your questions about iText here" <
itext-***@lists.sourceforge.net>
Subject: Re: [iText-questions] About the performance issue of the iText
Post by Alexis Pigeon
Hi Imgen,
Post by Imgen
I use iText to add bookmarks to an existing pdf file. It's about 750k. But
it takes
25s for the PdfStamper.close() to write the file to the disk. My computer's
configuration
is Intel Core2 Duo T7500 2.2GHZ + 2G Memory + Win7, not very bad. But the
close method
takes too long to complete the action. Is there a way to improve this or I'm
simply doomed.
Please provide a standalone piece of code + existing PDF file so that
we might have a chance to reproduce, and maybe pinpoint what's wrong.
If possible, you can also try on your side with another OS, developing
on an alpha/beta OS sounds to me just like asking for trouble...
Cheers,
alexis
------------------------------------------------------------------------------
Post by Alexis Pigeon
_______________________________________________
iText-questions mailing list
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php
------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
iText-questions mailing list
iText-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php






____________________________________________________________________

Viessmann IT Service GmbH
GeschÀftsfÌhrer: Dirk Klöckner, Dr. Harald Dörnbach
Sitz der Gesellschaft: Allendorf (Eder) - Registergericht:
AG Marburg (Lahn) - HRB 5324 - USt-IdNr.: DE258558424
____________________________________________________________________
Imgen
2009-04-07 14:12:09 UTC
Permalink
Dear Benjamin,
I used a profiler to trace the hotspot, and it turned out it's not the output stream,
it's the PdfReader. PdfReader uses the RandomAccessFileOrArray to access the file, and
PdfStamper.close method eventually calls PRStream.toPdf, and it calls
PdfReader.getStreamBytesRaw which calls RandomAccessFileOrArray.reOpen which
constructs a new file stream every time. And this acounts for almost all the time consumed
by PdfStamper.close. My question is, is there a way to not use RandomAccessFileOrArray and
directly use file stream? Is it possible? I mean, without modifying the source code of iText.


From: Benjamin Rein
Sent: Tuesday, April 07, 2009 4:00 PM
To: Post all your questions about iText here
Subject: [iText-questions] Antwort: About the performance issue of the iText



Hi,

please don't use FileOutputStream directly as parameter for PDFStamper. I would first try to use BufferedOutputStream in addition.

If you don't know enough about streams have a look here:
http://java.sun.com/docs/books/tutorial/essential/io/buffers.html

Best regards
Benjamin


Von: "Imgen" <***@hotmail.com>
An: "iText Questions" <itext-***@lists.sourceforge.net>
Datum: 07.04.2009 05:11
Betreff: [iText-questions] About the performance issue of the iText


--------------------------------------------------------------------------------



My code is like below
FileInputStream bmReader = new FileInputStream( "c:\\bookmarks.xml");
List bookmarks = SimpleBookmark.importFromXML( bmReader );
bmReader.close();
PdfReader reader = new PdfReader( "c:\\Testify Manual.pdf" );
reader.consolidateNamedDestinations();
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream("c:\\merged.pdf"));
stamper.setOutlines(bookmarks);
stamper.setViewerPreferences(reader.getSimpleViewerPreferences() | PdfWriter.PageModeUseOutlines);
stamper.close(); //this is the hot spot, it takes 25s to complete processing

About my pdf file, its size is about 750k, please see the attachment.

--------------------------------------------------
From: "Alexis Pigeon" <***@gmail.com>
Sent: Tuesday, April 07, 2009 12:15 AM
To: "Post all your questions about iText here" <itext-***@lists.sourceforge.net>
Subject: Re: [iText-questions] About the performance issue of the iText
Post by Alexis Pigeon
Hi Imgen,
Post by Imgen
I use iText to add bookmarks to an existing pdf file. It's about 750k. But
it takes
25s for the PdfStamper.close() to write the file to the disk. My computer's
configuration
is Intel Core2 Duo T7500 2.2GHZ + 2G Memory + Win7, not very bad. But the
close method
takes too long to complete the action. Is there a way to improve this or I'm
simply doomed.
Please provide a standalone piece of code + existing PDF file so that
we might have a chance to reproduce, and maybe pinpoint what's wrong.
If possible, you can also try on your side with another OS, developing
on an alpha/beta OS sounds to me just like asking for trouble...
Cheers,
alexis
------------------------------------------------------------------------------
_______________________________________________
iText-questions mailing list
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php
------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com_______________________________________________
iText-questions mailing list
iText-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php





____________________________________________________________________

Viessmann IT Service GmbH
GeschÀftsfÌhrer: Dirk Klöckner, Dr. Harald Dörnbach
Sitz der Gesellschaft: Allendorf (Eder) - Registergericht:
AG Marburg (Lahn) - HRB 5324 - USt-IdNr.: DE258558424
____________________________________________________________________



--------------------------------------------------------------------------------


------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com


--------------------------------------------------------------------------------


_______________________________________________
iText-questions mailing list
iText-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Imgen
2009-04-07 14:12:09 UTC
Permalink
Dear Benjamin,
I used a profiler to trace the hotspot, and it turned out it's not the output stream,
it's the PdfReader. PdfReader uses the RandomAccessFileOrArray to access the file, and
PdfStamper.close method eventually calls PRStream.toPdf, and it calls
PdfReader.getStreamBytesRaw which calls RandomAccessFileOrArray.reOpen which
constructs a new file stream every time. And this acounts for almost all the time consumed
by PdfStamper.close. My question is, is there a way to not use RandomAccessFileOrArray and
directly use file stream? Is it possible? I mean, without modifying the source code of iText.


From: Benjamin Rein
Sent: Tuesday, April 07, 2009 4:00 PM
To: Post all your questions about iText here
Subject: [iText-questions] Antwort: About the performance issue of the iText



Hi,

please don't use FileOutputStream directly as parameter for PDFStamper. I would first try to use BufferedOutputStream in addition.

If you don't know enough about streams have a look here:
http://java.sun.com/docs/books/tutorial/essential/io/buffers.html

Best regards
Benjamin


Von: "Imgen" <***@hotmail.com>
An: "iText Questions" <itext-***@lists.sourceforge.net>
Datum: 07.04.2009 05:11
Betreff: [iText-questions] About the performance issue of the iText


--------------------------------------------------------------------------------



My code is like below
FileInputStream bmReader = new FileInputStream( "c:\\bookmarks.xml");
List bookmarks = SimpleBookmark.importFromXML( bmReader );
bmReader.close();
PdfReader reader = new PdfReader( "c:\\Testify Manual.pdf" );
reader.consolidateNamedDestinations();
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream("c:\\merged.pdf"));
stamper.setOutlines(bookmarks);
stamper.setViewerPreferences(reader.getSimpleViewerPreferences() | PdfWriter.PageModeUseOutlines);
stamper.close(); //this is the hot spot, it takes 25s to complete processing

About my pdf file, its size is about 750k, please see the attachment.

--------------------------------------------------
From: "Alexis Pigeon" <***@gmail.com>
Sent: Tuesday, April 07, 2009 12:15 AM
To: "Post all your questions about iText here" <itext-***@lists.sourceforge.net>
Subject: Re: [iText-questions] About the performance issue of the iText
Post by Alexis Pigeon
Hi Imgen,
Post by Imgen
I use iText to add bookmarks to an existing pdf file. It's about 750k. But
it takes
25s for the PdfStamper.close() to write the file to the disk. My computer's
configuration
is Intel Core2 Duo T7500 2.2GHZ + 2G Memory + Win7, not very bad. But the
close method
takes too long to complete the action. Is there a way to improve this or I'm
simply doomed.
Please provide a standalone piece of code + existing PDF file so that
we might have a chance to reproduce, and maybe pinpoint what's wrong.
If possible, you can also try on your side with another OS, developing
on an alpha/beta OS sounds to me just like asking for trouble...
Cheers,
alexis
------------------------------------------------------------------------------
_______________________________________________
iText-questions mailing list
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php
------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com_______________________________________________
iText-questions mailing list
iText-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php





____________________________________________________________________

Viessmann IT Service GmbH
GeschÀftsfÌhrer: Dirk Klöckner, Dr. Harald Dörnbach
Sitz der Gesellschaft: Allendorf (Eder) - Registergericht:
AG Marburg (Lahn) - HRB 5324 - USt-IdNr.: DE258558424
____________________________________________________________________



--------------------------------------------------------------------------------


------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com


--------------------------------------------------------------------------------


_______________________________________________
iText-questions mailing list
iText-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php

Loading...