如何使用PDFsharp .NET库将图像导出为图像,用于像素级操作?如何使用PDFsharp .NET库将PDF页面导出为图像?
例如,像,System.Drawing.BitMap.GetPixel()
我试图找出空白区域(全白,或任何颜色的)一个PDF文档中,写一些图形/图片。
09,2010年6月:
我已经试过这一点,但它不工作。
为什么下面的代码不能按预期工作?
Bitmap.GetPixel总是返回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();
难道是'xgfx.Graphics'总是'null'? 'new Bitmap(int,int,Graphics)'方法的描述:“用指定大小和指定Graphics对象的分辨率初始化Bitmap类的新实例。难怪所有像素都返回0,因为这个函数没有(也不能)从Graphics对象中复制任何像素。 – 2015-06-30 08:44:58