Support Article
PDF name set incorrectly as thread name
Summary
On saving a PDF, the file name is incorrectly set with the thread name instead of the specified file name. This occurs during preview PDF.
Error Messages
Not Applicable
Steps to Reproduce
- Create an activity to generate the PDF.
- In the activity, write a Java step and add the below code.
String LTRFileName = "user_name.pdf";
HashStringMap aMap = new HashStringMap();
aMap.put( "ContentDisposition", "inline; filename="+LTRFileName+";");
tools.sendFile(byteArray, LTRFileName, false,aMap, false);
This code is to preview the PDF in the browser before downloading it.
Root Cause
A third-party product issue: Internet Explorer browser.
Resolution
Here’s the explanation for the reported behavior:
To render the document in the Preview mode, inline header in aMap is used. However, inline header has issues in the Internet Explorer browser.
Use the attachment header to download the document instead of inline header. However, in this case, preview is not possible. Only inline header has the privilage of preview.
aMap.put("ContentDisposition", "attachment;filename=\""+LTRFileName+"\";");
To generate PDF, set the Title tag in an HTML section. The pd4ml adds title to the PDF. The title displays instead of the tab name.
Use the following custom HTML section to generate the PDF:
<%
String section = tools.getParamValue("SectionName");
String strTitle = tools.getParamValue("PDFName");
%>
<HTML>
<HEAD>
<pega:include name="GeneratePDFStyles" type="Rule-Obj-HTML" />
<title><%= strTitle %></title>
</HEAD>
<BODY>
<pega:include name="<%= section %>" type="Rule-HTML-Section" />
</BODY>
</HTML>
Published January 30, 2019 - Updated July 20, 2021
Have a question? Get answers now.
Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.