Bug Report T298118
Visible to All Users

Usability - There is no way to specify DPI when getting images from a document

created 9 years ago

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?

Comments (3)
Maria Nikulina (DevExpress) 9 years ago

    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

      Maria Nikulina (DevExpress) 9 years ago

        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.

        Answers approved by DevExpress Support

        created 9 years ago

        We have fixed the issue described in this ticket and will include the fix in our next maintenance update. To apply this solution before the official update, request a hotfix by clicking the corresponding link for product versions you require.

        Note: Hotfixes may be unavailable for beta versions and updates that are about to be released.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.