Hi to all!
I am getting ‘System.OutOfMemoryException’ in Aspose.Words.dll while i try conwert big ( 128mb) TXT file to PDF.
The code is :
protected override PdfRenderResponse RenderToPdf(PdfRenderRequest request)
{
byte[] content;
using (var reader = new StreamReader(request.Stream))
using (var outputStream = new MemoryStream())
{
var text = reader.ReadToEnd();
var builder = new DocumentBuilder();
builder.Write(text);
var saveOptions = new global::Aspose.Words.Saving.PdfSaveOptions()
{
Compliance = global::Aspose.Words.Saving.PdfCompliance.Pdf17,
};
builder.Document.Save(outputStream, saveOptions);
content = outputStream.ToArray();
}
var returnValue = new PdfRenderResponse
{
Content = content,
};
return returnValue;
}
2022-02-04 14:22:20,155 ERROR [32] - Exception occurred during the handling of PdfRenderRequest for file: '341.txt': 'System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at ? ..ctor(Int32 )
at ..ctor(Inline , ? , String , ? )
at ? .(Inline , String , Boolean )
at . ()
at .()
at ? .()
at Aspose.Words.Document.UpdatePageLayout()
at .( ? , ?? )
at .? ( ? )
at ?? .?? ( ? )
at Aspose.Words.Document.( ? )
at Aspose.Words.Document.(Stream , String , SaveOptions )
at Aspose.Words.Document.Save(Stream stream, SaveOptions saveOptions)
@shubna Thank you for reporting this problem to us. But I am afraid the document is simply too large for rendering. MS Word also cannot convert your document to PDF it hangs for a while and then shows the following error:
Which is not surprising, your document contains 2097154 lines (paragraphs in Aspose.Words DOM), one page contains about 46 lines. In your sample document one paragraph fits one line on the page so the final document will contain about 45k pages.
I would recommend you to split such abnormally huge documents into parts.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.