How to export pdf page as a image using pdfsharp .net library ?

Posted by vi.su. on Stack Overflow See other posts from Stack Overflow or by vi.su.
Published on 2010-06-08T09:03:56Z Indexed on 2010/06/09 5:12 UTC
Read the original article Hit count: 839

Filed under:
|
|
|
|

How to export a pdf page as an image using pdfsharp .net library, for pixel level manipulation ?

for example, something like, System.Drawing.BitMap.GetPixel()

I am trying to find out empty area (all white, or of any colour) inside a pdf document, to write some graphics / image.

09, June 2010:

I have tried this, but it is not working.

why the following code is not working as expected ?

Bitmap.GetPixel always returns 0.

//
// PdfSharp.Pdf.PdfDocument
// PdfSharp.Pdf.PdfPage
// PdfSharp.Drawing.XGraphics
// System.Drawing.Bitmap
//
string srcPDF = @"C:\hcr\test\tmp\file1.pdf";
PdfDocument pdfd = PdfReader.Open(srcPDF);
XGraphics xgfx = XGraphics.FromPdfPage(pdfd.Pages[0]);
Bitmap b = new Bitmap((int) pdfp.Width.Point, (int) pdfp.Height.Point, xgfx.Graphics);

int rgb = b.GetPixel(0, 0).ToArgb();

© Stack Overflow or respective owner

Related posts about .NET

Related posts about image