HTML to PDF / DOCX / RTF Java converter library Forums PD4ML v3 Archived Forums (Read Only) Troubleshooting BufferedImage via ImageIO not schow in firefox preview

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #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

    #29425

    Could you please publish such PDF sample?

    #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

    #29427

    Hmm… 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.

    #29428

    That 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?

    #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?

    #29430

    In 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.

Viewing 7 posts - 1 through 7 (of 7 total)

The forum ‘Troubleshooting’ is closed to new topics and replies.