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)
@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.