Low quality on converting PDF to PNG

Hello,

I’m looking for the tool to convert PDF Drawings to PNG with a suitable quality.

Unfortunately, even the simple staright black line in PDF is converted to the gray or to the double black and gray lines.

Here is the code I used:

public override void Convert(string pathToPdf, int pageNumber = 1)
{
Document doc = new Document(pathToPdf);
var res = new Resolution(600);
PngDevice pngDevice =
new PngDevice(res);
pngDevice.Process(doc.Pages[pageNumber], pathToPdf + “.png”);
}

I have tried with the different combination of the resolution and RenderingOptions but still didn’t get the required quality.
Can you please advise if Aspose.PDF can provide the better quality?

In the attqachment there is a sample PDF and resulted PNG.

sample_drawings.pdf (225.9 KB)

sample_drawings_1_.png (1.2 MB)

Thanks.

@vchekalin

We really apologize for the inconvenience. We were also able to notice this issue at our end when we tested this case using Aspose.PDF for .NET 21.3. Therefore, we have logged it as PDFNET-49697 in our issue management system for the sake of correction. We will surely investigate this issue and work on improving the output image quality. You will be notified once the logged ticket is resolved. Please be patient and give us some time.

We apologize for the inconvenience.

Hi,

Thank you for your response. Can you please clarify, is this problem only in one of the latest version or in the early versions there was the same behavior? Can I try with the previous version?

I like how does Aspose.PDF component work and really would like to use it in our solution, but need to understand can Aspose.PDF provides the required quality or search another solution.

Just to make sure we are on the same page, I attached zoomed area of the origin pdf and resulted png.
png.png (34.0 KB)
pdf.png (30.0 KB)

Thanks,
Victor.

Here is also the png I got using another product which I cannot use for some reasons. I expect the similar quiality.
btw, can Aspose.Pdf manage the Bit depth parameter on conversion?
https://1drv.ms/u/s!Ag1Lr0XJCbXPthoUm0W2QiDcqCW8?e=fNZUNV
Attach as a link as the file has too high resolution and forum doesn’t allow attach it.

@vchekalin

We have tested using earlier versions of the API as well and noticed the same quality issue. Therefore, the ticket is logged for further investigation and has been updated as well as per your provided information.

Furthermore, if you want to preserve quality and specify bit depth, you can try generating TIFF from the PDF which will allow you generating TIFF with 32-bit depth and desired resolution. Following is the sample code snippet:

var pdfDocument = new Aspose.Pdf.Document(dataDir + "sample_drawings.pdf");
Aspose.Pdf.Devices.Resolution resolution = new Aspose.Pdf.Devices.Resolution(300);
Aspose.Pdf.Devices.TiffSettings tiffSettings = new Aspose.Pdf.Devices.TiffSettings();
tiffSettings.Compression = Aspose.Pdf.Devices.CompressionType.None;
tiffSettings.Depth = Aspose.Pdf.Devices.ColorDepth.Default;
tiffSettings.Shape = ShapeType.Portrait;
tiffSettings.SkipBlankPages = false;
//tiffSettings.Brightness = (float)0.1;
Aspose.Pdf.Devices.TiffDevice tiffDevice = new Aspose.Pdf.Devices.TiffDevice(resolution, tiffSettings);
tiffDevice.Process(pdfDocument, dataDir + "test.tif");