|
|
You can render page with grayscale flag into 8bpp indexed bitmap. Somthig like this: Code:
using (var doc = PdfDocument.Load(@"document.pdf"))
{
var page = doc.Pages[0];
int width = (int)page.Width;
int height = (int)page.Height;
int stride = width + (4 - width % 4);
IntPtr buffer = Marshal.AllocHGlobal(stride * height * 1);
using (var bmp = new PdfBitmap(width, height, BitmapFormats.FXDIB_8bppRgb, buffer, stride))
{
bmp.FillRect(0, 0, (int)width, (int)height, Color.White);
page.Render(bmp, 0, 0, width, height, PageRotate.Normal, RenderFlags.FPDF_GRAYSCALE);
bmp.Image.Save(@"document.png", ImageFormat.Png);
}
}
|
|
|
Previously I created png using ghostscript (pnggray argument), a 1679x2609 greyscale png - size is about 88 KB. Using pdfium, how would I get something comparable in size?
right now it is coming out rgb and about 700-800 KB.
|
Important Information:
The Patagames Software Support Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close