Skip to main content

This content has been archived and is no longer being updated. Links may not function; however, this content may be relevant to outdated versions of the product.

Support Article

Text Area is not working for PDF

SA-19939

Summary



When a PDF is exported, it ends up with extra blank rows at the bottom. Even if the textarea is set to auto it does not display full text entered in it when exported to a PDF.


Error Messages



Not Applicable


Steps to Reproduce

  1. Design a section with a text area.
  2. For the text area, change the cell properties in the presentation tab to Width = 70 Columns, Height = Size to Content, Height = 43 Rows.
  3. Design a flow with "Generate PDF" shape.
  4. Run the flow.
  5. Enter text in the area and keep the number of rows less than the rows defined in the height in section for example: enter 20 rows.
  6. After generating the PDF, observe it displays the 20 rows but it takes up 43 rows of height. Due to this, after 20 rows the remaining text area is shown as blank.


Root Cause



The underlying library PD4ML (that the Pega Platform uses to convert HTML to PDF) doesn't have dynamic sizing and only supports the number of columns configured for TextArea tag, which is causing this issue.

Resolution



Explicitly replace the TextArea tag with a Paragraph tag in the input HTML stream and also replacing carriage return and / or newline character (/r/n) into </br> (line break) tag. This will wrap the complete text to make it viewable.

For the same, modify the Activity @baseclass.pyAttachAsPDF to have the following custom code :

LocalHTMLStream = tools.getParamValue("Markup");

java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("<textarea[^>].+?(rows=(\".+?\")).+?>(.+?)</textarea>" , java.util.regex.Pattern.DOTALL);

java.util.regex.Matcher matcher = pattern.matcher(LocalHTMLStream); // 'LocalHTMLStream' is a local variable in activity and is initialized to the Stream to be put in pdf

 while(matcher.find()){

String original = matcher.group();

String replacement="";

int b=original.indexOf("</textarea>");

char ch= original.charAt(b-1);

if(!(ch == '>')){

replacement = original.replace("textarea","p");

replacement = replacement.replace("height: auto;","height: auto;color: rgb(81, 88, 94);");

LocalHTMLStream = LocalHTMLStream.replace(original,replacement);

}

}

tools.putParamValue("Markup", LocalHTMLStream);

This will experience some formatting/styling issues because CSS defined for textarea and paragraph tags are different. This should be resolved on case-to-case basis depending on Section/TextArea configuration by using the typical paragraph control generated HTML stream as reference.

 

Published February 22, 2016 - Updated October 8, 2020

Was this useful?

0% found this useful

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega Community has detected you are using a browser which may prevent you from experiencing the site as intended. To improve your experience, please update your browser.

Close Deprecation Notice
Contact us