Aspose PDF java : Requested font type subsetting is not supported

Hi team,

I am getting below exception while trying to convert HTML file to PDF

Exception in thread “main” com.aspose.pdf.internal.l19f.l12if: Requested font type subsetting is not supported.
at com.aspose.pdf.internal.l19f.l37y.l0p(Unknown Source)
at com.aspose.pdf.internal.l4k.l1h.l1y(Unknown Source)
at com.aspose.pdf.internal.l4k.l1p.lI(Unknown Source)
at com.aspose.pdf.internal.l4f.lu.lI(Unknown Source)
at com.aspose.pdf.internal.l5if.lI.lI(Unknown Source)
at com.aspose.pdf.ComboBoxField.lf(Unknown Source)
at com.aspose.pdf.WidgetAnnotation.lI(Unknown Source)
at com.aspose.pdf.Field.updateAppearances(Unknown Source)
at com.aspose.pdf.ComboBoxField.lI(Unknown Source)
at com.aspose.pdf.Field.lI(Unknown Source)
at com.aspose.pdf.Annotation.lI(Unknown Source)
at com.aspose.pdf.Annotation.(Unknown Source)
at com.aspose.pdf.WidgetAnnotation.(Unknown Source)
at com.aspose.pdf.Field.(Unknown Source)
at com.aspose.pdf.ChoiceField.(Unknown Source)
at com.aspose.pdf.ComboBoxField.(Unknown Source)
at com.aspose.pdf.internal.l8j.lb.lI(Unknown Source)
at com.aspose.pdf.internal.l8j.lb.beginElement(Unknown Source)
at com.aspose.pdf.internal.l8j.lt.beginElement(Unknown Source)
at com.aspose.pdf.internal.l38v.lI.lI(Unknown Source)
at com.aspose.pdf.internal.l27y.l0j.lI(Unknown Source)
at com.aspose.pdf.internal.l27y.l0if.lI(Unknown Source)
at com.aspose.pdf.internal.l27y.l0j.lI(Unknown Source)
at com.aspose.pdf.internal.l27y.l0if.lI(Unknown Source)
at com.aspose.pdf.internal.l27y.l0j.lI(Unknown Source)
at com.aspose.pdf.internal.l27y.l0if.lI(Unknown Source)
at com.aspose.pdf.internal.l27y.l0j.lI(Unknown Source)
at com.aspose.pdf.internal.l27y.l0if.lI(Unknown Source)
at com.aspose.pdf.internal.l27y.lv.lI(Unknown Source)
at com.aspose.pdf.internal.l27y.l0if.lI(Unknown Source)
at com.aspose.pdf.internal.l27y.l1u.lI(Unknown Source)
at com.aspose.pdf.internal.l38v.lI.lI(Unknown Source)
at com.aspose.pdf.internal.l46p.lI.lI(Unknown Source)
at com.aspose.pdf.internal.l46p.lI.lI(Unknown Source)
at com.aspose.pdf.internal.html.rendering.HtmlRenderer.render(Unknown Source)
at com.aspose.pdf.l6p.lI(Unknown Source)
at com.aspose.pdf.l6p.lI(Unknown Source)
at com.aspose.pdf.ADocument.lI(Unknown Source)
at com.aspose.pdf.ADocument.(Unknown Source)
at com.aspose.pdf.Document.(Unknown Source)
at AsposePDFGenerator.generatePDF(AsposePDFGenerator.java:17)

Below is my code :
HtmlLoadOptions htmloptions = new HtmlLoadOptions(“home/darshanshah/Documents/PDF”);
Document doc = new Document("/home/darshanshah/Documents/PDF/tutPoint/tutPoint_noScript_noXTCSS_noImage.html", htmloptions);
doc.save(“codebeautify.pdf”);

Not able to upload my source HTML file as .html extension is not supported. Please advise how to share it.

I have removed all css related to fonts-type from my HTML still getting this issue.

Can you please help with this. Thanks.

@Darshan_Shah

Thank you for contacting support.

Please upload the file as ZIP archive so that we may try to reproduce and investigate it in our environment. Before sharing requested data, please ensure using Aspose.PDF for Java 19.4.

Thanks for reply. Uploading my source HTML in zip file.tutPoint_noScript_noXTCSS_noImage.zip (63.0 KB)

I am using Aspose PDF for java version 19.2

@Darshan_Shah

Thank you for sharing requested data.

We are investigating the scenario and will get back to you with our findings soon.

@Darshan_Shah

Thank you for being patient.

