We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Font not found in linux

Hi there,


I am using pdf 11.1.0 to convert pdf files to html.

I got an exception in linux

class com.aspose.pdf.exceptions.FontNotFoundException: Font Helvetica can not found.
com.aspose.pdf.internal.p53.z29.m27(Unknown Source)
com.aspose.pdf.internal.p42.z1.m1(Unknown Source)
com.aspose.pdf.internal.p42.z3.m1(Unknown Source)
com.aspose.pdf.internal.p32.z7.m3(Unknown Source)
com.aspose.pdf.internal.p32.z7.m4(Unknown Source)
com.aspose.pdf.internal.p32.z7.m2(Unknown Source)
com.aspose.pdf.internal.p32.z7.m2(Unknown Source)
com.aspose.pdf.ApsUsingConverter.m1(Unknown Source)
com.aspose.pdf.z37.m1(Unknown Source)
com.aspose.pdf.ADocument.save(Unknown Source)
com.aspose.pdf.Document.save(Unknown Source)

And my code would be like this:

Document pdf = new Document(“custom/input/pdf/Redis.pdf”);
HtmlSaveOptions htmlSaveOps = new HtmlSaveOptions();
pdf.save(“custom/output/pdf/Redis.html”, htmlSaveOps);


this pdf should be in the attachement.

Please take a look and help me solve this problem, thanks :slight_smile:

Hi Craig,


Thanks for your inquiry. We are looking into it and will guide you accordingly.

We are sorry for the inconvenience caused.

Best Regards,

If it is true about “font not found” when saving, is there any way to set default font for saving even without the specific font required

Hi Craig,


Thanks for your patience.

One workaround to resolve font not found issue is to Replace fonts in existing PDF file with fonts currently installed over system and then perform the conversion. Currently we cannot specify the system to use default fonts when fonts used inside document are not found.
Hi Craig,
craigabyss:
Hi there,

I am using pdf 11.1.0 to convert pdf files to html.

I got an exception in linux

class com.aspose.pdf.exceptions.FontNotFoundException: Font Helvetica can not found.
com.aspose.pdf.internal.p53.z29.m27(Unknown Source)
com.aspose.pdf.internal.p42.z1.m1(Unknown Source)
com.aspose.pdf.internal.p42.z3.m1(Unknown Source)
com.aspose.pdf.internal.p32.z7.m3(Unknown Source)
com.aspose.pdf.internal.p32.z7.m4(Unknown Source)
com.aspose.pdf.internal.p32.z7.m2(Unknown Source)
com.aspose.pdf.internal.p32.z7.m2(Unknown Source)
com.aspose.pdf.ApsUsingConverter.m1(Unknown Source)
com.aspose.pdf.z37.m1(Unknown Source)
com.aspose.pdf.ADocument.save(Unknown Source)
com.aspose.pdf.Document.save(Unknown Source)

And my code would be like this:

Document pdf = new Document("custom/input/pdf/Redis.pdf");
HtmlSaveOptions htmlSaveOps = new HtmlSaveOptions();
pdf.save("custom/output/pdf/Redis.html", htmlSaveOps);


this pdf should be in the attachement.

Please take a look and help me solve this problem, thanks :)


We are sorry for the inconvenience. It seems Aspose.Pdf for Java is unable to find fonts on your system. I have tested PDF to HTML conversion over CentOS and unable to notice the reported issue. I have Microsoft fonts in system default font path i.e. /usr/share/fonts/msttcorefonts/.

Please install Microsoft fonts on your system or place your fonts in your system default font path and try the conversion. Hopefully it will resolve the issue.

Best Regards,

Thanks for your solution :slight_smile:


However if Aspose cannot find fonts which is required for conversion, could it use default font for it?

Furthermore, we cannot assure that we have all fonts we need to convert client’s pdf file, right?

Besides, we have to care about the fonts’(from microsoft) copyright or it may cause some legal problems

craigabyss:
Thanks for your solution :slight_smile:

However if Aspose cannot find fonts which is required for conversion, could it use default font for it?

Furthermore, we cannot assure that we have all fonts we need to convert client’s pdf file, right?

Besides, we have to care about the fonts’(from microsoft) copyright or it may cause some legal problems
Hi Craig,

Thanks for the acknowledgement.

I have logged the above stated requirement as PDFNEWJAVA-35503 in our issue tracking system. We will further look into the details of this problem and will keep you posted on the status of correction. Please be patient and spare us little time. We are sorry for this inconvenience.

Hi Craig,


Thanks for your feedback. If Aspose.Pdf for Java can not find the referred font it should fall back to the system default font. However if you are facing some issue then please share some deatils so we will look into it and guide you.

Furthermore , using Microsoft fonts on linux is legal. You can read EULA here: https://www.microsoft.com/typography/fontpack/eula.htm The key parts of the license are, “The SOFTWARE PRODUCT is licensed, not sold.” and "You may install and use an unlimited number of copies of the SOFTWARE PRODUCT."

Best Regards,

Hi


I 've tried this solution
Here is my code:

Document pdf = new Document(“custom/input/pdf/PD_005.pdf”, “123456”);

String defaultFontName = “fontName”;
HtmlSaveOptions htmlSaveOps = new HtmlSaveOptions();

TextFragmentAbsorber absorber = new TextFragmentAbsorber(
new TextEditOptions(
TextEditOptions.FontReplace.RemoveUnusedFonts));

pdf.getPages().accept(absorber);

TextFragmentCollection textFragmentCollection = absorber
.getTextFragments();
for (Iterator iterator = textFragmentCollection.iterator(); iterator.hasNext():wink: {
TextFragment textFragment = iterator.next();
textFragment.getTextState().setFont(
FontRepository.findFont(defaultFontName));
}

pdf.save(“custom/output/pdf/APD_005.pdf.html”, htmlSaveOps);

I tried to replace all fonts of texts in the pdf, but it seems that not all text’s font are replaced by the font I want.

I add my pdf file in the attachement, please check it.
the defaultFontName can be other font’s name.

Is there somthing wrong about this code?

Hi Craig,


Thanks for your inquiry. I have tested the scenario with Arial Unicode MS font and noticed the reported issue, all fonts are not being replaced. We have logged a ticket PDFNEWJAVA-35508 in our issue tracking system for further investigation and resolution. We will notify you as soon as it is resolved.

We are sorry for the inconvenience.

Best Regards,

The issues you have found earlier (filed as PDFNEWJAVA-35503) have been fixed in Aspose.Pdf for Java 11.5.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

The issues you have found earlier (filed as PDFNEWJAVA-35508) have been fixed in Aspose.Pdf for Java 16.11.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.