Proxy error(NullReferenceException) in aspose.pdf (python via .Net)

To convert pdf to HTML, I am using the aspose.pdf library. I have installed the library through pip3 install aspose-pdf. This library works fine for my Windows machine in Python, version 3.8. But facing an error in linux machine: Proxy error(NullReferenceException): Object reference not set to an instance of an object. I have tried Centos and Ubuntu, but getting the same error. source code:

import aspose.pdf as pdf

doc = pdf.Document("input.pdf")
saveOptions = pdf.HtmlSaveOptions()
doc.save("output.html", saveOptions)

System details:

  • OS: Ubuntu 20.04.3, centos 7
  • Python version: Python 3.8.10
  • Aspose.pdf: 23.5.0 (python via . Net)

@rifh07
Thank you for contacting support.
Can you attach your file (any file with which there is an error) so that we can test the problem? Thanks!

@sergey.mikhaylov

The following is the code that I created:
sample.zip (724 Bytes)

@rifh07
Yes, the code won’t hurt either, but we need a data file (input.pdf) to reproduce the error.

@sergey.mikhaylov
For sample data you can use all pdf. You must be getting the same error. I used sample data from https://www.africau.edu/images/default/sample.pdf

@rifh07
Thanks! We are checking it and will get back to you shortly.

@rifh07
the library is strongly tied to the fonts available in MS Windows. And when working in other OS, it often helps to install them.
So you shoud install package with Microsoft compatible fonts: ttf-mscorefonts-installer

Another nuance when working with the library in Linux:
In which folder do you have the fonts installed?
The package looks for fonts in folders:
“/usr/share/fonts”
“/usr/share/fonts/truetype/msttcorefonts”
“/usr/share/fonts/msttcore”
“/usr/local/share/fonts”
“~/.fonts”
and does not take into account what is located in the cache. Let’s say that the font is shown by the command “fc-list | grep “.ttf” | cut -f2 -d: | sort | uniq" does not mean that it will be used by the library.