HTML to PDF / DOCX / RTF Java converter library › Forums › PD4ML v3 Archived Forums (Read Only) › Deployment / Configuration issues › ByteArray loading of PD4ML
- This topic has 1 reply, 2 voices, and was last updated Oct 01, 2015
15:04:15 by PD4ML.
-
AuthorPosts
-
September 23, 2015 at 11:25#27046
Hi, We have the following workflow for generating and storing the PDF
1. create PDF
2. Load ByteArray and store it as BLOB in database.
3. User comes to website and tries to access PDF.
4. PDF sent in response stream.We are facing a weird issue where the file created from PD4ML when opened with Adobe loads the PDF perfectly fine. But if we store the file as byte[] in database and try accessing it from database the PDF loads but none of the images gets displayed in PDF.
Styling is present, only the images are missing.
<br /> ByteArrayOutputStream baos = new ByteArrayOutputStream(4096);<br /> PD4ML pd4ml = new PD4ML();<br /> pd4ml.interpolateImages(true);<br /> pd4ml.enableDebugInfo();<br /> pd4ml.setHtmlWidth(850);<br /> pd4ml.addStyle("BODY {margin: 0}", true);<br /> pd4ml.setPageInsets(new Insets(0, 0, 0, 0));<br /> pd4ml.fitPageVertically();<br /> pd4ml.overrideDocumentEncoding("UTF-8");<br /> <br /> pd4ml.setPermissions("empty", PD4Constants.AllowPrint, true);<br /> pd4ml.setPermissions("empty", PD4Constants.AllowModify, false);<br /> pd4ml.setPermissions("empty", PD4Constants.AllowCopy, true);<br /> <br /> pd4ml.render(new StringReader(htmlCode), baos);<br /> byte[] bytes = baos.toByteArray();<br /> ############<br /> # Store bytes in DB<br /> ############<br /> <br /> <br /> <br /> ############<br /> # Servlet<br /> ############<br /> response.getOutputStream().write(byte[]/* from database.*/);<br /> response.setContentType("application/octet-stream");<br /> response.setHeader("Content-Disposition","attachment;filename=file.pdf");<br />
October 1, 2015 at 15:04#29836Could you please send a corrupted PDF sample to support pd4ml com?
Also:
1. In the section only the last setPermissions() call takes effect:
[language=java:2fhuhcrq]pd4ml.setPermissions(“empty”, PD4Constants.AllowPrint, true);
pd4ml.setPermissions(“empty”, PD4Constants.AllowModify, false);
pd4ml.setPermissions(“empty”, PD4Constants.AllowCopy, true);[/language:2fhuhcrq]Correct API call:
[language=java:2fhuhcrq]pd4ml.setPermissions(“empty”, PD4Constants.AllowPrint |
PD4Constants.AllowModify | PD4Constants.AllowCopy, true);[/language:2fhuhcrq]2. Right MIME type for PDF is
[language=java:2fhuhcrq]response.setContentType(“application/pdf”);[/language:2fhuhcrq]
-
AuthorPosts
The forum ‘Deployment / Configuration issues’ is closed to new topics and replies.