Hello,
I have a PDF file with scanned images in it. I need to export those images for further processing. I've created the following code for testing:
PdfDocumentProcessor pdf = new PdfDocumentProcessor();
pdf.LoadDocument(@"c:\tmp\test.pdf", true);
int i = 0;
for (int p = 0; p < pdf.Document.Pages.Count; p++)
{
var area = new PdfDocumentArea(p + 1, pdf.Document.Pages[p].MediaBox);
foreach (var img in pdf.GetImages(area))
{
img.Save($@"c:\tmp\test{i++}.png", ImageFormat.Png);
}
}
Now when I inspect those images I see that image quality is WAY lower than it appears in PDF document itself. Scans are made in black/white (i.e. 1 bit color depth) whilst on the output I see grayscale with lowered pixel resolution and applied smoothing filter. Is there any way to export images with original quality?
Hello Gosha,
I've passed this issue to our R&D team. Please stay tuned to our updates. We will notify you as soon as we get any results.
Meanwhile, you can try to use the PdfDocumentProcessor.CreateBitmap method to export a PDF page to an image.
Luckily in my context it is OK to have the whole page as an image so that's what I actually did
Okay, Gosha. So, you can use this approach until the behavior is not fixed on our side.
Please feel free to contact us if you have any further difficulties.