HTML to PDF / DOCX / RTF Java converter library › Forums › PD4ML v3 Archived Forums (Read Only) › Troubleshooting › BufferedImage via ImageIO not schow in firefox preview
- This topic has 6 replies, 4 voices, and was last updated Feb 13, 2015
08:54:25 by Anonymous.
-
AuthorPosts
-
November 15, 2013 at 10:59#26886
Hi there,
I have some complex problem here with pd4ml 385fx2.
I am using pd4ml by the taglib approach rendering a pdf file.
The file contains a img tag which is refering to a Servlet which returns an BufferedImage (a barcode generated on the fly).
Without this call the pdf renders perfectly – with the call the pdf won’t be shown by the internal pdf viewer of firefox version 25. If I ‘download’ the pdf an open it via Acrobat Reader the pdf is shown perfectly.
So, only the BufferedImage prevents the pdf from beeing displayed by firefox’s internal pdf viewer.
Here is the code returned on the JSP of the called Servlet:
<br /> response.setContentType("image/png");<br /> BufferedImage image = getMyBufferedImage();<br /> OutputStream os = response.getOutputStream();<br /> ImageIO.write(image, "png", os);<br /> os.close();<br />
I think the ImageIO.write statement has some downfalls with pd4ml.
Any quick help?
Thanks
November 15, 2013 at 11:12#29425Could you please publish such PDF sample?
November 15, 2013 at 11:40#29426@PD4ML wrote:
Could you please publish such PDF sample?
The file is too big to attach it to this thread. Here is the link instead: http://bit.ly/I35Vio
November 15, 2013 at 14:57#29427Hmm… The PDF seems to be not corrupted and there is no leading-trailing garbage. I tested it with Firefox 25 (on Mac) – no problems.
Are there any exceptions or error messages originated by PD4ML in server’s log?
I would also recommend to inspect HTTP header returned with the PDF for cases without and with PNG.
November 15, 2013 at 15:39#29428That is strange because on all our systems (firefox 25 on mac and win7) the pdf returned by the above link opens the internal firefox pdf viewer but after loading the pdf (white bar on top of the viewer) the pdf is not shown. only the direct download – out of the viewer – shows the correct pdf.
Did you just download the pdf or did it also opened fully in the internal ff pdf viewer on you system?
Response header with embedded png:
<br /> HTTP/1.1 200 OK<br /> Date: Fri, 15 Nov 2013 15:17:54 GMT<br /> Server: Apache/2.0.59 (Win32) mod_ssl/2.0.59 OpenSSL/0.9.7l<br /> Content-Length: 2209665<br /> Expires: Thu, 01 Dec 1994 16:00:00 GMT<br /> Content-Disposition: inline; filename=antrag_partnercard.pdf<br /> Accept-Ranges: bytes<br /> Keep-Alive: timeout=15, max=100<br /> Connection: Keep-Alive<br /> Content-Type: application/pdf<br />
Response header without embedded png:
<br /> HTTP/1.1 200 OK<br /> Date: Fri, 15 Nov 2013 15:28:41 GMT<br /> Server: Apache/2.0.59 (Win32) mod_ssl/2.0.59 OpenSSL/0.9.7l<br /> Content-Length: 2207685<br /> Expires: Thu, 01 Dec 1994 16:00:00 GMT<br /> Content-Disposition: inline; filename=antrag_partnercard.pdf<br /> Accept-Ranges: bytes<br /> Keep-Alive: timeout=15, max=100<br /> Connection: Keep-Alive<br /> Content-Type: application/pdf<br />
Sometimes I get the array index out of bounds exceptions stated in the attached file – but not always…
Btw: is it possible to tell pd4ml to set the content-disposition to “attachment”? like this we could work around the pdf viewer and the browser would open the pdf directly, wouldn’t it?
February 13, 2015 at 02:36#29429@jungbunzlav wrote:
Hi there,
I have some complex problem here with pd4ml 385fx2.
I am using pd4ml by the taglib approach rendering a pdf file.
The file contains a img tag which is refering to a Servlet which returns an BufferedImage (a barcode generated on the fly).
Without this call the pdf renders perfectly – with the call the pdf won’t be shown by the internal pdf viewer of firefox version 25. If I ‘download’ the pdf an open it via Acrobat Reader the pdf is shown perfectly.
So, only the BufferedImage prevents the pdf from beeing displayed by firefox’s internal pdf viewer.
Here is the code returned on the JSP of the called Servlet:
<br /> response.setContentType("image/png");<br /> BufferedImage image = getMyBufferedImage();<br /> OutputStream os = response.getOutputStream();<br /> ImageIO.write(image, "png", os);<br /> os.close();<br />
I think the ImageIO.write statement has some downfalls with pd4ml.
Any quick help?
Thanks
I have also experienced similar problems. The PDF and swf files with bar code images did not display on firefox, but it works correctly on safari. I really don’t know why?
February 13, 2015 at 08:54#29430In the servlet code I would try also to return a content lengths in HTTP header.
For that, you would probably need to print image to a ByteArrayOutputStream, measure resulting byte array length, set headers and only after that send it to HTTP output stream.
-
AuthorPosts
The forum ‘Troubleshooting’ is closed to new topics and replies.