We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

ExportAsImage doesn't work with DPI Settings

Thread ID:

Created:

Updated:

Platform:

Replies:

142082 Jan 17,2019 06:41 PM UTC Jan 18,2019 11:17 AM UTC WPF 1
loading
Tags: PdfViewer
Haikal Khair
Asked On January 17, 2019 06:41 PM UTC

I Have a problem with exporting a PDF to an Image when i set the DPI:

      public static Bitmap ConvertPdfToBitmap(string filepath, int dpi)
        {

            Bitmap bmp = null;

            PdfViewerControl loadedDocument = new PdfViewerControl();
            loadedDocument.Load(filepath);
            bmp = loadedDocument.ExportAsImage(0);
            bmp = loadedDocument.ExportAsImage(0, bmp.HorizontalResolution *2, bmp.VerticalResolution*2) ;

            return bmp;
        }

When i use the DPI settings, the image DPI gets higher but the image itself is nto stretched. White space is added around it, even when I put in an integer like 300,300 it is the same thing.
Is this a bug or am i doing something wrong?

Attachment: 20190117_19_40_31_665a0895.rar

Karthik Krishnaraj [Syncfusion]
Replied On January 18, 2019 11:17 AM UTC

Hi Haikal, 
 
Greetings from Syncfusion, 
 
When i use the DPI settings, the image DPI gets higher but the image itself is nto stretched. White space is added around it 
We were unable to reproduce the issue with “White space added around the exported image”. I have attached a simple sample for your reference below. Can you please modify the sample to replicate the issue? It will be helpful for us to analyze further and provide better solution. 
the image itself is nto stretched 
DPI value is meant to increase the quality of the image. If you want to increase width and height of the image, you can specify the custom size to the image while exporting the PDF document using PDF viewer. Please find the below code snippet. 
 
BitmapSource[] bitmapSource = pdfViewer.ExportAsImage(startIndex, endIndex, new SizeF(900, 900), 300, 300, true); 
 
 
 
API reference link: 
 
We can also export the specific pages of the PDF document as Bitmap sources with respect to DPI. Please find the API reference link below. 
 
We have prepared sample illustrating both the scenario. Kindly try running the sample and let us know whether it helps you. 
 
 
 
Sample link: 
 
Regards, 
Karthik. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;