logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Post a reply
From:
Message:

Maximum number of characters in each post is: 32767
Bold Italic Underline   Highlight Quote Choose Language for Syntax Highlighting Insert Image Insert an existing Attachment or upload a new File... Create Link   Unordered List Ordered List   Left Justify Center Justify Right Justify   Outdent Indent   More BBCode Tags
Font Color Font Size
Security Image:
Enter The Letters From The Security Image:
  Preview Post Cancel

Last 10 Posts (In reverse order)
Paul Rayman Posted: Thursday, January 21, 2016 5:40:03 AM(UTC)
 
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);
	}
}
peterb Posted: Wednesday, January 20, 2016 10:45:55 AM(UTC)
 
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.