Re: [iText-questions] Problem with transparent images

2008-02-21 Thread Stephan Michels
2008/2/21, Eliot M Cline [EMAIL PROTECTED]:
 The only way I could keep acrobat reader from changing the color space to
 CMYK was to set the entire page containing our graphics to a transparency
 group and then set the colorspace accordingly. See the VB code snippet
 below.

Great! That worked.

Thank you,
Stephan.

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/


Re: [iText-questions] Problem with transparent images

2008-02-21 Thread Leonard Rosenthol
Bruno/Paulo - can you guys please add this as a higher level API call  
(say, on a PdfPage) for the future?


Thanks,
Leonard

On Feb 20, 2008, at 7:45 PM, Eliot M Cline wrote:



 2008/2/20, Leonard Rosenthol [EMAIL PROTECTED]:
 Hmm, doesn't help :-( I tried every blend mode, but this doesn't
 prevent Acrobat from switching to the CMYK color space.


 You need to set the COLORSPACE to DeviceRGB...

 Thanks, but how can I achieve it? I tried

 1.
 ImgTemplate image2 = new ImgTemplate(template);
 PdfArray colorspace = new PdfArray();
 colorspace.add(PdfName.DEVICERGB);
 PdfDictionary ad = new PdfDictionary();
 ad.put(PdfName.COLORSPACE, colorspace);
 image2.setAdditional(ad);

 2.
 PdfDictionary ad = new PdfDictionary();
 ad.put(PdfName.COLORSPACE, PdfName.DEVICERGB);
 image2.setAdditional(ad);

Stephan,

We struggled with this problem for a long time too. Our situation  
was slightly different than yours in that we make heavy use of  
transparency with vector graphics as opposed to transparent images.


The only way I could keep acrobat reader from changing the color  
space to CMYK was to set the entire page containing our graphics to  
a transparency group and then set the colorspace accordingly. See  
the VB code snippet below.


Dim pp As PdfDictionary = New PdfDictionary

pp.Put(PdfName.TYPE, PdfName.GROUP)
pp.Put(PdfName.S, PdfName.TRANSPARENCY)
pp.Put(PdfName.CS, PdfName.DEVICERGB)

doc.Open()

Dim cb As PdfContentByte = writer.DirectContent

Dim tp As PdfTemplate = cb.CreateTemplate(x, y)

'Include the below immediately after a doc.NewPage() or after  
creating a new doc as above


cb.PdfWriter.Group = pp
cb.SetDefaultColorspace(PdfName.CS, PdfName.DEVICERGB)
tp.SetDefaultColorspace(PdfName.CS, PdfName.DEVICERGB) 'Not sure if  
this one is necessary


Anyway, this works for us. Maybe it will be of some help to you as  
well.


Cheers,

Eliot Cline



Sent with DeskNow Lite - Free mail  groupware server http:// 
www.desknow.com
-- 
---

This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ 
___

iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/


Re: [iText-questions] Problem with transparent images

2008-02-20 Thread 1T3XT info
Stephan Michels wrote:
 The Acrobat Reader seems to mix or change colors, which are used in a
 page if I use a image with an alpha channel.
 I tracked down the problem to the method
 Image.getInstance(java.awt.Image, java.awt.Color, boolean). The
 problem occurs if the method sets the ImageMask.
 
 I made following screenshots to show the problem:

I'm not sure what I'm supposed to see.
In one screen there's a thicker border than in the other three
screens. I guess that's your problem, but... I don't know what
you are doing. Have you read the following remark about transparency:
http://www.nabble.com/Re%3A-PDFStamper%3A-Color-of-text-in-PDF-changes-when-replacing-button-with-PNG-Image-p15485315.html

Adobe Reader is probably the only viewer that deals more or
less correctly with transparency. Hardly any other viewer
blends transparent layers correctly. So my first guess would
be that the problem doesn't lie with Adobe Reader or iText,
but with Evince. (And if Evince shows the desired PDF, then
the problem lies probably with your code.)
-- 
This answer is provided by 1T3XT BVBA

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/


Re: [iText-questions] Problem with transparent images

2008-02-20 Thread Stephan Michels
2008/2/20, 1T3XT info [EMAIL PROTECTED]:
 Stephan Michels wrote:
  I made following screenshots to show the problem:

 I'm not sure what I'm supposed to see.
 In one screen there's a thicker border than in the other three
 screens. I guess that's your problem, but... I don't know what
 you are doing.

Yes, the thicker border is an additional problem.

The problem is that you see different colors in the second screenshot
than I have used to generate the PDF. You see the desired output on
the right side within Evince.

 Have you read the following remark about transparency:
 http://www.nabble.com/Re%3A-PDFStamper%3A-Color-of-text-in-PDF-changes-when-replacing-button-with-PNG-Image-p15485315.html

Good point, that the Acrobat Reader changes the colors to the CMYK
color space was one of my assumptions.

