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

Free Support Forum - aspose.com

Out of memory exception converting PDF to word document using Aspose.PDF in dotnetcore C#

	System.OutOfMemoryException: Out of memory.
   at System.Drawing.Region.Intersect(Region region)
   at #=zl_6i8dFQNOrU6rLrBU1h8hAKW4PIsfWH3w==.#=zbA5hrH7Y60cwMrLnSWkDkxc=.#=zvxN7JPdjS7ot(#=zsaH5R1KMgU3e1FwmRbnje9c= #=zkA7YidZNOtEj)
   at #=zsaH5R1KMgU3e1FwmRbnje9c=.#=zY8orcSU=(#=z6ODPS6Qh3ZQoaPqmSFRyL6mh8Ffy #=z2XFhBzs=)
   at #=zJc3b3z4QZBpHnFRHpyFMrwF8c3JA.#=zY8orcSU=(#=z6ODPS6Qh3ZQoaPqmSFRyL6mh8Ffy #=z2XFhBzs=)
   at #=zsaH5R1KMgU3e1FwmRbnje9c=.#=zY8orcSU=(#=z6ODPS6Qh3ZQoaPqmSFRyL6mh8Ffy #=z2XFhBzs=)
   at #=zJc3b3z4QZBpHnFRHpyFMrwF8c3JA.#=zY8orcSU=(#=z6ODPS6Qh3ZQoaPqmSFRyL6mh8Ffy #=z2XFhBzs=)
   at #=zsaH5R1KMgU3e1FwmRbnje9c=.#=zY8orcSU=(#=z6ODPS6Qh3ZQoaPqmSFRyL6mh8Ffy #=z2XFhBzs=)
   at #=zJc3b3z4QZBpHnFRHpyFMrwF8c3JA.#=zY8orcSU=(#=z6ODPS6Qh3ZQoaPqmSFRyL6mh8Ffy #=z2XFhBzs=)
   at #=zG68Jd3tx9ZPvn6_B_ZvmdVI=.#=zY8orcSU=(#=z6ODPS6Qh3ZQoaPqmSFRyL6mh8Ffy #=z2XFhBzs=)
   at #=zJc3b3z4QZBpHnFRHpyFMrwF8c3JA.#=zY8orcSU=(#=z6ODPS6Qh3ZQoaPqmSFRyL6mh8Ffy #=z2XFhBzs=)
   at #=zQ2yQPkir__cRz9p0L2qtWl8=.#=zY8orcSU=(#=z6ODPS6Qh3ZQoaPqmSFRyL6mh8Ffy #=z2XFhBzs=)
   at #=zl_6i8dFQNOrU6rLrBU1h8hAKW4PIsfWH3w==.#=zUNl00cE=(#=zJc3b3z4QZBpHnFRHpyFMrwF8c3JA #=zXozSQPM=, Single #=zqtgTtPuUrXWa, #=zQ1dJmqZViT$OnwvXkDOns15Q5weAuUcs2Q== #=zb6ItOOA=, Boolean #=zDcUkhtWRYaMq)
   at #=zQ1dJmqZViT$OnwvXkDOns15Q5weAuUcs2Q==.#=z17cjcE1GNGtHLk3oqg==(#=zMGlcsn3BFoIMneBME1lOKwI= #=zHZ1Wdxs=, Single #=zqtgTtPuUrXWa, Single #=zaYk662zIB0v0, #=zaK8MiNbbW1ILbfbogrQw7yszq9AtB5rIJF0GVUg= #=znsjntMs=, Boolean #=zFiPSdzXF$MiC_zavFfuWPoE2rJRiijJcow==, Boolean #=zGfpN9VPLJVUyI3yxqQ==, #=zQ1dJmqZViT$OnwvXkDOns15Q5weAuUcs2Q== #=zb6ItOOA=)
   at #=zQ1dJmqZViT$OnwvXkDOns15Q5weAuUcs2Q==.#=z17cjcE1GNGtHLk3oqg==(#=zMGlcsn3BFoIMneBME1lOKwI= #=zHZ1Wdxs=, Single #=zqtgTtPuUrXWa, Single #=zaYk662zIB0v0, #=zQ1dJmqZViT$OnwvXkDOns15Q5weAuUcs2Q== #=zb6ItOOA=)
   at #=zQ1dJmqZViT$OnwvXkDOns15Q5weAuUcs2Q==.#=z4Cy6P7mbNR1KNzwx2UwdMVk=(#=zMGlcsn3BFoIMneBME1lOKwI= #=zHZ1Wdxs=, SizeF #=ziQ75Wws=)
   at #=zRc36HAOEy8YwyoO3snRcpyF9mHVt5jgNT$sNysU=.#=z8iw6RLE=(#=zQ2yQPkir__cRz9p0L2qtWl8= #=zz9dkUxzR0bDt, #=zOfLX9YbusSjAuFmYn7pu145grUsU8BgGvg== #=z5VL4nng=)
   at #=zDCwwTC0biIm_ddbKzisdpWY9B_vT4gwXLQ==.#=z8iw6RLE=(#=zQ2yQPkir__cRz9p0L2qtWl8= #=zaWlAJpI=)
   at #=zBWykNWW6cSmysUq_sP3gIRU=.#=zFgw7Dj1HNLAjMHe1yg==(Document #=zJI$HESs=, DocSaveOptions #=zS65jNXk=, Queue`1 #=zob_bbr_ZMwsC, Stream #=zxPkvVuVtMRjf, Int32 #=zBMsq8EAuY$4t)
   at #=zBWykNWW6cSmysUq_sP3gIRU=.#=z1TTwgCY=(Document #=zJI$HESs=, Stream #=zxPkvVuVtMRjf, DocSaveOptions #=zS65jNXk=)
   at Aspose.Pdf.Document.#=zcOk$9jRDM4g7(Stream #=zxPkvVuVtMRjf, SaveOptions #=zS65jNXk=)
   at Aspose.Pdf.Document.#=zcOk$9jRDM4g7(String #=zaT_PEOOjO9fV, SaveOptions #=zS65jNXk=)
   at Aspose.Pdf.Document.Save(String outputFileName, SaveOptions options)
   at Author.PdfConverter.WordConverter.ConvertToWord(ILogger logger, Stream stream) in /app/Author.PdfConverter/WordConverter.cs:line 67

These are the save options being used:

Aspose.Pdf.DocSaveOptions saveOptions = new Aspose.Pdf.DocSaveOptions();
saveOptions.Mode = Aspose.Pdf.DocSaveOptions.RecognitionMode.Flow;
saveOptions.RecognizeBullets = true;
saveOptions.Format = Aspose.Pdf.DocSaveOptions.DocFormat.DocX;

This error is occurring in Docker with 5GB of ram. The document size is 263KBPreformatted text

@samuelkdavis

Would you kindly share your sample PDF document with us so that we can test the scenario in our environment and address it accordingly.

Hi, I’ve managed to get it fixed. The pdf processed fine in windows, and in WSL2 ubuntu. I switched my container to ubuntu and am no longer receiving these issues.

FROM ubuntu:20.10

WORKDIR /app

RUN apt-get update

RUN apt-get install wget -y

RUN wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb

RUN dpkg -i packages-microsoft-prod.deb

RUN apt-get update && apt-get install -y gnupg2

RUN apt-get update; \

  apt-get install -y apt-transport-https && \

  apt-get update && \

  apt-get install -y dotnet-sdk-3.1

RUN echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | debconf-set-selections

RUN apt-get install -y --quiet ttf-mscorefonts-installer

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

It is good to know that you have been able to resolve the issue. Please keep using our API and in case you face any issue, please feel free to let us know.