Question
Endeavour Energy
AU
Last activity: 11 Jul 2017 1:24 EDT
Embedding Images in pdf using pd4ml
We have a specific requirement to have separate header and footer in document for first Page and rest of the document
So we have used pd4ml inline tags to achieve the same
<pd4ml:page.header pagesToSkip='0' areaHeight='180' scope='1'>
<pega:include name = "DocumentHeaderLogo.Mail" type="Rule-Obj-Corr" />
</pd4ml:page.header>
<pd4ml:page.footer pagesToSkip='0' areaHeight='150' scope='1'>
<pega:include name = "FooterTemplate.Mail" type="Rule-Obj-Corr" />
<p align="center">Page $[page] </p>
</pd4ml:page.footer>
<html>
<head>
<h1>Title</h1>
</head>
<body>
<BR>
<pd4ml:page.header pagesToSkip='1' areaHeight='-1'>
</pd4ml:page.header>
<pd4ml:page.footer pagesToSkip='1' areaHeight='-1'>
<p align="center">Page $[page] </p>
<BR></pd4ml:page.footer>
ReplaceContent
</body>
</html>
While generating the document we are facing one problem
Images are not getting embedded in generated document if we pass relative path as below
<img src="images/logo.gif">
But if we use below Tag it is embedding the image
<img src="data:image/gif;base64,R0lGODlhkwAYAPcAAA.....DCkFAADs=">
We have a specific requirement to have separate header and footer in document for first Page and rest of the document
So we have used pd4ml inline tags to achieve the same
<pd4ml:page.header pagesToSkip='0' areaHeight='180' scope='1'>
<pega:include name = "DocumentHeaderLogo.Mail" type="Rule-Obj-Corr" />
</pd4ml:page.header>
<pd4ml:page.footer pagesToSkip='0' areaHeight='150' scope='1'>
<pega:include name = "FooterTemplate.Mail" type="Rule-Obj-Corr" />
<p align="center">Page $[page] </p>
</pd4ml:page.footer>
<html>
<head>
<h1>Title</h1>
</head>
<body>
<BR>
<pd4ml:page.header pagesToSkip='1' areaHeight='-1'>
</pd4ml:page.header>
<pd4ml:page.footer pagesToSkip='1' areaHeight='-1'>
<p align="center">Page $[page] </p>
<BR></pd4ml:page.footer>
ReplaceContent
</body>
</html>
While generating the document we are facing one problem
Images are not getting embedded in generated document if we pass relative path as below
<img src="images/logo.gif">
But if we use below Tag it is embedding the image
<img src="data:image/gif;base64,R0lGODlhkwAYAPcAAA.....DCkFAADs=">
Java code to render the document is as below(we are not using pega wrapper class to invoke pd4ml library in this scenario as we need to set sepcific margin for the document)
try{
String sContent=sHtml;
org.zefer.pd4ml.PD4ML pd4ml = new org.zefer.pd4ml.PD4ML();
pd4ml.enableDebugInfo();
pd4ml.setPageInsetsMM(new java.awt.Insets(24, 24, 12, 24));
java.io.ByteArrayOutputStream os=new java.io.ByteArrayOutputStream();
java.io.InputStream is=new java.io.ByteArrayInputStream(sContent.getBytes());
java.io.InputStreamReader ris=new java.io.InputStreamReader(is);
pd4ml.render(ris,os);
byte[] byteArray=os.toByteArray();
tools.putParamValue("PDFDocument",byteArray);
}catch(Exception e){
throw new PRRuntimeException(e.toString());
}
I have attached the html and generated pdf when we are using relative path(Decision pdf and generatedstream.txt) as compared to hardcoded image base64 content(test pdf and hardcodedcontenthtml)
Is there a way to resolve the issue and embedded image using relative path instead of hardocding base64 content
***Updated by Moderator: Marissa. Removed user added Ask the Expert group tag. Apologies for confusion, shouldn't have been an end-user option; updated categories***