Problems to generate PDF (Linux Enviroment)

Dear all,

Would like to know if someone has or had this problem.

I would like to generate a PDF using aspose and java. In a windows SO the result is ok (as image01.png shows). When I install the software in a Linux SO (SUSE) the pdf is not ok (as image02.png shows).

An aditional information, if a generate a doc instead of pdf in Linux the doc is ok (as image03.png shows).

Can anyone help me?

Thank you!

Rodrigo
Hi Rodrigo,

Thanks for your inquiry. I would suggest you please upgrade to the latest version of Aspose.Words for Java (14.11.0) and see how it goes on your end. I hope this helps.
http://www.aspose.com/community/files/72/java-components/aspose.words-for-java/default.aspx

Also, please note that Aspose.Words requires TrueType fonts when rendering documents to fixed-page formats such as PDF, XPS or SWF. Please install the required fonts on your linux machine and refer to the following articles for details:

How Aspose.Words Uses True Type Fonts
How to Specify True Type Fonts Location
How to Install True Type Fonts on Linux

In case the problem still remains, please attach your input Word document and output PDF file showing the undesired behavior here for testing. We will investigate the issue on our side and provide you more information.

Best regards,
Hello Awais Hafeez

I've tried what you said. I changed the aspose version and checked all true types fonts at the server (Linux SO) and I had no success.

An interesting thing, if I copy and paste the text from a PDF, in a notepad the text is displayed.

Any aideas?

Thank you!
Hi Rodrigo,

Thanks for your inquiry. Please attach your input Word document and output PDF file showing the undesired behavior here for testing. We will investigate the issue on our side and provide you more information.

Best regards,
Awais, the document is generated dynamically.
Is possible to force a specific Font to the PDF? I've observed that in a Linux SO, a strange Font is incorporated.
How to force a specific Font once the default Font for the document is not accepted?

Thank you

Rodrigo

Attached the files to investigate. The PDF was generated in Windows and LINUX.

Hi Rodrigo,


Thanks for the additional information. After an initial test with Aspose.Words for Java 14.11.0 over Linux Enviroment, I was unable to reproduce this issue on my side. I would suggest you please upgrade to the latest version of Aspose.Words. You can download it from the following link. I hope, this helps.

Secondly, you can find various members in FontSettings class particularly FontSettings.DefaultFontName property. Also, you can get notifications of missing fonts and font substitution during rendering. Please refer to the following article:

I hope, this helps.

Best regards,

Hi Awais, I discover the problem. My code to generate the PDF is here:


ByteArrayInputStream imagem = new ByteArrayInputStream(emissaoContrato.getMinuta().getImagem());
Document doc = null;
try
{
doc = new Document(imagem);
}
catch (Exception e)
{
LOG.error(e.getMessage(), e);
throw new ServiceException(e);
}
FontSettings.setDefaultFontName(“Courier”);
doc.save(outputStream, SaveFormat.PDF);

I’ve tried in 3 Linux SO (the same version of JVM, ASPOSE e Container WEB). The problem is, using the code above the PDF doesn’t assume the Font setted.

How is possible forcing the exact Font to generate the PDF (that exists in Linux SO) ?

Thank you.

P.S. I already update the Aspose version!

Hi Rodrigo,


Thanks for your inquiry. First off, please make sure that Aspose.Words is able to pick fonts from following default locations in your Linux environment.

/usr/share/fonts
/usr/local/share/fonts
/usr/X11R6/lib/X11/fonts

When running the code from here, have you noticed any warning messages being generated by Aspose.Words?

You can copy required fonts in one directory on your Linux machine and instruct Aspose.Words to use fonts from this location using FontSettings.setFontsFolder method. It could be that your Linux distribution contains old version of Courier font, and you can try copying latest version of this font from Windows machine into Linux machine. I hope, this helps.

Best regards,