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

Notification

Icon
Error

Options
Go to last post Go to first unread
peterb  
#1 Posted : Tuesday, November 8, 2016 7:31:13 AM(UTC)
peterb

Rank: Newbie

Groups: Registered
Joined: 1/20/2016(UTC)
Posts: 7

I am getting an exception when calling page.render (note that pdf renders fine in chrome browser)

Code:

using (var bmp = new PdfBitmap(width, height, BitmapFormats.FXDIB_8bppRgb, buffer, stride))
{
    bmp.FillRect(0, 0, width, height, Color.White);

    page.Render(bmp, 0, 0, width, height,
         Patagames.Pdf.Enums.PageRotate.Normal,
         Patagames.Pdf.Enums.RenderFlags.FPDF_GRAYSCALE);
                                
    using (FileStream fs = new FileStream("output.png", FileMode.Create))
    {
         bmp.Image.Save(fs, ImageFormat.Png);                                   
    }
}


Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

at Patagames.Pdf.Pdfium.FPDF_RenderPageBitmap_native(IntPtr bitmap, IntPtr page, Int32 start_x, Int32 start_y, Int32 size_x, Int32 size_y, Int32 rotate, Int32 flags)
at Patagames.Pdf.Pdfium.FPDF_RenderPageBitmap(IntPtr bitmap, IntPtr page, Int32 start_x, Int32 start_y, Int32 size_x, Int32 size_y, PageRotate rotate, RenderFlags flags)
at resizePDFimages.Program.makeAllthumbsHT(String pdffile, String savefolder, Int32 height) in E:\UTILS\PARSING_UTILS\C - makethumbs-ALL\Program.cs:line 338


pdf here:
https://drive.google.com...kpaSGN3/view?usp=sharing

Edited by moderator Tuesday, November 8, 2016 3:20:26 PM(UTC)  | Reason: Not specified

Paul Rayman  
#2 Posted : Tuesday, November 8, 2016 3:26:10 PM(UTC)
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 1,138

Thanks: 10 times
Was thanked: 133 time(s) in 130 post(s)
Hi,

I'm guessing the problem due to incorrect values of the buffer and the stride variables.
Are you calculate them correctly?
Code:

int stride = width + (4 - width % 4);
IntPtr buffer = Marshal.AllocHGlobal(stride * height * 1);


Also, please be sure to use the latest version of Pdfium.Net SDK.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.