Support Article
Caught exception while creating PDF from HTML stream
SA-50355
Summary
User configured the Create PDF smart shape in a flow but the PDF does not generate successfully.
The user has the application server on RHEL 7.4 operating system.
Error Messages
The below error appears in the log :-
@baseclass HTMLtoPDF activity, step 4 - "com.pega.pegarules.pub.PRRuntimeException: Caught exception while creating PDF from HTML stream".
Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
at sun.font.CompositeStrike.getStrikeForSlot(CompositeStrike.java:75)
at sun.font.CompositeStrike.getFontMetrics(CompositeStrike.java:93)
at sun.font.FontDesignMetrics.initMatrixAndMetrics(FontDesignMetrics.java:359)
at sun.font.FontDesignMetrics.<init>(FontDesignMetrics.java:350)
at sun.font.FontDesignMetrics.getMetrics(FontDesignMetrics.java:302)
at sun.font.FontDesignMetrics.getMetrics(FontDesignMetrics.java:250)
at sun.awt.SunToolkit.getFontMetrics(SunToolkit.java:649)
at sun.awt.HeadlessToolkit.getFontMetrics(HeadlessToolkit.java:413)
at org.zefer.font.c.super(Unknown Source)
at org.zefer.font.c.<init>(Unknown Source)
at org.zefer.cache.ResourceCache.getFontMetrics(Unknown Source)
at org.zefer.html.doc.q.Ó00000(Unknown Source)
at org.zefer.html.doc.q.Ö00000(Unknown Source)
at org.zefer.html.doc.w.<init>(Unknown Source)
at org.zefer.html.doc.PD4MLHtmlParser.buildDocument(Unknown Source)
at org.zefer.pd4ml.PD4ML.o00000(Unknown Source)
at org.zefer.pd4ml.PD4ML.render(Unknown Source)
at com.pega.pegarules.integration.engine.internal.util.PDFUtilsImpl.invokePD4ML(PDFUtilsImpl.java:1296)
at com.pega.pegarules.integration.engine.internal.util.PDFUtilsImpl.convertHTMLToPDF(PDFUtilsImpl.java:1010)
at com.pega.pegarules.integration.engine.internal.util.PDFUtilsImpl.generatePDF(PDFUtilsImpl.java:215)
Steps to Reproduce
1. Create a Flow.
2. Configure a Create PDF smart shape.
Root Cause
This is an issue with the RHEL OS version 7.4.
In this OS version the the default font has changed from Utopia to STIX.
The Open JDK does not go well with the STIX font and thus the PD4ML library fails during PDF generation.
Resolution
Make the following change to the operating environment:
1. Create a file /etc/fonts/local.conf and include the below entries
<?xml version='1.0'?> <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'> <fontconfig> <alias> <family>serif</family> <prefer><family>Utopia</family></prefer> </alias> <alias> <family>sans-serif</family> <prefer><family>Utopia</family></prefer> </alias> <alias> <family>monospace</family> <prefer><family>Utopia</family></prefer> </alias> <alias> <family>dialog</family> <prefer><family>Utopia</family></prefer> </alias> <alias> <family>dialoginput</family> <prefer><family>Utopia</family></prefer> </alias> </fontconfig> |
2. Save the file and restart the server and check the PDF generation from Pega.
Published February 21, 2018 - Updated October 8, 2020
Have a question? Get answers now.
Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.