2X faster development
The ultimate ASP.NET Core UI toolkit to boost your development speed.
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, C# static void Main(string[] args) { PdfiumViewer.FPDF_AddRef(); //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); PdfiumViewer.FPDF_GetDocPermissions(doc); 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); PdfiumViewer.FPDFBitmap_Destroy(createdpages); bitmapImage.UnlockBits(data); bitmapImage.Save("../../../Images/" + "exportedPage11_" + i.ToString() + ".png"); } } Sample link:
Note: 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 Note: Only 16.1.0.24 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.
This page will automatically be redirected to the sign-in page in 10 seconds.
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!