Cannot find any fonts installed on the system (MapReduce)

Hi,
I’m trying to convert pdf file to html. There are mapReduce in application so I have a lot of servers and I can’t install fonts on all of it. There is possible to convert to html without install fonts?
Sometimes this code works without this error on the same server which didn’t work a moment ago.
I think that there can be some problem with pdf aspose.
Below trace occur during document saving:

HtmlSaveOptions saveOptions = prepareSaveOptions(resultOutputStream);
document.save(“temp.xml”, saveOptions);
document.close();
htmlContent = new String(resultOutputStream.toByteArray(), StandardCharsets.UTF_8);

I don’t need to save document to file anyway but then I have empty output.

aspose-pdf:18.9
java 1.8.0_101-b13
Red Hat 4.4.7-18

com.aspose.pdf.internal.ms.System.I174: Cannot find any fonts installed on the system.
at com.aspose.pdf.internal.l61l.I17.lif(Unknown Source)
at com.aspose.pdf.internal.l61l.I17.lif(Unknown Source)
at com.aspose.pdf.internal.l61l.I17.lif(Unknown Source)
at com.aspose.pdf.internal.l387.I34.lI(Unknown Source)
at com.aspose.pdf.internal.l39l.I4I.lI(Unknown Source)
at com.aspose.pdf.internal.l39l.I4I.ll(Unknown Source)
at com.aspose.pdf.internal.l39l.I4I.lif(Unknown Source)
at com.aspose.pdf.internal.l39l.I4I.lif(Unknown Source)
at com.aspose.pdf.internal.l39l.I4I.lif(Unknown Source)
at com.aspose.pdf.internal.l38l.I01.lif(Unknown Source)
at com.aspose.pdf.internal.l38l.I01.lif(Unknown Source)
at com.aspose.pdf.internal.l38l.I01.lif(Unknown Source)
at com.aspose.pdf.internal.l38l.I1l.lif(Unknown Source)
at com.aspose.pdf.internal.l38l.I1l.lif(Unknown Source)
at com.aspose.pdf.internal.l38l.I0I.lif(Unknown Source)
at com.aspose.pdf.internal.l38l.I7.lif(Unknown Source)
at com.aspose.pdf.internal.l387.II.lif(Unknown Source)
at com.aspose.pdf.internal.l07.I01.lif(Unknown Source)
at com.aspose.pdf.I17I.lif(Unknown Source)
at com.aspose.pdf.I17I.lif(Unknown Source)
at com.aspose.pdf.ADocument.lif(Unknown Source)
at com.aspose.pdf.ADocument.save(Unknown Source)
at com.aspose.pdf.Document.save(Unknown Source)
at processor.PdfToHtmlProcessor.convertPdfToHtml(PdfToHtmlProcessor.java:113)
at processor.PdfToHtmlProcessor.lambda$1(PdfToHtmlProcessor.java:78)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1374)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
at processor.PdfToHtmlProcessor.processDocument(PdfToHtmlProcessor.java:78)
at converter.DocumentConverter.convert(DocumentConverter.java:43)
at mapper.CondorSplitterMapper.map(CondorSplitterMapper.java:39)
at mapper.CondorSplitterMapper.map(CondorSplitterMapper.java:1)
at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:145)
at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:793)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:341)
at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:164)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:422)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1917)
at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:158)

Regards,
Jarek

@JaroslawPigula

Thank you for contacting support.

Would you please share a zipped, sample HTML file which reproduces this issue in your environment. Also share a self-contained code snippet which does not include any undefined method or variable so that we may try to reproduce and investigate it in our environment.

@Farhan.Raza
Thanks for response. Unfortunately I can’t send to you any PDF and HTML files. I’m trying to convert PDF to HTML. There is possible to set Fonts or skip document.save(String filename, SaveOptions options) method? I was trying to use this method with outputStream but I have information about unset classes but when I set it then I have got trace with information about it I can’t set these classes so I’m confused. I attached snippet of the code in txt file.
sample code.zip (965 Bytes)

@JaroslawPigula

Would you please share a working sample project application instead of partial code which includes some undefined properties and methods. For instance, getUnavailableFontNames. We need to reproduce the scenario to help you out so kindly elaborate the problem a little more, for our reference.

Moreover, you may also visit the documentation article Replace fonts in existing PDF file.

@Farhan.Raza The code is my companies property and I can share whole code on this fromu, I can send you it in email. Anyway I now that information about problems should be public on this forum but I can’t share my code. There is some possible to do it?

@JaroslawPigula

