System.OutOfMemoryException when using Aspose.Words.Cloud to generate printable

Product: Aspose.Words Cloud SDK
Platform: [.NET / Java / Node.js / Python / etc. — specify your SDK]
Error Type: Runtime Exception - System.OutOfMemoryException
Priority: High (production impact)

Description:
We are experiencing a System.OutOfMemoryException while using the Aspose.Words.Cloud.Sdk during a document conversion operation (PDF generation for printable quotes).

The error appears in our logs during the execution of this method:

Aspose.Words.Cloud.Sdk.WordsApi.ConvertDocument(ConvertDocumentRequest request)

It appears the service is unable to process the document due to memory limitations or handling of large input data.

@AsposeCreatio

:page_facing_up: Issue Summary

You are receiving a System.OutOfMemoryException when calling

Aspose.Words.Cloud.Sdk.WordsApi.ConvertDocument(ConvertDocumentRequest request)

during a PDF conversion (printable quotes).

The exception is thrown on the client side, which means the SDK tried to load the entire converted document into memory before returning it to your application.


:rocket: Quick Fixes

# Action Why it helps
1 Upgrade to the latest Aspose.Words Cloud SDK Memory‑handling improvements and bug fixes are included in every release.
2 Use the “out‑path” (cloud storage) overload The API writes the converted file directly to Aspose Cloud Storage, so the SDK never holds the whole PDF in memory.
3 Stream the result instead of loading it If you must receive the file in memory, use the GetDocumentWithFormat method with Stream (or async) to process the data chunk‑by‑chunk.
4 Reduce the document size before conversion (e.g., remove unused images, large embedded objects, or split the source file into smaller parts).
5 Set PDF save options for size optimization (e.g., disable high‑quality rendering, compress images).
6 Increase the available memory for your process (run the app on a machine/instance with more RAM) if streaming cannot be used.

:hammer_and_wrench: Recommended Implementation

Below is a sample workflow that avoids the out‑of‑memory condition by writing the PDF directly to Aspose Cloud Storage and then downloading it (or providing a public link) as needed.

:one: Prepare the request with an OutPath

using Aspose.Words.Cloud.Sdk.Api;
using Aspose.Words.Cloud.Sdk.Model.Requests;

// Initialise the API (replace with your credentials)
var config = new Configuration
{
    ClientId = "YOUR_CLIENT_ID",
    ClientSecret = "YOUR_CLIENT_SECRET"
};
var wordsApi = new WordsApi(config);

// Input document (can be in local storage or already uploaded to cloud)
string sourceFileName = "Quote.docx";
string storageFolder = "input";
string outFolder = "output";
string outFileName = "Quote.pdf";

// Build the convert request
var convertRequest = new ConvertDocumentRequest
{
    Name = sourceFileName,
    Format = "pdf",
    Folder = storageFolder,          // folder where the source lives
    OutPath = $"{outFolder}/{outFileName}", // **important** – write result to cloud storage
    // Optional: PDF save options for reduced memory usage
    SaveOptionsData = new PdfSaveOptions
    {
        CompressImages = true,
        ImageCompression = PdfImageCompression.Jpeg,
        JpegQuality = 70,
        OptimizeForSize = true,
        // Disable high‑quality rendering if not needed
        UseHighQualityRendering = false
    }
};

// Perform conversion – the SDK only receives a small JSON response
var convertResult = wordsApi.ConvertDocument(convertRequest);

:two: (Optional) Download the generated PDF when needed

var downloadRequest = new DownloadFileRequest
{
    Path = $"{outFolder}/{outFileName}",
    Storage = null               // default storage
};

using (var pdfStream = wordsApi.DownloadFile(downloadRequest))
using (var file = File.Create(@"C:\Temp\Quote.pdf"))
{
    pdfStream.CopyTo(file);
}

Result:

  • The heavy PDF generation happens entirely on the Aspose Cloud server.
  • The SDK only receives a lightweight JSON response, eliminating the OutOfMemoryException.

:books: Useful Documentation Links

Topic Link
Convert Document (Cloud API) https://docs.aspose.cloud/words/convert-document
OutPath Parameter – write output to storage https://apireference.aspose.cloud/words/wordsapi/convertdocument
PDF Save Options (size & performance) https://docs.aspose.cloud/words/pdf-save-options
Downloading files from Aspose Cloud Storage https://docs.aspose.cloud/words/download-file
SDK Upgrade Guide https://docs.aspose.cloud/words/upgrade

:raising_hand_woman: Next Steps / Follow‑up Questions

To fine‑tune the solution, could you please share:

  1. Which SDK language are you using (C#, Java, Python, Node.js, etc.)?
  2. Approximate size of the source .docx and the generated PDF.
  3. Whether the source document is already uploaded to Aspose Cloud Storage or you are sending it as a byte array/stream.
  4. Any specific PDF rendering requirements (e.g., need for exact visual fidelity, high‑resolution images).

With that information we can suggest more precise settings (e.g., page range conversion, image down‑sampling) if you still prefer to receive the PDF as a stream.


Feel free to try the “out‑path” approach and let us know the outcome. We’ll be happy to help you further!

Best regards,
Aspose Support Team

Please share document that causes issue.