PDF Redaction distorts image on Windows Server VM

Hi there,

Using the sample from here: https://products.aspose.com/total/net/redact/:

Aspose.Pdf.Document doc = new Aspose.Pdf.Document(inputPath);
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber("ludford");
TextSearchOptions textSearchOptions = new TextSearchOptions(true);
textFragmentAbsorber.TextSearchOptions = textSearchOptions;
doc.Pages.Accept(textFragmentAbsorber);
TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;

foreach (TextFragment textFragment in textFragmentCollection)
{
    Page page = textFragment.Page;
    Aspose.Pdf.Rectangle annotationRectangle = textFragment.Rectangle;
    Aspose.Pdf.Annotations.RedactionAnnotation annot = new Aspose.Pdf.Annotations.RedactionAnnotation(page, annotationRectangle);
    annot.FillColor = Aspose.Pdf.Color.Black;
    doc.Pages[textFragment.Page.Number].Annotations.Add(annot, true);
    annot.Redact();
}
doc.Save(outputPath);

If you see attached input.pdf and compare both outputs, you’ll see that when running the exact same code on laptop vs. server, the output quality of the pdf is distorted when run on the server (Windows Server 2022 and 2025 both tested).

Using .NET Framework 4.8 (also tried 4.8.1) for C#, latest Aspose.PDF 25.8.

Any assistance is greatly appreciated.

Input.pdf (47.9 KB)

redacted_laptop.pdf (566.1 KB)

redacted_server.pdf (623.7 KB)

@markmanley.adlib

It sounds like you’re experiencing a quality issue with PDF redaction when running your code on a Windows Server VM compared to your laptop. Here’s a structured approach to diagnose and resolve the issue:

Cause: The difference in output quality may stem from various factors, including outdated graphics drivers, environment discrepancies, or specific settings in your PDF processing code.

Solution: Follow these steps to address the issue:

  1. Check Graphics Drivers: Ensure that the graphics drivers on your Windows Server VM are up to date, as outdated drivers can affect rendering quality.

  2. Environment Differences: Compare the environment settings between your laptop and the server, including .NET Framework versions, installed libraries, and any specific configurations that might differ.

  3. Image Quality Settings: Review the image quality settings in your PDF processing code. Explicitly set the resolution or quality parameters when saving the document.

  4. Test with Different PDF Files: Redact different PDF files to determine if the issue is consistent across all documents or specific to certain files.

  5. Update Aspose.PDF: Ensure you are using the latest version of Aspose.PDF. If you are already on the latest version, check the release notes for any known issues or fixes related to redaction.

  6. Logging and Debugging: Implement logging in your code to capture any warnings or errors during the redaction process, which can provide insights into what might be going wrong.

Next Steps: After following these steps, if the issue persists, reach out to Aspose support with detailed information about your environment and the specific differences in output quality.

Please let me know if you need further assistance!

Graphics drivers have no issue or effect using other PDF redaction utilities. Please advise further.

All other steps are N/A.

@markmanley.adlib

If possible, can you please make sure that all Windows fonts are present on the server? You can copy all fonts from your laptop and simply paste them in the Fonts folder on server. In case it does not help, please let us know so that we can further proceed accordingly.

I mean, sure, but why would fonts have anything to do with it?

  • Update: copying fonts did nothing.

If I am just saving the PDF normally without redact, it comes out fine.

Thanks,
Mark

@markmanley.adlib

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-60509

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.