How to increase the image quality on using Pdfium

3

I have extracted the pdf page as an image by using the below code snippet,but on changing the size of the bitmap the text content in the image is not sharp, it is blurry Can you suggest a solution for improving the quality of the rendered image.

var data = bitmapImage.LockBits(
     new Rectangle(0, 0, Width, Height), 
     ImageLockMode.ReadWrite, 
     bitmapImage.PixelFormat
);

int bytes = Math.Abs(data.Stride) * bitmapImage.Height;

var createdpages = PdfiumViewer.FPDFBitmap_CreateEx(
       Width, 
       Height, 
       4, 
       data.Scan0, 
       bitmapImage.Width * 4
);

PdfiumViewer.FPDFBitmap_FillRect(
     createdpages, 0, 0, 
     Width, 
     Height, 
     0xFFFFFFFF 
);

PdfiumViewer.FPDF_RenderPageBitmap(
     createdpages, 
     pages, 0, 0, 
     Width, 
     Height, 0, 0
);

Kindly provide a solution for rendering the image with shapness

c#
pdfium
asked on Stack Overflow Dec 19, 2017 by Mohan Selvaraj • edited Dec 19, 2017 by Matheus Cuba

1 Answer

0

pdfium renders the page at 300 dpi. If the image is blurry, it's most likely the image in the pdf has low dpi.

You could try reducing the height and width of the output to make the image less blurry, to reduce the amount of zooming to fit the small image in the rendered bitmap.

answered on Stack Overflow Apr 9, 2019 by codeDr • edited Apr 9, 2019 by codeDr

User contributions licensed under CC BY-SA 3.0