Hmm, so what can I do? How I can prevent that the Acrobat Reader
change to the CMYK color space?

Stephan Michels.

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/


Re: [iText-questions] Problem with transparent images

2008-02-20 Thread Leonard Rosenthol
On Feb 20, 2008, at 3:26 AM, Stephan Michels wrote:
 Good point, that the Acrobat Reader changes the colors to the CMYK
 color space was one of my assumptions.

 Hmm, so what can I do? How I can prevent that the Acrobat Reader
 change to the CMYK color space?


Tell the PDF consumer what colorspace to use by explicitly setting  
the transparency blending space!

Leonard


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/


Re: [iText-questions] Problem with transparent images

2008-02-20 Thread Stephan Michels
2008/2/20, Leonard Rosenthol [EMAIL PROTECTED]:
 On Feb 20, 2008, at 3:26 AM, Stephan Michels wrote:
  Good point, that the Acrobat Reader changes the colors to the CMYK
  color space was one of my assumptions.
 
  Hmm, so what can I do? How I can prevent that the Acrobat Reader
  change to the CMYK color space?

 Tell the PDF consumer what colorspace to use by explicitly setting
 the transparency blending space!

And how can I set the default transparency blending space with itext?
Or doesn't exist such option in PDF? Can I change this in Acrobat?

Can I use the method PdfWriter.setDefaultColorspace() for that?

Thanks,
Stephan.

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/


Re: [iText-questions] Problem with transparent images

2008-02-20 Thread Leonard Rosenthol
On Feb 20, 2008, at 7:59 AM, Stephan Michels wrote:

 2008/2/20, Leonard Rosenthol [EMAIL PROTECTED]:
 Tell the PDF consumer what colorspace to use by explicitly setting
 the transparency blending space!

 And how can I set the default transparency blending space with itext?

There is an API somewhere - but I'll let Bruno answer with the  
specifics...


 Or doesn't exist such option in PDF?

Of course it does - that's the whole point!  You didn't specify  
anything in your PDF, so the PDF consumer gets to choose.


 Can I change this in Acrobat?


Nope - Acrobat is just following the rules in the PDF Reference.



Leonard


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/


Re: [iText-questions] Problem with transparent images

2008-02-20 Thread 1T3XT info
Stephan Michels wrote:
 And how can I set the default transparency blending space with itext?

This is explained in chapter 12 of iText in Action.

Some pseudocode (so that you can Google for the keywords):

PdfGState gs = new PdfGState();
gs.setBlendMode(choose state);
cb.setState(gs);

With cb a PdfContentByte instance (for instance a PdfTemplate).
-- 
This answer is provided by 1T3XT BVBA

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/


Re: [iText-questions] Problem with transparent images

2008-02-20 Thread Leonard Rosenthol
On Feb 20, 2008, at 9:28 AM, Stephan Michels wrote:

 2008/2/20, 1T3XT info [EMAIL PROTECTED]:
 Stephan Michels wrote:
 And how can I set the default transparency blending space with  
 itext?

 Some pseudocode (so that you can Google for the keywords):

 PdfGState gs = new PdfGState();
 gs.setBlendMode(choose state);
 cb.setState(gs);

 Hmm, doesn't help :-( I tried every blend mode, but this doesn't
 prevent Acrobat from switching to the CMYK color space.


You need to set the COLORSPACE to DeviceRGB...

Leonard


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/


Re: [iText-questions] Problem with transparent images

2008-02-20 Thread Stephan Michels
2008/2/20, 1T3XT info [EMAIL PROTECTED]:
 Stephan Michels wrote:
  And how can I set the default transparency blending space with itext?

 Some pseudocode (so that you can Google for the keywords):

 PdfGState gs = new PdfGState();
 gs.setBlendMode(choose state);
 cb.setState(gs);

Hmm, doesn't help :-( I tried every blend mode, but this doesn't
prevent Acrobat from switching to the CMYK color space.

I made a little test class to reproduce the problem:
http://www.filespace.net/?d=A867FB691

And also a screenshot to compare the results:
http://www.filespace.net/?d=2D877E011

I understand why the border is thinner in the alpha version and the
black background of the non-alpha version.

What I don't understand is why Acrobat change the text and the border color.

Stephan.

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/


Re: [iText-questions] Problem with transparent images

2008-02-20 Thread Stephan Michels
2008/2/20, Leonard Rosenthol [EMAIL PROTECTED]:
  Hmm, doesn't help :-( I tried every blend mode, but this doesn't
  prevent Acrobat from switching to the CMYK color space.
 

 You need to set the COLORSPACE to DeviceRGB...

Thanks, but how can I achieve it? I tried

1.
ImgTemplate image2 = new ImgTemplate(template);
PdfArray colorspace = new PdfArray();
colorspace.add(PdfName.DEVICERGB);
PdfDictionary ad = new PdfDictionary();
ad.put(PdfName.COLORSPACE, colorspace);
image2.setAdditional(ad);