We have tried to reproduce the problem but OutOfMemoryError occurs instead of the exception you have mentioned. However, we have logged a ticket with ID PDFJAVA-38554 in our issue management system for further investigations and resolution.

Moreover, would you please share your environment details including OS, installed memory, JDK etc. for our reference.

Hello,

We are also facing same issue
com.aspose.pdf.internal.l20if.l12if: Requested font type subsetting is not supported.
at com.aspose.pdf.internal.l20if.l37y.l0p(Unknown Source)
at com.aspose.pdf.internal.l4k.l1h.l1y(Unknown Source)
at com.aspose.pdf.internal.l4k.l1p.lI(Unknown Source)
at com.aspose.pdf.internal.l4f.lu.lI(Unknown Source)
at com.aspose.pdf.internal.l5if.lI.lI(Unknown Source)
at com.aspose.pdf.internal.l5t.lI.lI(Unknown Source)
at com.aspose.pdf.TextSegment.setText(Unknown Source)
at com.aspose.pdf.TextSegment.lI(Unknown Source)
at com.aspose.pdf.TextBuilder.lI(Unknown Source)
at com.aspose.pdf.TextBuilder.appendText(Unknown Source)
at com.aspose.pdf.internal.l8j.lb.fillText(Unknown Source)
at com.aspose.pdf.internal.l8j.lt.fillText(Unknown Source)
at com.aspose.pdf.internal.l38p.lI.lI(Unknown Source)
at com.aspose.pdf.internal.l27k.l0v.lI(Unknown Source)
at com.aspose.pdf.internal.l27k.l0if.lI(Unknown Source)
at com.aspose.pdf.internal.l27k.lv.lI(Unknown Source)
at com.aspose.pdf.internal.l27k.l0if.lI(Unknown Source)
at com.aspose.pdf.internal.l27k.l0j.lI(Unknown Source)
at com.aspose.pdf.internal.l27k.l0if.lI(Unknown Source)
at com.aspose.pdf.internal.l27k.l0j.lI(Unknown Source)
at com.aspose.pdf.internal.l27k.l0if.lI(Unknown Source)
at com.aspose.pdf.internal.l27k.l0j.lI(Unknown Source)
at com.aspose.pdf.internal.l27k.l0if.lI(Unknown Source)
at com.aspose.pdf.internal.l27k.l0j.lI(Unknown Source)
at com.aspose.pdf.internal.l27k.l0if.lI(Unknown Source)
at com.aspose.pdf.internal.l27k.lv.lI(Unknown Source)
at com.aspose.pdf.internal.l27k.l0if.lI(Unknown Source)
at com.aspose.pdf.internal.l27k.l1u.lI(Unknown Source)
at com.aspose.pdf.internal.l38p.lI.lI(Unknown Source)
at com.aspose.pdf.internal.l46f.lI.lI(Unknown Source)
at com.aspose.pdf.internal.html.rendering.HtmlRenderer.render(Unknown Source)
at com.aspose.pdf.internal.html.rendering.HtmlRenderer.render(Unknown Source)
at com.aspose.pdf.internal.html.rendering.Renderer.render(Unknown Source)
at com.aspose.pdf.internal.html.rendering.Renderer.render(Unknown Source)
at com.aspose.pdf.l6u.lI(Unknown Source)
at com.aspose.pdf.l6u.lI(Unknown Source)
at com.aspose.pdf.ADocument.lI(Unknown Source)
at com.aspose.pdf.ADocument.(Unknown Source)
at com.aspose.pdf.Document.(Unknown Source)

on below linux environment:
OS:
NAME=“Red Hat Enterprise Linux Server”
VERSION=“7.5 (Maipo)”
ID=“rhel”
ID_LIKE=“fedora”
VARIANT=“Server”
VARIANT_ID=“server”
VERSION_ID=“7.5”
PRETTY_NAME=“Red Hat Enterprise Linux Server 7.5 (Maipo)”
ANSI_COLOR=“0;31”
CPE_NAME=“cpe:/o:redhat:enterprise_linux:7.5:GA:server”
HOME_URL=“https://www.redhat.com/
BUG_REPORT_URL=“https://bugzilla.redhat.com/

REDHAT_BUGZILLA_PRODUCT=“Red Hat Enterprise Linux 7”
REDHAT_BUGZILLA_PRODUCT_VERSION=7.5
REDHAT_SUPPORT_PRODUCT=“Red Hat Enterprise Linux”
REDHAT_SUPPORT_PRODUCT_VERSION=“7.5”

JDK:
jdk version “11.0.3”

