Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Other Application Frameworks and the fly likes xhtmlrenderer won't display dynamically generated images Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "xhtmlrenderer won Watch "xhtmlrenderer won New topic
Author

xhtmlrenderer won't display dynamically generated images

Drey Marks
Greenhorn

Joined: Dec 02, 2010
Posts: 3
Hi guys.

I've created a Stripes ActionBean to stream dynamically generated images to the response. I'm using this component for a HTML page that I'm going to convert to PDF through xhtmlrenderer. However, when I try to generate the PDF, the images don't show up. On the dynamically created HTML page, they're ok but not on the PDF.

To create the image, I use BufferedImage, and JPEGImageEncoder.

Any idea why xhtmlrenderer ignores them?

Thanks.
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
During the XHTML->PDF step, is the image generator URL being called at all?
Drey Marks
Greenhorn

Joined: Dec 02, 2010
Posts: 3
I'm not sure. Here's how I do the conversion:

1) generate the formatted page to a certain URL
2) use a client internally (Apache HTTPClient) to fetch the document from that URL
3) create a Document object (w3c) from the fetched entity
4) use xhtmlrender to convert the Document object to PDF

It might not be the best way to go about it but that's how I did it. So essentially I format everything through one actionBean and convert it to PDF on another. So, I'm not sure how xhtmlrender go about rendering the images but as I've said, the "static" images get shown properly.
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
What do you mean by "static" images - how does their URL differ from those of the "dynamic" image?

I'd add some logging to your image generation ActionBean - I'll bet it isn't called at all during the PDF generation. You might also do some HTTP monitoring to see at which times requests for which URLs go out, and what the responses are.
Drey Marks
Greenhorn

Joined: Dec 02, 2010
Posts: 3
By "static images" I meant they're already in the deployment as images and that they're not created through code. The URLs for static and dynamically created images don't differ that much. I created the image generator ActionBean so that its URL is like pointing to a "static" image.

As for the generator being called on conversion, I found out--thanks to Lester's suggestion--that it's NOT being called. The thing is: there's an interceptor in the application that limits access to ActionBeans to logged in users and the HTTPClient is not set to be logged in.

I could probably work with a solution from here. Thanks.

EDIT: it probably isn't the HTTPClient that's not set to be logged in exactly but some other internal component/s.
 
 
subject: xhtmlrenderer won't display dynamically generated images
 
Similar Threads
How to bind images and text together in same jsp page in easiest way?
Accessing images from another path in UNIX
Div inner Html to PDF
Providing dynamic content from separate web/app servers
Resetting Values