You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Lea Thurman <le...@onesoon.co.uk> on 2008/08/05 12:02:43 UTC

Can FOP render my PNG's with transparent backgrounds

Hi all,

I am using FOP 0.95beta and I am successfully creating a PDF from an SVG
document which has a number of image elements which reference .png files.

The .png files do not have a transparent background - but I was wondering
whether there was an SVG (or FOP) setting that could enable this.

I know it's a long shot and I suspect I need to add this using ImageIO (not
sure how though) but I thought I would ask before I go down this route.

Thanks
Lea.
-- 
View this message in context: http://www.nabble.com/Can-FOP-render-my-PNG%27s-with-transparent-backgrounds-tp18828067p18828067.html
Sent from the FOP - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: Can FOP use a Rendered/BufferedImage rather than a JPEG or GIF? (was: Can FOP render my PNG's with transparent backgrounds)

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
Please don't hijack threads, or at least change the subject. Thanks!

To your question: I assume, by "Java image", you mean a BufferedImage or
a RenderedImage? At the moment, this is not implemented, although the
new image loading framework is prepared to support it. The easiest way
is to use ImageIO to save the bitmap to a PNG and to pass it to FOP
either through a servlet or a custom URIResolver.

On 05.08.2008 23:35:02 BVN wrote:
> 
> Can you add java image? or do we have to use ImageIO to save that java image
> as jpeg/gif and attach that? Please let me know.
> 
> -bvn
<snip/> 



Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: Can FOP render my PNG's with transparent backgrounds

Posted by BVN <ba...@us.ing.com>.
Can you add java image? or do we have to use ImageIO to save that java image
as jpeg/gif and attach that? Please let me know.

-bvn



Jeremias Maerki-2 wrote:
> 
> On 05.08.2008 12:48:53 Lea Thurman wrote:
>> 
>> Hi,
>> 
>> I made some progress with this and have amended my source to render all
>> .png's will an alpha channel and in turn set this to transparent. I am
>> able
>> to open the .png via 3rd party utils and they look perfect however now
>> FOP
>> is throwing an exception when I attempt to render them to PDF.
>> 
>> I have included the error below, but it is an EOFException which is
>> curious
>> since all other apps think its is valid. 
> 
> The exception happens when you use PNG files that are smaller than 88
> bytes. It's a bug I've fixed already. Please upgrade to XML Graphics
> Commons 1.3.1. See
> http://xmlgraphics.apache.org/commons/changes.html#version_1.3.1
> Or you can just upgrade to FOP 0.95 final which should be available from
> the download mirrors within the next few hours.
> 
>> Does FOP support the linking of images with transparent background?
> 
> I don't understand the question. If "linking" means "embed", then yes.
> 
>> Many Thanks
>> Lea
>> 
>> 
>> java.io.EOFException
>> 	at
>> javax.imageio.stream.ImageInputStreamImpl.readFully(ImageInputStreamImpl.java:330)
>> 	at
>> javax.imageio.stream.ImageInputStreamImpl.readFully(ImageInputStreamImpl.java:338)
>> 	at
>> org.apache.xmlgraphics.image.loader.impl.AbstractImagePreloader.getHeader(AbstractImagePreloader.java:45)
>> 	at
>> org.apache.xmlgraphics.image.loader.impl.PreloaderEMF.preloadImage(PreloaderEMF.java:65)
> <snip/>
>> 
>> Lea Thurman wrote:
>> > 
>> > Hi all,
>> > 
>> > I am using FOP 0.95beta and I am successfully creating a PDF from an
>> SVG
>> > document which has a number of image elements which reference .png
>> files.
>> > 
>> > The .png files do not have a transparent background - but I was
>> wondering
>> > whether there was an SVG (or FOP) setting that could enable this.
> 
> Not out of the box. The easiest, as you seem to have done, is rewriting
> the PNGs to become transparent. It would theoretically be possible to
> implement an extension attribute that lets you specify a transparent
> color for an image that FOP would try to use. But I don't think that's a
> good idea.
> 
>> > I know it's a long shot and I suspect I need to add this using ImageIO
>> > (not sure how though) but I thought I would ask before I go down this
>> > route.
>> > 
>> > Thanks
>> > Lea.
>> > 
>> 
>> -- 
>> View this message in context:
>> http://www.nabble.com/Can-FOP-render-my-PNG%27s-with-transparent-backgrounds-tp18828067p18828679.html
>> Sent from the FOP - Users mailing list archive at Nabble.com.
>> 
>> 
> 
> 
> 
> 
> Jeremias Maerki
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Can-FOP-render-my-PNG%27s-with-transparent-backgrounds-tp18828067p18840413.html
Sent from the FOP - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: Can FOP render my PNG's with transparent backgrounds

Posted by Lea Thurman <le...@onesoon.co.uk>.
Just thought i would post a final message to close the thread.

Spot on. My file was 82 bytes. Have now upgraded and all is well.

Once again thank you.


Jeremias Maerki-2 wrote:
> 
> On 05.08.2008 12:48:53 Lea Thurman wrote:
>> 
>> Hi,
>> 
>> I made some progress with this and have amended my source to render all
>> .png's will an alpha channel and in turn set this to transparent. I am
>> able
>> to open the .png via 3rd party utils and they look perfect however now
>> FOP
>> is throwing an exception when I attempt to render them to PDF.
>> 
>> I have included the error below, but it is an EOFException which is
>> curious
>> since all other apps think its is valid. 
> 
> The exception happens when you use PNG files that are smaller than 88
> bytes. It's a bug I've fixed already. Please upgrade to XML Graphics
> Commons 1.3.1. See
> http://xmlgraphics.apache.org/commons/changes.html#version_1.3.1
> Or you can just upgrade to FOP 0.95 final which should be available from
> the download mirrors within the next few hours.
> 
>> Does FOP support the linking of images with transparent background?
> 
> I don't understand the question. If "linking" means "embed", then yes.
> 
>> Many Thanks
>> Lea
>> 
>> 
>> java.io.EOFException
>> 	at
>> javax.imageio.stream.ImageInputStreamImpl.readFully(ImageInputStreamImpl.java:330)
>> 	at
>> javax.imageio.stream.ImageInputStreamImpl.readFully(ImageInputStreamImpl.java:338)
>> 	at
>> org.apache.xmlgraphics.image.loader.impl.AbstractImagePreloader.getHeader(AbstractImagePreloader.java:45)
>> 	at
>> org.apache.xmlgraphics.image.loader.impl.PreloaderEMF.preloadImage(PreloaderEMF.java:65)
> <snip/>
>> 
>> Lea Thurman wrote:
>> > 
>> > Hi all,
>> > 
>> > I am using FOP 0.95beta and I am successfully creating a PDF from an
>> SVG
>> > document which has a number of image elements which reference .png
>> files.
>> > 
>> > The .png files do not have a transparent background - but I was
>> wondering
>> > whether there was an SVG (or FOP) setting that could enable this.
> 
> Not out of the box. The easiest, as you seem to have done, is rewriting
> the PNGs to become transparent. It would theoretically be possible to
> implement an extension attribute that lets you specify a transparent
> color for an image that FOP would try to use. But I don't think that's a
> good idea.
> 
>> > I know it's a long shot and I suspect I need to add this using ImageIO
>> > (not sure how though) but I thought I would ask before I go down this
>> > route.
>> > 
>> > Thanks
>> > Lea.
>> > 
>> 
>> -- 
>> View this message in context:
>> http://www.nabble.com/Can-FOP-render-my-PNG%27s-with-transparent-backgrounds-tp18828067p18828679.html
>> Sent from the FOP - Users mailing list archive at Nabble.com.
>> 
>> 
> 
> 
> 
> 
> Jeremias Maerki
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Can-FOP-render-my-PNG%27s-with-transparent-backgrounds-tp18828067p18830932.html
Sent from the FOP - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: Can FOP render my PNG's with transparent backgrounds

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
On 05.08.2008 12:48:53 Lea Thurman wrote:
> 
> Hi,
> 
> I made some progress with this and have amended my source to render all
> .png's will an alpha channel and in turn set this to transparent. I am able
> to open the .png via 3rd party utils and they look perfect however now FOP
> is throwing an exception when I attempt to render them to PDF.
> 
> I have included the error below, but it is an EOFException which is curious
> since all other apps think its is valid. 

The exception happens when you use PNG files that are smaller than 88
bytes. It's a bug I've fixed already. Please upgrade to XML Graphics
Commons 1.3.1. See
http://xmlgraphics.apache.org/commons/changes.html#version_1.3.1
Or you can just upgrade to FOP 0.95 final which should be available from
the download mirrors within the next few hours.

> Does FOP support the linking of images with transparent background?

I don't understand the question. If "linking" means "embed", then yes.

> Many Thanks
> Lea
> 
> 
> java.io.EOFException
> 	at
> javax.imageio.stream.ImageInputStreamImpl.readFully(ImageInputStreamImpl.java:330)
> 	at
> javax.imageio.stream.ImageInputStreamImpl.readFully(ImageInputStreamImpl.java:338)
> 	at
> org.apache.xmlgraphics.image.loader.impl.AbstractImagePreloader.getHeader(AbstractImagePreloader.java:45)
> 	at
> org.apache.xmlgraphics.image.loader.impl.PreloaderEMF.preloadImage(PreloaderEMF.java:65)
<snip/>
> 
> Lea Thurman wrote:
> > 
> > Hi all,
> > 
> > I am using FOP 0.95beta and I am successfully creating a PDF from an SVG
> > document which has a number of image elements which reference .png files.
> > 
> > The .png files do not have a transparent background - but I was wondering
> > whether there was an SVG (or FOP) setting that could enable this.

Not out of the box. The easiest, as you seem to have done, is rewriting
the PNGs to become transparent. It would theoretically be possible to
implement an extension attribute that lets you specify a transparent
color for an image that FOP would try to use. But I don't think that's a
good idea.

> > I know it's a long shot and I suspect I need to add this using ImageIO
> > (not sure how though) but I thought I would ask before I go down this
> > route.
> > 
> > Thanks
> > Lea.
> > 
> 
> -- 
> View this message in context: http://www.nabble.com/Can-FOP-render-my-PNG%27s-with-transparent-backgrounds-tp18828067p18828679.html
> Sent from the FOP - Users mailing list archive at Nabble.com.
> 
> 




Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: Can FOP render my PNG's with transparent backgrounds

Posted by Lea Thurman <le...@onesoon.co.uk>.
Hi,

I made some progress with this and have amended my source to render all
.png's will an alpha channel and in turn set this to transparent. I am able
to open the .png via 3rd party utils and they look perfect however now FOP
is throwing an exception when I attempt to render them to PDF.

I have included the error below, but it is an EOFException which is curious
since all other apps think its is valid. 

Does FOP support the linking of images with transparent background?

Many Thanks
Lea


java.io.EOFException
	at
javax.imageio.stream.ImageInputStreamImpl.readFully(ImageInputStreamImpl.java:330)
	at
javax.imageio.stream.ImageInputStreamImpl.readFully(ImageInputStreamImpl.java:338)
	at
org.apache.xmlgraphics.image.loader.impl.AbstractImagePreloader.getHeader(AbstractImagePreloader.java:45)
	at
org.apache.xmlgraphics.image.loader.impl.PreloaderEMF.preloadImage(PreloaderEMF.java:65)
	at
org.apache.xmlgraphics.image.loader.ImageManager.preloadImage(ImageManager.java:165)
	at
org.apache.xmlgraphics.image.loader.cache.ImageCache.needImageInfo(ImageCache.java:96)
	at
org.apache.xmlgraphics.image.loader.ImageManager.getImageInfo(ImageManager.java:112)
	at
org.apache.fop.svg.PDFImageElementBridge.createImageGraphicsNode(PDFImageElementBridge.java:79)
	at
org.apache.batik.bridge.SVGImageElementBridge.buildImageGraphicsNode(Unknown
Source)
	at org.apache.batik.bridge.SVGImageElementBridge.createGraphicsNode(Unknown
Source)
	at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(Unknown Source)
	at org.apache.batik.bridge.GVTBuilder.buildComposite(Unknown Source)
	at org.apache.batik.bridge.GVTBuilder.build(Unknown Source)
	at
org.apache.fop.render.pdf.PDFSVGHandler.renderSVGDocument(PDFSVGHandler.java:188)
	at
org.apache.fop.render.AbstractGenericSVGHandler.handleXML(AbstractGenericSVGHandler.java:57)
	at
org.apache.fop.render.AbstractRenderer.renderXML(AbstractRenderer.java:799)
	at
org.apache.fop.render.PrintRenderer.renderDocument(PrintRenderer.java:169)
	at
org.apache.fop.render.pdf.PDFImageHandlerXML.generateImage(PDFImageHandlerXML.java:55)
	at org.apache.fop.render.pdf.PDFRenderer.putImage(PDFRenderer.java:1745)
	at org.apache.fop.render.pdf.PDFRenderer.renderImage(PDFRenderer.java:1679)
	at
org.apache.fop.render.AbstractRenderer.renderViewport(AbstractRenderer.java:734)
	at
org.apache.fop.render.AbstractPathOrientedRenderer.renderViewport(AbstractPathOrientedRenderer.java:557)
	at
org.apache.fop.render.AbstractRenderer.renderInlineArea(AbstractRenderer.java:617)
	at
org.apache.fop.render.pdf.PDFRenderer.renderInlineArea(PDFRenderer.java:1345)
	at
org.apache.fop.render.AbstractRenderer.renderLineArea(AbstractRenderer.java:592)
	at
org.apache.fop.render.pdf.PDFRenderer.renderLineArea(PDFRenderer.java:1336)
	at
org.apache.fop.render.AbstractRenderer.renderBlocks(AbstractRenderer.java:529)
	at
org.apache.fop.render.AbstractRenderer.renderBlock(AbstractRenderer.java:564)
	at org.apache.fop.render.pdf.PDFRenderer.renderBlock(PDFRenderer.java:1329)
	at
org.apache.fop.render.AbstractRenderer.renderBlocks(AbstractRenderer.java:519)
	at
org.apache.fop.render.AbstractRenderer.renderFlow(AbstractRenderer.java:424)
	at
org.apache.fop.render.AbstractRenderer.renderMainReference(AbstractRenderer.java:403)
	at
org.apache.fop.render.AbstractRenderer.renderBodyRegion(AbstractRenderer.java:337)
	at
org.apache.fop.render.AbstractRenderer.renderRegionViewport(AbstractRenderer.java:282)
	at
org.apache.fop.render.AbstractRenderer.renderPageAreas(AbstractRenderer.java:255)
	at
org.apache.fop.render.AbstractRenderer.renderPage(AbstractRenderer.java:229)
	at org.apache.fop.render.pdf.PDFRenderer.renderPage(PDFRenderer.java:801)
	at org.apache.fop.area.RenderPagesModel.addPage(RenderPagesModel.java:113)
	at
org.apache.fop.layoutmgr.AbstractPageSequenceLayoutManager.finishPage(AbstractPageSequenceLayoutManager.java:312)
	at
org.apache.fop.layoutmgr.ExternalDocumentLayoutManager.makePageForImage(ExternalDocumentLayoutManager.java:158)
	at
org.apache.fop.layoutmgr.ExternalDocumentLayoutManager.activateLayout(ExternalDocumentLayoutManager.java:111)
	at
org.apache.fop.area.AreaTreeHandler.endExternalDocument(AreaTreeHandler.java:254)
	at
org.apache.fop.fo.extensions.ExternalDocument.endOfNode(ExternalDocument.java:94)
	at
org.apache.fop.fo.FOTreeBuilder$MainFOHandler.endElement(FOTreeBuilder.java:340)
	at org.apache.fop.fo.FOTreeBuilder.endElement(FOTreeBuilder.java:169)
	at
org.apache.xalan.transformer.TransformerIdentityImpl.endElement(TransformerIdentityImpl.java:1101)


Lea Thurman wrote:
> 
> Hi all,
> 
> I am using FOP 0.95beta and I am successfully creating a PDF from an SVG
> document which has a number of image elements which reference .png files.
> 
> The .png files do not have a transparent background - but I was wondering
> whether there was an SVG (or FOP) setting that could enable this.
> 
> I know it's a long shot and I suspect I need to add this using ImageIO
> (not sure how though) but I thought I would ask before I go down this
> route.
> 
> Thanks
> Lea.
> 

-- 
View this message in context: http://www.nabble.com/Can-FOP-render-my-PNG%27s-with-transparent-backgrounds-tp18828067p18828679.html
Sent from the FOP - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org