We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Convert PDF to DOCX using Aspose.PDF for .NET under Linux - object reference not set to an instance

new Aspose.Pdf.Document(pdfFileLocation).Save(wordFileLocation, SaveFormat.DocX)

Throw the error:
System.NullReferenceException: Object reference not set to an instance of an object.
at #=zD0fa8itO5ui54F8jEYXzphgyuYHPVRG_hCUT$NzZJbO9.#=zmbjyF2HNTn7b()
at #=zBpwQv4kqNuLWVhg1HEhtn9uKgk50SQVg8ibOS_1i0Rbf7zgsFw==.#=zfBd9dI8=(#=z7GS$1utcjEvFgZ_8ESrPzhah2f1y8rftmfe8ck9Z$OQQ #=z4aTy0Hc=, #=zYoQVCAbCU4j9kycH3YDuII1uroSbBk1Avr5QKdPE_bEb #=zvYmSv1E9vNaB, #=zCvqUyy58DIav7tcWZlxGEoxFDr$V$7fSyg== #=z3hfAmLg=)
at #=zELMwkqufAmt6AlqpGYl3U3zLFyyrFR7eSUdtN6GdAMw1DfVJqg==.#=zfBd9dI8=(#=z7GS$1utcjEvFgZ_8ESrPzhah2f1y8rftmfe8ck9Z$OQQ #=z4aTy0Hc=, #=zYoQVCAbCU4j9kycH3YDuII1uroSbBk1Avr5QKdPE_bEb #=zvYmSv1E9vNaB)
at #=z3NJn0rgKZdfKwcCHUdmeHE0XVh$4zz08yIBhmVTy6SjU.#=zFb8P2o_Evu2KQ8cQSg==(#=z7GS$1utcjEvFgZ_8ESrPzhah2f1y8rftmfe8ck9Z$OQQ #=z4aTy0Hc=, List1 #=zmTg3oAs=) at #=z3NJn0rgKZdfKwcCHUdmeHE0XVh$4zz08yIBhmVTy6SjU.#=zeESHUxaS$kzduBGUxg==(#=z7GS$1utcjEvFgZ_8ESrPzhah2f1y8rftmfe8ck9Z$OQQ #=z4aTy0Hc=, List1 #=zmTg3oAs=)
at #=z3NJn0rgKZdfKwcCHUdmeHE0XVh$4zz08yIBhmVTy6SjU.#=zjYxDj1s5O5FL(#=z7GS$1utcjEvFgZ_8ESrPzhah2f1y8rftmfe8ck9Z$OQQ #=z4aTy0Hc=, List1 #=zWOmyDDdha8_I) at #=z3NJn0rgKZdfKwcCHUdmeHE0XVh$4zz08yIBhmVTy6SjU.#=zl9_56XU=(#=z7YJ6FD11yomS8Ad5MwdRkHNkTuLn #=z0swRsQA=, #=zFXLkxeb0R0MZuadF9qn0WcJexYO00eQvNw== #=zn9Zfcj8=, #=z7GS$1utcjEvFgZ_8ESrPzhah2f1y8rftmfe8ck9Z$OQQ #=z4aTy0Hc=) at #=zKOVyNvh3VYYIok2dtAjosGZKA7fKYXdWoA==.#=zaIrs9JQ=(Int32 #=zN2fFN_8=, IList1 #=zsnRIwefLoit3OCJLhA==, #=zmPj8OCpJ9ntK #=zcYdIMgs=)
at #=zKOVyNvh3VYYIok2dtAjosGZKA7fKYXdWoA==.#=zl9_56XU=()
at #=zqL8JMLHlm1qm2zxInq2O8Y90A0It.#=zee4Tgs8XLffv(Document #=z0swRsQA=, #=z7GS$1utcjEvFgZ_8ESrPzhah2f1y8rftmfe8ck9Z$OQQ& #=zZInXOfthePmjwOb43w==, UnifiedSaveOptions #=zkPLPQeA=, Int32& #=zmnMNLxA0xTnX, Boolean #=zoawTHck=)
at #=zqL8JMLHlm1qm2zxInq2O8Y90A0It.#=zdjbsrSYCPe0$x1AICA==(Document #=zXOj1L9eX9YMl, #=z7GS$1utcjEvFgZ_8ESrPzhah2f1y8rftmfe8ck9Z$OQQ& #=z4aTy0Hc=, UnifiedSaveOptions #=zkPLPQeA=, Int32& #=zVqfNwsZ1NfaD, Boolean #=zoawTHck=)
at #=z1uk1kmFz4$dZYJUlaqR3HH4=.#=zdY03P4A=(Document #=z0swRsQA=, Stream #=zEIpCJDiFv3dI, DocSaveOptions #=zkPLPQeA=)
at Aspose.Pdf.Document.#=z4hZe98z$mC5e(Stream #=zEIpCJDiFv3dI, SaveOptions #=zkPLPQeA=)
at Aspose.Pdf.Document.#=z4hZe98z$mC5e(String #=zrrBoMbipHx43, SaveFormat #=z67h4_4U=)
at Aspose.Pdf.Document.Save(String outputFileName, SaveFormat format)

@samuelkdavis

Would you kindly make sure that following packages and installations are made to the environment in which you are using the API:

  1. libgdiplus package
  2. package with Microsoft compatible fonts: ttf-mscorefonts-installer. (e.g. sudo apt-get install ttf-mscorefonts-installer )

These fonts should be placed in “/usr/share/fonts/truetype/msttcorefonts” directory as Aspose.PDF for .NET scans this folder on Linux like operating systems. In case operating system has other default folder/directory for fonts, you should use following line of code before performing any operation using Aspose.PDF.

Aspose.Pdf.Text.FontRepository.Sources.Add( new FolderFontSource( "<user's path to ms fonts>" ));

In case you still face any issue, please share your sample PDF document with us. We will test the scenario in our environment and address it accordingly.

This seems to work for some documents.

This is the docker container I used:

FROM mcr.microsoft.com/dotnet/core/sdk:3.1

WORKDIR /app

RUN apt-get update

# install ttf-mscorefonts-installer
RUN echo "deb http://httpredir.debian.org/debian jessie main contrib" > /etc/apt/sources.list \
    && echo "deb http://security.debian.org/ jessie/updates main contrib" >> /etc/apt/sources.list \
    && echo "ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true" | debconf-set-selections \
    && apt-get update \
    && apt-get install -y ttf-mscorefonts-installer \
    && apt-get clean \
    && apt-get autoremove -y \
    && rm -rf /var/lib/apt/lists/*

RUN apt-get update && apt-get install -y libfontconfig1 libgdiplus

COPY . ./
RUN dotnet publish -c Release -o out

ENV ASPNETCORE_URLS "http://0.0.0.0:8000"

ENTRYPOINT [ "dotnet", "out/MyProject.dll"]

@samuelkdavis

Please share the document for which you are facing the error after even following the above shared suggestions. We will further proceed to assist you accordingly.