0

We recently upgraded flying-saucer-itext from 9.1.15 to 9.15.22, and the images are no longer rendering. We are using Docusign 3.23 SDK to fetch the signature images and try to render those in our app.

This is some part of the code.

pom.xml is

<dependency>
      <groupId>org.xhtmlrenderer</groupId>
      <artifactId>flying-saucer-pdf-itext5</artifactId>
      <version>9.1.22</version>
      <exclusions>
        <exclusion>
          <groupId>org.bouncycastle</groupId>
          <artifactId>bcprov-jdk14</artifactId>
        </exclusion>
        <exclusion>
          <groupId>com.github.librepdf</groupId>
          <artifactId>openpdf</artifactId>
        </exclusion>
      </exclusions>
</dependency>
<dependency>     
      <groupId>com.github.librepdf</groupId>     
      <artifactId>openpdf</artifactId>     
      <version>1.3.30</version> 
</dependency>
.
.
.
 <docusign.sdk.version>3.23.0</docusign.sdk.version>

The code logic is (truncated for privacy concerns)

import org.stringtemplate.v4.DateRenderer;
import org.stringtemplate.v4.ST;
import org.stringtemplate.v4.STRawGroupDir;
import org.stringtemplate.v4.StringRenderer;
import org.xhtmlrenderer.pdf.ITextRenderer;
.
.
.
signatureImageStringEncoded = Base64.getEncoder().encodeToString(signatureImage);
.
.

and rendering this in a .st (String template ST4) file

 <img src="data:image/gif;base64, signatureImageStringEncoded" alt="Signature" width="200" height="75"/>

I went back to the 9.1.15 package, and it is rendering the image as expected, but our deployment team is pushing to update it to 9.1.22.

I tried referring to this page but no luck.

Update on 7/6/2023. I'm encountering an error in the section of the code that handles creating PDF files.

Error:  
java.lang.RuntimeException: Font 'STSong-Light,BoldItalic' with 'UniGB-UCS2-H' is not recognized.
    at org.xhtmlrenderer.pdf.ITextFontResolver.createInitialFontMap(ITextFontResolver.java:469)
    at org.xhtmlrenderer.pdf.ITextFontResolver.<init>(ITextFontResolver.java:40)
    at org.xhtmlrenderer.pdf.ITextRenderer.<init>(ITextRenderer.java:117)
    at org.xhtmlrenderer.pdf.ITextRenderer.<init>(ITextRenderer.java:102)
    at com.oncor.corp.pete.api.services.pdf.PDFService.createPDFFromTemplate(PDFService.java:49)
Saurabh
  • 336
  • 3
  • 9
  • Security concern of what library exactly? Or security concern in general? – Lonzak May 15 '23 at 06:29
  • I apologize. There was no security concern. Our deployment/app security team is pushing for that update. I have tried multiple things but have had no luck rendering the pdf image. – Saurabh May 16 '23 at 18:01
  • Version 9.1.22 is still using an old version of openPDF. Try to exclude this version and use the latest one. ` com.github.librepdf openpdf ` and then import the latest one ` com.github.librepdf openpdf 1.3.30 ` And then try again... – Lonzak May 17 '23 at 06:30
  • @Lonzak, I updated my pom.xml on my thread based on your suggestion. Does that look correct? – Saurabh May 17 '23 at 15:45
  • Yes it looks correct. To be really sure check you final build for those dependencies: There should be only version 1.3.30 in there but not version 1.3.11. When that's the case then try again... – Lonzak May 22 '23 at 05:47
  • Font 'STSong-Light,BoldItalic' with 'UniGB-UCS2-H' is not recognized. I started receiving this error now. I've added the error trace to my original message @lonzak – Saurabh Jul 07 '23 at 00:05
  • You have to install the missing font. Check out this [post](https://stackoverflow.com/questions/73382606/pdfbox-how-to-solve-font-stsong-light-problem-when-converting-pdf-to-image) – Lonzak Jul 25 '23 at 07:21

0 Answers0