Hello,
I get a System.NullReferenceException when I use
PDFRasterizer.Rasterize().
I tried the 2 overloads bellow, they throw the same error.
Is there something wrong with the way I assign the InPtr variable?
Debugging does not bring any relevant info.
PDFDraw.Export works perfectly, but I need to use PDFRasterizer.
Thanks in advance!
PDFDoc existing_doc = new PDFDoc("C:\\InputDoc.pdf");
Page page = existing_doc.GetPage(1);
PDFRasterizer pdfrasterizer = new
PDFRasterizer(PDFRasterizer.Type.e_BuiltIn);
Matrix2D my_matrix = new Matrix2D(1, 0, 0, 1,0, 0);
int height = (int)page.GetPageHeight();
int width = (int)page.GetPageWidth();
int imgsize = height* width;
int[] image= new int[imgsize];
int comps = 4;
int stride = ((width * comps + 3) / 4) * 4;
IntPtr ip = Marshal.AllocCoTaskMem(height * stride);
//getting NullRef here
pdfrasterizer.Rasterize(page, ip, my_matrix *
page.GetDefaultMatrix(true),
new Rect(0, 0, width, height), 72);
pdfrasterizer.Rasterize(page, ip, my_matrix *
page.GetDefaultMatrix(true), null, 0);
Marshal.Copy(ip, image, 0, imgsize);
Marshal.FreeCoTaskMem(ip);
//do something here with the image