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.
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.
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.
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.
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.
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.
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.
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.
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 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.
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.
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:
Install msttcorefonts package
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.