Thanks, that's exactly what I was looking for. I experiemnted around with 
addImage() and came to the same conclusion, but I wasn't sure if this was a 
bug or a feature (in other words: I wasn't sure if this was the official way or 
not), but now that I know it is, I can start optimizing my code! 
Thanks a lot!

Rog


Bruno Lowagie (iText) wrote:
> Roger Misteli wrote:
>> Hiyas
>>
>> I have a document with, say, 2000 pages and on each page is a little image. 
>> The image is the same over all the 2000 pages. Now, if I simply add the 
>> picture to the document using PdfContentByte and addImage() I get the 
>> desired result, but the same image is written 2000 times and blows up the 
>> document size.
>> Is there a possibility using Watermarks or Templates how I could add it just 
>> one time and let the other images simply point to the existing picture?
> 
> Yes,
> there is a huge difference between:
> 
> Image img = new Image("my_image.pdf");
> for (int i = 0; i < 2000; i++) {
>    addImage(img); // your custom method that adds an image
>    document.newPage();
> }
> 
> and
> 
> for (int i = 0; i < 2000; i++) {
>    Image img = new Image("my_image.pdf");
>    addImage(img); // your custom method that adds an image
>    document.newPage();
> }
> 
> In the first sample, the image bytes are added only once.
> In the second sample, they are added 2000 times.
> On page 449-450 of the book you get an idea of the
> amount of bytes you can save ;-)
> br,
> Bruno
> 
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> iText-questions mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
> Buy the iText book: http://itext.ugent.be/itext-in-action/
> 

-- 
"The absolute value of the TA was less than epsilon."
  -- Comments from MIT course evaluation guide

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to