Please note that all attachments are accessible to thread owner and Aspose staff only, so no one else can access your data. Feel free to attach it here or you can upload it to Google Drive, Dropbox etc and share the link with me in private message. You may click on my username and send the message. We will try to reproduce it in our environment to help you out. Please also elaborate the problem a little more.

@JaroslawPigula

Thank you for sharing the Java class. However, it includes methods but not the method call sequence, please specify the sequence of methods you are working with so that we may try to reproduce and investigate it. As requested earlier, kindly elaborate the problem and share a working sample application instead of Java classes only, we will then be able to proceed further.

@Farhan.Raza
Thank you for response. Unfortunately I can’t send you my whole application. Process is the first method called. Maybe you can just tell me how can I use document.save(OutputStream, saveOptions); I know how to use it with file name as first arg but here occur problem with fonts when application tries to save data in file on the server. So for me solution is a save it in output stream but when I’m trying to do it I have information about that I have to set some properties(initialize class) but I don’t know how can I do it. When I set invoke method for it I have information about that I should have it empty so I’m confused now. Could you show me how can I use save method for outputSteam?

@JaroslawPigula

You can save an instance of Document object to ByteArrayOutputStream and then this stream can be saved or manipulated as per your requirements.

Document document = new Document();
com.aspose.pdf.HtmlSaveOptions options = new com.aspose.pdf.HtmlSaveOptions();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
document.save(baos, options);

We hope this will be helpful. Please elaborate a little more if you need any further assistance. We will be more than glad to assist you.

@Farhan.Raza I was trying to use your code but I received error:

changes in my code:

try (ByteArrayOutputStream resultOutputStream = new ByteArrayOutputStream()) {
HtmlSaveOptions saveOptions = prepareSaveOptions(resultOutputStream);
document.save(resultOutputStream, saveOptions);
document.close();

htmlContent = new String(resultOutputStream.toByteArray(), StandardCharsets.UTF_8);

class com.aspose.pdf.internal.ms.System.z8: Inconsistent saving options detected : ‘CustomStrategyOfCssUrlCreation’,‘CustomCssSavingStrategy’,‘CustomResourceSavingStrategy’ may not be null when requested saving to stream!

When I set these objects (fast samples):

saveOptions.CustomStrategyOfCssUrlCreation = new HtmlSaveOptions.CssUrlMakingStrategy() {
@Override
public String invoke(HtmlSaveOptions.CssUrlRequestInfo cssUrlRequestInfo) {
return null;
}
};

saveOptions.CustomCssSavingStrategy = new HtmlSaveOptions.CssSavingStrategy() {
@Override
public void invoke(HtmlSaveOptions.CssSavingInfo cssSavingInfo) {

}
};

saveOptions.CustomResourceSavingStrategy = new HtmlSaveOptions.ResourceSavingStrategy() {
@Override
public String invoke(SaveOptions.ResourceSavingInfo resourceSavingInfo) {
return null;
}
};

then I received:

class com.aspose.pdf.internal.ms.System.z8: If selected mode of embedding into HTML(PartsEmbeddingModes.EmbedAllIntoHtml), custom CSS saving stategy not allowed and must be null! Please set HtmlSaveOptions.CustomCssSavingStrategy=null!’

class com.aspose.pdf.internal.ms.System.z8: If selected mode of embedding CSSes into HTML(PartsEmbeddingModes.EmbedAllIntoHtml), custom CSS URL creation strategy not allowed and must be null! Please set HtmlSaveOptions.CustomStrategyOfCssUrlCreation=null!’

class com.aspose.pdf.internal.ms.System.z8: If selected mode of embedding of external resources into HTML (PartsEmbeddingModes.EmbedAllIntoHtml), custom
resource saving strategy not allowed and must be null! Please set HtmlSaveOptions.CustomResourceSavingStrategy=null!’

I attached file with logs to this message. What should I set and how? Do you have some solution for it?
logs.zip (3.9 KB)

@JaroslawPigula

Would you please share a narrowed down sample application containing SSCCE code and source file so that we may try to reproduce it and assist you accordingly.

@Farhan.Raza
You can find a zip file with the code here: AsposeTesting.zip (235.1 KB)

@JaroslawPigula

Thank you for sharing requested code.

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

@JaroslawPigula

Thank you for being patient.

We have been able to notice the problem while saving the output to stream object. A ticket with ID PDFJAVA-38197 has been logged in our issue management system for further investigation and resolution. The ticket ID has been linked with this thread so that you will receive notification as soon as the ticket is resolved.

We are sorry for the inconvenience.