2.
PdfDictionary ad = new PdfDictionary();
ad.put(PdfName.COLORSPACE, PdfName.DEVICERGB);
image2.setAdditional(ad);

Without luck.

Stephan.

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/


Re: [iText-questions] Problem with transparent images

2008-02-20 Thread Leonard Rosenthol
You need to put the colorspace into the blending space that you were  
workign with before...

Look at the PDF Reference for details on page blending spaces...

Leonard

On Feb 20, 2008, at 10:32 AM, Stephan Michels wrote:

 2008/2/20, Leonard Rosenthol [EMAIL PROTECTED]:
 Hmm, doesn't help :-( I tried every blend mode, but this doesn't
 prevent Acrobat from switching to the CMYK color space.


 You need to set the COLORSPACE to DeviceRGB...

 Thanks, but how can I achieve it? I tried

 1.
 ImgTemplate image2 = new ImgTemplate(template);
 PdfArray colorspace = new PdfArray();
 colorspace.add(PdfName.DEVICERGB);
 PdfDictionary ad = new PdfDictionary();
 ad.put(PdfName.COLORSPACE, colorspace);
 image2.setAdditional(ad);

 2.
 PdfDictionary ad = new PdfDictionary();
 ad.put(PdfName.COLORSPACE, PdfName.DEVICERGB);
 image2.setAdditional(ad);

 Without luck.

 Stephan.

 -- 
 ---
 This SF.net email is sponsored by: Microsoft
 Defy all challenges. Microsoft(R) Visual Studio 2008.
 http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
 ___
 iText-questions mailing list
 iText-questions@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/itext-questions
 Buy the iText book: http://itext.ugent.be/itext-in-action/



-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/


Re: [iText-questions] Problem with transparent images

2008-02-20 Thread Eliot M Cline

 2008/2/20, Leonard Rosenthol [EMAIL PROTECTED]:
 Hmm, doesn't help :-( I tried every blend mode, but this doesn't
 prevent Acrobat from switching to the CMYK color space.


 You need to set the COLORSPACE to DeviceRGB...

 Thanks, but how can I achieve it? I tried

 1.
 ImgTemplate image2 = new ImgTemplate(template);
 PdfArray colorspace = new PdfArray();
 colorspace.add(PdfName.DEVICERGB);
 PdfDictionary ad = new PdfDictionary();
 ad.put(PdfName.COLORSPACE, colorspace);
 image2.setAdditional(ad);

 2.
 PdfDictionary ad = new PdfDictionary();
 ad.put(PdfName.COLORSPACE, PdfName.DEVICERGB);
 image2.setAdditional(ad);

Stephan,


We struggled with this problem for a long time too. Our situation was
slightly different than yours in that we make heavy use of transparency
with vector graphics as opposed to transparent images.

The only way I could keep acrobat reader from changing the color space to CMYK 
was to set the entire page containing our graphics to a transparency group and 
then set the colorspace accordingly. See the VB code snippet below.

Dim pp As PdfDictionary = New PdfDictionary


pp.Put(PdfName.TYPE, PdfName.GROUP)

pp.Put(PdfName.S, PdfName.TRANSPARENCY)

pp.Put(PdfName.CS, PdfName.DEVICERGB)

doc.Open()

Dim cb As PdfContentByte = writer.DirectContent

Dim tp As PdfTemplate = cb.CreateTemplate(x, y)

'Include the below immediately after a doc.NewPage() or after creating 
a new doc as above

cb.PdfWriter.Group = pp
cb.SetDefaultColorspace(PdfName.CS, PdfName.DEVICERGB)
tp.SetDefaultColorspace(PdfName.CS, PdfName.DEVICERGB) 'Not sure if 
this one is necessary

Anyway, this works for us. Maybe it will be of some help to you as well.

Cheers,

Eliot Cline-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/


[iText-questions] Problem with transparent images

2008-02-19 Thread Stephan Michels
Hi,
I have a problem with the Adobe Acrobat Reader and PDFs generated by iText.

The Acrobat Reader seems to mix or change colors, which are used in a
page if I use a image with an alpha channel.
I tracked down the problem to the method
Image.getInstance(java.awt.Image, java.awt.Color,   boolean). The
problem occurs if the method sets the ImageMask.

I made following screenshots to show the problem:

Comparison with a non-transparent image (Evince left, Adobe Acrobat
8.1.1 right):
http://www.filespace.net/?d=771E9FB31

Comparison with a transparent image (Evince left, Adobe Acrobat 8.1.1 right):
http://www.filespace.net/?d=669C21161

I don't know if it is a problem of the Acrobat Reader or iText. The
problem doesn't happen in Evince.

Does anyone see this problem before?

Thank you,
Stephan Michels.

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/