Free Support Forum - aspose.com

Formatting and text errors on docx to PDF conversion

Hi There,


I am using following code to convert docx to PDF:

InputStream DocFile = new ByteArrayInputStream(inParamFile);
Document doc = new Document(DocFile );
// ConvertDoc
doc.save(outputByteArray,SaveFormat.PDF);
ResultFile = outputByteArray.toByteArray();

But I loose some characters appear as boxes and all the spacing gets messed up. How can I make sure that all characters show up and formatting is same? The font used in Word file is Arial with size 10.
Please check the attached screenshots for issues.

Thanks,
Gurvinder

Hi Gurvinder,


Thanks for your inquiry. Could you please attach your input Word document you’re getting this problem with and output PDF file showing the undesired behavior here for testing? We will investigate the issue on our end and provide you more information.

Best regards,

Hi Awais,


Please check the attached word and pdf files.
FYI It is okay for us if the document is converted to pdf with images as data instead of text.

Thanks,
Gurvinder

Forgot to attach the files earlier. Please check it now.

Hi Gurvinder,


Thanks for your inquiry. After an initial test with Aspose.Words for Java 17.2.0, we were unable to reproduce this issue on our end (see attached awjava-17.2.0.pdf). Please make sure that the following fonts are installed on your machine:

  • Arial
  • Wingdings

Best regards,

Hi Awais,


Thanks for your feedback. We have the application deployed on Linux Redhat Machine, where can I get these fonts for that?

Regards,
Gurvinder

Hi Gurvinder,


Thanks for your inquiry. You can copy required fonts from Windows machine. Please try installing/copying attached “fonts.zip” in your Linux machine. Hope, this helps.

Different Linux distributions store fonts in different folders. Aspose.Words looks for fonts in several well-known locations.

By default, Aspose.Words looks for the fonts in the following locations:

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

This default behavior will work for most Linux distributions, but not guaranteed to work all of the time. You might need to specify the location of true type fonts explicitly. To do this, you need to know where TrueType fonts are installed on your Linux distribution.

Best regards,