Converting certain PDF to HTML/PNG produces some artifacts in .NET

Converting the attached PDF with the latest GroupDocs.Viewer to HTML or PNG produces some strange artifacts (see screenshot)
image.png (61.8 KB)

It’s most noticeable for PNG.
The problem here, is how small dots are combined when “zooming out” / lowering the resolution.
When printed, it would look like a gray background (in the original).
So ideally, this would also work in GroupDocs, that multiple small dots, will appear gray?

PDF dots are too big.zip (223.7 KB)

@Clemens_Pestuka

I have reproduced this issue. Can you please confirm that your application is targeting .NET Framework?

To improve rendering to HTML you can use enable WrapImagesInSvg. See output in WrapImagesInSvg.zip (291.7 KB)

HtmlViewOptions viewOptions = HtmlViewOptions.ForEmbeddedResources();
viewOptions.PdfOptions.WrapImagesInSvg = true;

When rendering to PNG you can also try enabling RenderOriginalPageSize and get better output quality but dots are disappearing in this case see RenderOriginalPageSize.png (26.4 KB)

PngViewOptions viewOptions = new PngViewOptions();
viewOptions.PdfOptions.RenderOriginalPageSize = true;

In case of rendering to PNG we’ll investigate this issue and update you when it will be fixed.

Issue ID for reference i VIEWERNET-4826.

1 Like

@vladimir.litvinchik

Yes we’re using .NET Framework still.
Thanks a lot for the suggested fix, I can confirm that this greatly improves both outputs.
The HTML output is pretty much spot-on. :+1:
Do you know if this has any performance implications, as it “wraps images in to SVG” now?
Same question for Rending in original page size?

@Clemens_Pestuka

There are no noticeable performance implications to render with WrapImagesInSvg

Method Mean Error StdDev Gen0 Gen1 Allocated
WrapImagesInSvgFalse 532.8 ms 259.0 ms 14.20 ms 11000.0000 1000.0000 70.79 MB
WrapImagesInSvgTrue 526.8 ms 909.5 ms 49.85 ms 11000.0000 1000.0000 72.05 MB

RenderOriginalPageSize was a bit faster:

Method Mean Error StdDev Gen0 Gen1 Gen2 Allocated
DefaultRendering 122.40 ms 48.70 ms 2.670 ms 3000.0000 1000.0000 500.0000 18.59 MB
WrapImagesInSvg 83.82 ms 25.43 ms 1.394 ms 2857.1429 1000.0000 285.7143 18.16 MB

I was testing the attached file but the results may differ for files with different content.

1 Like

@vladimir.litvinchik

Thank you so much for testing :smiley:
I will add both options to our code then. :+1:

@Clemens_Pestuka

You’re welcome!

1 Like