API is throwing exception while saving large size PDF

Hi team.
We use 24.6.0 version in our project and faced with the same issue.
Trying to save file larger than 200MB.
Is it still unresolved?

@Vadym_Ianchenko

Sorry for the delayed response. Could you please share your sample file and the code snippet so that we can test and log a separate dedicated issue for your document?

@asad.ali, the sample file is 250 MB. How can I securely share it with you?

@oleksii88

You can upload it to Google Drive and share the link with us. Also, please share the sample code snippet with us so that we can test the scenario in our environment and address it accordingly.

how can I securely share the link? It is the customer’s file. I can not just post it here.

@oleksii88

We are sending you a private message where you can please share the link and we will proceed accordingly.

Code to replicate the issue with the sample PDF file.

var path = @"quite-large-document.pdf";
using (var pdf = new Aspose.Pdf.Document(path))
{
    pdf.Save(path);
    // or pdf.Save();
}

@oleksii88

We have responded to you in private message. Please check and reply there accordingly so that we can further proceed.

I replied to you in private messages already.

Try now, please.

Use the same link.

@oleksii88

We used above code snippet with 24.9 version of the API and in Windows 11 environment. We could not replicate the issue that you mentioned. Can you please test with the latest version and let us know if it helps in resolving the issue?

I can still replicate the issue.

Attached sample project - AsposeIssueSamples.zip (3.6 KB)

  • Open the project.
  • Specify the path to quite-large-document.pdf in the launchSettings.json.
  • Put a breakpoint in the Mdp15116CliExtensions.RunTest method.
  • Run the project.

Thanks.

@oleksii88

For incremental saving of a document, it is recommended to initialize it using stream like below:

using (var pdf = new Aspose.Pdf.Document(new FileStream(pdfInfo.FullName, FileMode.Open, FileAccess.ReadWrite)))
{
    try
    {
        pdf.Save();
    }
    catch (NotSupportedException ex)
    {
        // Aspose.Pdf 24.9
        //System.NotSupportedException: 'Stream does not support writing.'
        Console.WriteLine(ex);
    }

    try
    {
        pdf.Save(pdfInfo.FullName);
    }
    catch (IOException ex)
    {
        // Aspose.Pdf 24.9
        //System.IO.IOException: 'The process cannot access the file 'quite-large-document.pdf' because it is being used by another process.'
        Console.WriteLine(ex);
    }
}

Please try to use the code like above and share if you still face any issues.