Using Document.Save automatically redacts text it should not

Aspose Version: 24.4.0

One thing I thought would be important to note is that this did not happen back in version 21. When I was forced to upgrade to the most recent version is when this became a problem.

Attempting to using PdfDocument.Save() is automatically redacting text that it should not be.

Here is the code that is being used

public async Task SaveEachPageOut(CompileAttachment compileAttachment, bool isScanned = false)
{
    var fileExt = Path.GetExtension(compileAttachment.OriginalAzurePath).ToLower();
    var filePath = Path.Combine(_attachmentPath, $"Temp{fileExt}");

    //If the file is originally a Docx it processes much faster
    //then a PDF so no need to save out each page.
    try
    {
        if (fileExt.ToLower() == ".docx" || fileExt.ToLower() == ".doc")
        {
            await _azureProvider.DownloadToFileAsync(compileAttachment.OriginalAzurePath, filePath);

            var document = new Aspose.Words.Document(filePath);

            for (var i = 0; i < document.PageCount; i++)
            {
                var docxFilePath = Path.Combine(_attachmentPath, $"{i + 1}.docx");
                var extractedPage = document.ExtractPages(i, 1);
                extractedPage.Save(docxFilePath);
            }

            document = null;
        }
        else
        {
            filePath = fileExt != ".pdf" ? filePath.Replace(fileExt, ".pdf") : filePath;
            await _azureProvider.DownloadToFileAsync(compileAttachment.AzurePdfPath, filePath);

            if (isScanned)
            {
                ConvertScannedDocument(filePath);
            }

            var document = new Aspose.Pdf.Document(filePath);

            try
            {
                document.Repair();
                document.Flatten(new Aspose.Pdf.Forms.Form.FlattenSettings { ApplyRedactions = false, UpdateAppearances = true });
            }
            catch (Exception repairAndFlattenException)
            {
                var logManagerModel = new LogManagerModel
                {
                    Exception = repairAndFlattenException,
                    ExceptionData = new Dictionary<string, string>()
                {
                    { "Message", $"Failed to repair and/or flatten PDF (this is usually because it is already flattened) this will not cause any problems. Continuing to process document." },
                    { "ClassName", $"BaseCompiler" },
                    { "MethodName", $"SaveEachPageOut" },
                    { "StackTrace", $"{Environment.StackTrace}" }
                }
                };
                _customerCallContext.LogManager.Error(logManagerModel);
            }
            finally
            {
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }

            //Save attachment pages into Attachment ID Folder
            foreach (var page in document.Pages)
            {
                var pdfFilePath = Path.Combine(_attachmentPath, $"{page.Number}.pdf");
                var newDocument = new Aspose.Pdf.Document();
                newDocument.Pages.Add(page);
                newDocument.Save(pdfFilePath);
                newDocument.FreeMemory();
                newDocument.Dispose();
            }

            document.FreeMemory();
            document.Dispose();
            document = null;
        }
    }
    catch (Exception ex)
    {
        File.Delete(filePath);

        GC.Collect();
        GC.WaitForPendingFinalizers();

        throw;
    }
    finally
    {
        File.Delete(filePath);

        GC.Collect();
        GC.WaitForPendingFinalizers();
    }
}

Here is the file before it becomes redacted
Blacked out OKC - DC-0310 WC-1018 Amendment No 4.pdf (420.6 KB)

Here is the file after it is saved out and you will notice on the last page it is being redacted.
Temp.pdf (413.4 KB)

@ST2YKE2

It is quite possible that the issue is related to this specific kind of PDF document. Nevertheless, we will surely investigate it and address it accordingly.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-57097

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

We are sorry for the inconvenience.

@asad.ali

If there is any type of workaround please advise. We have found SEVERAL bugs in Aspose that are huge hindrances to our customer base.

I have enjoyed using Aspose for the most part and I have created workarounds for most of the other issues but at this point my company is asking me to investigate other alternative solutions. Some additional feedback your support costs are WAY WAY to high. You have to find a middle ground because you are beginning to alienate your customer base especially given the lack of options to get assistance or viable options to continue providing the best experience possible to our customers.

Please Advise, thank you.

@ST2YKE2

The issue looks related to this specific type of PDF document and we are afraid that we cannot offer any workaround at the moment without investigating the cause of this issue. We will prioritize the logged ticket on a first come first serve basis and as soon as we have some updates, we will share with you. Please spare us some time.

We apologize for the inconvenience.

@asad.ali
I now have paid support is there a way I can attach this account to my paid support account?

@ST2YKE2

If you have subscription to paid support, you will be able to login into paid support forum using same email address that was used to purchase the support. Please create a topic there with the reference to the ticket ID logged in this forum thread and your issue will be escalated to the highest priority.

The issues you have found earlier (filed as PDFNET-57097) have been fixed in Aspose.PDF for .NET 24.6.