Question

2
Replies
2974
Views
Mahesh Sawant (Mahesh_Sawant)
Capgemini
LSA
Capgemini
AU
Mahesh_Sawant Member since 2013 12 posts
Capgemini
Posted: February 3, 2017
Last activity: February 6, 2017
Posted: 3 Feb 2017 7:45 EST
Last activity: 6 Feb 2017 4:20 EST
Closed

PDF Generation from PD4ML

We are generating PDF documents from the correspondence templates, for generating it we are using PD4ML library instead of Pega OOTB HTMLtoPDF to achieve the customer requirements. Basically we are mentioning "10pt" as font size in the correspondence template but the generated PDF is showing as "11pt" or "10.5pt" font size.


PD4ML Code snapshot



try{


String sContent=sHtml;


org.zefer.pd4ml.PD4ML pd4ml = new org.zefer.pd4ml.PD4ML();


//pd4ml.resetAddedStyles();

pd4ml.setPageInsetsMM(new java.awt.Insets(10, 21, 0, 16));

pd4ml.enableImgSplit(false);

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.setCookie("JSESSIONID",JSESSIONID);

pd4ml.setCookie("Pega-RULES",PEGARULES);

pd4ml.useTTF(FontsProp,false);

java.net.URL base=new java.net.URL(BASEURL);

pd4ml.enableDebugInfo() ;

pd4ml.render(ris,os,base);


byte[] byteArray=os.toByteArray();


// Action == Preview

if (Action.equalsIgnoreCase("Preview")){

String sPDF=Base64Util.encodeToString(byteArray);

ClipboardPage workpage = tools.findPage("pyWorkPage");

workpage.putString("PDFDocument",sPDF);

}


else {

tools.putParamValue("PDFDocument",byteArray);

}

Show More

We are generating PDF documents from the correspondence templates, for generating it we are using PD4ML library instead of Pega OOTB HTMLtoPDF to achieve the customer requirements. Basically we are mentioning "10pt" as font size in the correspondence template but the generated PDF is showing as "11pt" or "10.5pt" font size.

PD4ML Code snapshot

try{

String sContent=sHtml;

org.zefer.pd4ml.PD4ML pd4ml = new org.zefer.pd4ml.PD4ML();

//pd4ml.resetAddedStyles();
pd4ml.setPageInsetsMM(new java.awt.Insets(10, 21, 0, 16));
pd4ml.enableImgSplit(false);
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.setCookie("JSESSIONID",JSESSIONID);
pd4ml.setCookie("Pega-RULES",PEGARULES);
pd4ml.useTTF(FontsProp,false);
java.net.URL base=new java.net.URL(BASEURL);
pd4ml.enableDebugInfo() ;
pd4ml.render(ris,os,base);

byte[] byteArray=os.toByteArray();

// Action == Preview
if (Action.equalsIgnoreCase("Preview")){
String sPDF=Base64Util.encodeToString(byteArray);
ClipboardPage workpage = tools.findPage("pyWorkPage");
workpage.putString("PDFDocument",sPDF);
}

else {
tools.putParamValue("PDFDocument",byteArray);
}

}catch(Exception e){

throw new PRRuntimeException(e.toString());
}

***Moderator Edit: Vidyaranjan | Updated Categories, tagged SRExists***

Show Less
Case Management Support Case Exists
Moderation Team has archived post, This thread is closed to future replies. Content and links will no longer be updated. If you have the same/similar Question, please write a new Question.