Installed Memory:
MemTotal: 32780620 kB

Aspose: 17.02

Unzip file to E drive. So that image path mentioned in form.html get well set.

Please help us to resolve problem quickly.

PDFTest.zip (505.3 KB)

@Rhuol_Chiddi

We used the below code snippet with Aspose.PDF for Java 21.2 and did not notice any exception. We also noticed that you were adding HTML string inside PDF after loading HTML document with HtmlLoadOptions which did not seem correct:

HtmlLoadOptions htmloptions = new HtmlLoadOptions("Path where images are placed");
htmloptions.setInputEncoding("UTF-8");

Document doc = new Document(dataDir + "REQ-11841_Form.html", htmloptions);
System.out.println("Creating pdf file");
// Save HTML file
String sFullFilePath = dataDir + "REQ-11841_Table.pdf";
doc.save(sFullFilePath);

Would you please try using above code snippet with latest version of the API and let us know in case you still face any issue. We will further proceed to assist you accordingly.

Hello,

Thanks for your reply.
We will officially drop mail to get newer version of jar. So that we can use it in our all environment/server.

Question:
“Path where images are placed” --> image path is build at run time along with “REQ-11841_Form.html” & “REQ-11841_Table.pdf” location.

We experience a constraint with 17.2 version to access dynamic location. we think it only accepts fix location.

Does newer version support dynamic image location in HtmlLoanOptions?
Or Please suggest us a way to solve.

Thank you for your assistance.

@Rhuol_Chiddi

You can get the path after assigning it inside HTML for images and give it inside HtmlLoadOptions. You can also try managing external resource loading using the API in case it helps. The path to the images should be the same which was used in the HTML file for image loading. You can also try given suggestions with 17.2v as well and let us know in case you need further information.

Hello,

We modified our code accordingly loading external resource.
But still problem persists.

We observed one strange behavior.
When we try to do same thing on another linux environment (with our actual code), it worked well. This time we don’t have images URL present in HTML.

Attached is the html files.
Can you confirm whats wrong in this? Is there a font issue? But I crossed check installed font. All are same like our PROD environment.

REQ-6555_PRD.zip (3.1 KB)

@Rhuol_Chiddi

Meanwhile we are testing the scenario in our environment, could you please make sure that fonts are present at “/usr/share/fonts/truetype/msttcorefonts” path as Aspose.PDF scans this directory for the installed fonts. Furthermore, you can also use setLocalFontPaths method to set the font path before executing the conversion process.

Hello,

Our server has different font location.
/usr/share/fonts

We never installed fonts on the location you mentioned but it was working previously.
Can you please answer what can be wrong?
Did you check previous attachment? REQ-6555_PRD.zip?

We are currently blocked.
Thank you for help.

@Rhuol_Chiddi

We tested the scenario in our environment while using Aspose.PDF for Java 21.3 and did not face any issue while converting your files into PDF. For your kind reference, output PDFs are also attached.

REQ-6555_Form.pdf (139.2 KB)
REQ-6555_Table.pdf (90.8 KB)

Would you please make sure to test the scenario with the latest version of the API and let us know in case issue still persists.

Thank you.
We will try with latest version of API.

But its really strange that on our one server it works but fails on PRD.
What can be checked at server?
–>
com.aspose.pdf.internal.l20if.l12if: Requested font type subsetting is not supported.

When we receive this error? If some configuration missing.

Just a note, I’m not able to download your files as it supposed to be access by topic owner/staff.

@Rhuol_Chiddi

This error is caused by the reason that MS Fonts are not installed properly in the system or the installed fonts are broken.

There are two ways to fix the issue:

  1. Install msttcorefonts package
  2. Copy required fonts and set path to font directory by the method:
FontRepository.addLocalFontPath("path_to_fonts"); 

In order to further substitute an absent font, you can use built-in monitoring for substituted fonts:

final Map<String,String> names =  new HashMap<String,String>() ;

            pdfDocument.FontSubstitution.add(new Document.FontSubstitutionHandler()
            {
                public void invoke(Font font, Font newFont)
                {
                    //add substituted FontNames into map.
                    names.put(font.getFontName(), newFont.getFontName());
                    //or print the message into console
                    System.out.println("Warning: Font "+ font.getFontName() + " was substituted with another font -> " + newFont.getFontName());
                }
            });

The above code snippet would provide you warnings and font names which are absent or causing the issue.

The issues you have found earlier (filed as PDFJAVA-38554) have been fixed in Aspose.PDF for Java 21.6.