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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to export the PDF document into images in ASP.NET Core using Pdfium rendering engine?

Platform: ASP.NET Core |
Control: PdfViewer

At present we do not have support for EJ1 PDF Viewer in ASP.NET Core. However, you can export pages of the PDF document as images in ASP.NET Core using the Pdfium rendering engine. Find the code snippet for the same below,


static void Main(string[] args)
 //Get the stream of the PDF document
            Stream input = File.OpenRead("../../../Data/HTTP Succinctly.pdf");
            int id = StreamManager.Register(input);
            IntPtr doc = PdfiumViewer.FPDF_LoadCustomDocument(input, null, id);
            PdfiumNative.PdfRenderFlags flags = PdfiumNative.PdfRenderFlags.CorrectFromDpi;
            int pageCount = PdfiumViewer.FPDF_GetPageCount(doc);
            for (var i = 0; i < pageCount; i++)
                double width;
                double height;
    //Get the size of the PDF document page
                int pagesizes = PdfiumViewer.FPDF_GetPageSizeByIndex(doc, i, out width, out height);
                int Width = (int)width;
                int Height = (int)height;
                int rotation = 0;
                IntPtr pages = PdfiumViewer.FPDF_LoadPage(doc, i);
    //Creating new bitmap image
                Bitmap bitmapImage = new Bitmap(Width, Height);
                BitmapData data = bitmapImage.LockBits(new Rectangle(0, 0, Width, Height), ImageLockMode.ReadWrite, bitmapImage.PixelFormat);
                IntPtr createdpages = PdfiumViewer.FPDFBitmap_CreateEx(Width, Height, 4, data.Scan0, bitmapImage.Width * 4);
                uint background = (flags & PdfiumNative.PdfRenderFlags.Transparent) == 0 ? 0xFFFFFFFF : 0x00FFFFFF;
                PdfiumViewer.FPDFBitmap_FillRect(createdpages, 0, 0, Width, Height, background);
                PdfiumViewer.FPDF_RenderPageBitmap(createdpages, pages, 0, 0, Width, Height, rotation, 0);
                bitmapImage.Save("../../../Images/" + "exportedPage11_" + i.ToString() + ".png");

Sample link:



The above sample will work in Windows OS only, the support for Linux and Mac will be included along with the support for PDF viewer in ASP.NET Core.


Follow the below steps to use Pdfium

1. Copy the Pdfium assembly’s folder to a local folder from the installation path. The folder name must be “Pdfium”.
2.The Pdfium assemblies will be available in {$SystemDrive}:\Program Files (x86)\Syncfusion\Essential Studio\{Essential Studio version}\Pdfium



Only and higher versions of Essential Studio release will contain Pdfium assembly folder. The Pdfium folder will contain two folders namely X86 and X64, both would contain pdfium.dll assembly for the respective architecture.






2X faster development

The ultimate ASP.NET Core UI toolkit to boost your development speed.
You must log in to leave a comment
Jordan Capa
Apr 23, 2019

thank you for the easy instructions, now i know how to export pdf document into images. if you're looking for a very fast pdf sdk, i recommend using ZetPDF (zetpdf.com). It's very convenient and helpful!


Please sign in to access our KB

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

Up arrow icon

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

Live Chat Icon For mobile