Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Sat Jul 30, 2022 4:18 am

I want to convert pdf to html content. First I use byte array to generate pdf. Then use function saveToStream to get html content

Code: Select all
PdfDocument pdf = new PdfDocument();
pdf.loadFromBytes(byteArrayOutput);
htmlContent = Arrays.stream(pdf.saveToStream(FileFormat.HTML)).findFirst().toString();


I got HTML content in the local. But When I deployed to gitlab, it threw Exception:

Code: Select all
java.lang.IllegalStateException: Cannot found font installed on the system.
        at com.spire.pdf.packages.sprmel.spr┑┽(Unknown Source)
        at com.spire.pdf.packages.sprvil.spr۩┼(Unknown Source)
        at com.spire.pdf.packages.sprvil.spr⑇┼(Unknown Source)
        at com.spire.pdf.packages.sprvil.spr℃┼(Unknown Source)
        at com.spire.pdf.packages.sprgko.spr┑╸(Unknown Source)
        at com.spire.pdf.packages.sprrun.spr▆∭(Unknown Source)
        at com.spire.pdf.packages.sprgyn.spr┺╸(Unknown Source)
        at com.spire.pdf.packages.sprgzn.spr┨╸(Unknown Source)
        at com.spire.pdf.PdfDocumentBase.spr┏∮(Unknown Source)
        at com.spire.pdf.PdfDocument.spr◍╽(Unknown Source)
        at com.spire.pdf.PdfDocument.saveToStream(Unknown Source)

My questions are: What can I resolved this issue(Cannot found font installed on the system). Or Is there any other way to convert pdf byte array to html content?

jkl_0610
 
Posts: 4
Joined: Sat Jul 30, 2022 4:03 am

Mon Aug 01, 2022 3:15 am

Hello,

Thanks for your inquiry.

In the process of converting PDF to HTML, Spire.Pdf needs to use the fonts installed in the system. Please check the fonts used in your PDF and install them in your test environment. You can also directly install all the fonts which are installed in your local system to the test system.
Besides, if you don't want to install these fonts on your system, you can use the following code to specify the path where the font files are located for Spire.Pdf. That is to say, you can just copy the font files to a folder in the system without installing them. Hope it can help you.
Code: Select all
PdfDocument.setCustomFontsFolders("/root/myfonts/");
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Return to Spire.PDF

cron