Closed oxiadenine closed 2 weeks ago
@oxiadenine Thank you for reporting the problem.
In PR https://github.com/flyingsaucerproject/flyingsaucer/pull/441, I've restored classes FSImageWriter
and ImageRenderer
.
I think you can simplify your code by using ImageRenderer
instead of FSImageWriter
:
BufferedImage image = ImageRenderer.renderToImage(getClass().getResource("/text-with-background-image.xhtml"), resultingImagePath, 600);
Please share your suggestions how we can improve API of ImageRenderer
even more.
@asolntsev I have tested what you done, but it is not working, so I think it has to do with the internal functionality of Java2DRenderer
, FSImageWriter
and ImageRenderer
are irrelevant, because as write before, ImageIO
is working well in realease 9.9.2.
@asolntsev I have tested what you done, but it is not working, so I think it has to do with the internal functionality of
Java2DRenderer
,FSImageWriter
andImageRenderer
are irrelevant, because as write before,ImageIO
is working well in realease 9.9.2.
How exactly did you test it? How can you be sure that you used the latest snapshot version I built today?
Because I tested, and it worked on my machine. :)
@asolntsev I have tested what you done, but it is not working, so I think it has to do with the internal functionality of
Java2DRenderer
,FSImageWriter
andImageRenderer
are irrelevant, because as write before,ImageIO
is working well in realease 9.9.2.How exactly did you test it? How can you be sure that you used the latest snapshot version I built today?
Because I tested, and it worked on my machine. :)
I just copied the changes you done in the two commits linked to this issue and reproduce it in my project, since this changes doesn't modify internal logic of Java2DRenderer
, so I created a XML file with my HTML text and loaded it as you done in your test.
Also, ImageRenderer
doesn't do anything that I'm currently doing, and FSImageWriter
can not be the problem as I mentioned before.
@oxiadenine Sorry, I don't understand. Please do the following:
org.xhtmlrenderer:flying-saucer-core:9.11.0-SNAPSHOT
BufferedImage image = ImageRenderer.renderToImage(getClass().getResource("/text-with-background-image.xhtml"), resultingImagePath, 600);
@oxiadenine Sorry, I don't understand. Please do the following:
1. use the snapshot version `org.xhtmlrenderer:flying-saucer-core:9.11.0-SNAPSHOT` 2. use this code: `BufferedImage image = ImageRenderer.renderToImage(getClass().getResource("/text-with-background-image.xhtml"), resultingImagePath, 600);`
Sorry, but it didn't worked, so I created a repository to show you what I doing.
https://github.com/oxiadenine/flying-saucer-test
I'm using Kotlin.
@oxiadenine Thank you for the working example.
See my fix for this sample: https://github.com/oxiadenine/flying-saucer-test/pull/1
@oxiadenine FlyingSaucer 9.11.0 has been released.
In release 9.10.2,
org.xhtmlrenderer.util.FSImageWriter
was removed, butJava2DRenderer.htmlAsImage()
has been added.The problem:
if I use
ImageIO
to write theBufferedImage
to aFile
orOutputStream
, the CSS property background with an url to a local image with relative path does not render to the final image, and I think the problem is not withImageIO
, but withJava2DRenderer
.9.9.2 (works)
or
9.10.2 (does not work)
or
P.S. CSS background property with url to remote image or
file://
with absolute path is working.