I suspect you have an extended graphic state on the first page that affects 
color matching/management, and not on the other pages...

Or visa versa...

Or different states.

Solution?  Use the same state in all instances of the image.  Figuring out the 
current state?  That's Hard (though not impossible thanks to 
com.lowagie.text.pdf.parser.*).

You'll want to check out the PDF reference, sections 4.3 (graphic state) and 
4.5 (color spaces)... and maaayyybe 4.8 (images).

Have fun.  :\

--Mark Storer 
  Senior Software Engineer 
  Cardiff.com

#include <disclaimer> 
typedef std::Disclaimer<Cardiff> DisCard; 



> -----Original Message-----
> From: pavanp [mailto:[email protected]]
> Sent: Wednesday, September 23, 2009 2:37 PM
> To: [email protected]
> Subject: Re: [iText-questions] PDFStamper: Color of text in 
> PDF changes
> when replacing button with PNG Image
> 
> 
> 
> Is there any solution for this? 
> I am adding a PdfPtable with background colors in the table 
> cells. but when
> i add a png image to the page, the colors appear darker on 
> the first page
> and the rest of the pages look good(no image on the other 
> pages). so the
> first page colors and the other pages colors are looking different.
> 
> Thanks
> Pavan 
> 
> 
> Leo Erlandsson wrote:
> > 
> > Hi,
> > 
> > I noticed a strange behaviour in PDFStamper yesterday. 
> Maybe I am doing 
> > something wrong...
> > 
> > The color of text (and images, and other objects, note the 
> faded red color 
> > of the box in the example documents) in PDF changes when 
> replacing a push 
> > button with PNG Image. But this only happens if I flatten 
> the form. An 
> > unflattened form maintains the color in the document. 
> > 
> > Code snippet of code reproducing the problem:
> > 
> >         // Get fields
> >         AcroFields form = stamper.getAcroFields();
> > 
> >         // Load PNG Image
> >         Image image = Image.getInstance("image.png");
> >  
> >         // Replace button with image
> >         PushbuttonField bt = 
> form.getNewPushbuttonFromField("picture1");
> >         bt.setLayout(PushbuttonField.LAYOUT_ICON_ONLY);
> >         bt.setProportionalIcon(true);
> >         bt.setImage(image);
> >         form.replacePushbuttonField("picture1", bt.getField());
> >  
> >         // Flatten (or not) and close.
> >         stamper.setFormFlattening(flatten);     // Should 
> we flatten form?
> >         stamper.close();
> >         out.close();
> > 
> > 
> > Please find the attached example template, image, complete 
> example code 
> > and resulting files.
> > 
> > 
> > I am using Adobe Acrobat Reader 8.0. If I view the file in 
> e.g Sun's 
> > PDFRenderer, the color is OK. Maybe the problem is in Adobe Acrobat 
> > Reader? But it is interesting that the color of the 
> document is preserved 
> > if flattening is not done, but altered when the form is flattened.
> > 
> > 
> > 
> > 
> > P.S I bought The Book yesterday. Great stuff!
> > 
> > Sincerely yours
> > Leo 
> > 
> >  
> >  
> >  
> >  
> >  
> > 
> --------------------------------------------------------------
> -----------
> > This SF.net email is sponsored by: Microsoft
> > Defy all challenges. Microsoft(R) Visual Studio 2008.
> > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> > _______________________________________________
> > 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/
> > 
> > 
> 
> -- 
> View this message in context: 
> http://www.nabble.com/PDFStamper%3A-Color-of-text-in-PDF-chang
es-when-replacing-button-with-PNG-Image-tp15476625p25531306.html
Sent from the iText - General mailing list archive at Nabble.com.


------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
iText-questions mailing list
[email protected]
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/


------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
iText-questions mailing list
[email protected]
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/

Reply via email to