HTML to PDF / DOCX / RTF Java converter library › Forums › PD4ML v3 Archived Forums (Read Only) › Troubleshooting › Convert XML to PDF with SSL resources › Re: Re: Convert XML to PDF with SSL resources
Thank you for your reply.
The code is from our legacy project. It takes XML file from database and transform it, output is a PDF file. There is a link to remote HTTPS xslt file in XML, and that xslt file contains URLs to remote HTTPS image. If it is a local xslt file, the code works just fine. Could you shed some light? Here is the code with comments:
<br />
/**<br />
* Generates a PDF document from an XML file that requires transformation using an<br />
* XSL stylesheet.<br />
*<br />
* @param sourceStream The source XML document stream.<br />
* @param targetStream The target PDF document stream.<br />
* @param headerText Text to display as a page header in the target PDF.<br />
* @param forcePrint Whether or not to force the print dialog to appear when the PDF is loaded.<br />
*<br />
* @throws Exception If something goes wrong while transforming the XML or generating the PDF.<br />
*/<br />
public void generatePdf(InputStream sourceStream, OutputStream targetStream, String headerText, boolean forcePrint) throws Exception {<br />
PD4ML converter = new PD4ML();<br />
if (headerText != null) {<br />
PD4PageMark header = new PD4PageMark();<br />
Font font = header.getFont();<br />
Font boldFont = font.deriveFont(Font.BOLD);<br />
header.setFont(boldFont);<br />
header.setTitleTemplate(headerText);<br />
converter.setPageHeader(header);<br />
}<br />
PD4PageMark footer = new PD4PageMark();<br />
footer.setPageNumberTemplate("Page $[page] of $[total]");<br />
footer.setPageNumberAlignment(PD4PageMark.CENTER_ALIGN);<br />
converter.setPageFooter(footer);<br />
converter.setPageSize(PD4Constants.A4);<br />
converter.setPageInsetsMM(new Insets(10, 10, 10, 10));<br />
converter.setHtmlWidth(820);<br />
if (forcePrint) {<br />
Map<String, String> dynamicParameters = new HashMap<String, String>();<br />
dynamicParameters.put(PD4Constants.PD4ML_PRINT_DIALOG_POPUP, "true");<br />
converter.setDynamicParams(dynamicParameters);<br />
}<br />
converter.render(new InputStreamReader(sourceStream, "UTF-8"), targetStream);<br />
}<br />