Rank: Member
Groups: Registered
Joined: 5/30/2016(UTC) Posts: 14  Thanks: 4 times
|
Hi, I use pdfium to extract images from PDF pages (among other things) I have this file of 100 something pages. The first 50 pages extract correctly and then suddently the folowing ones are empty. My code is like this : Code:
Int32 dpi = 96;
using (var doc = Patagames.Pdf.Net.PdfDocument.Load(filePath))
{
int i = 0;
foreach (var page in doc.Pages)
{
i++;
int width = (int)(page.Width / 72.0 * dpi);
int height = (int)(page.Height / 72.0 * dpi);
using (var bitmap = new PdfBitmap(width, height, true))
{
bitmap.FillRect(0, 0, width, height, Color.White);
page.Render(bitmap, 0, 0, width, height, Patagames.Pdf.Enums.PageRotate.Normal, Patagames.Pdf.Enums.RenderFlags.FPDF_LCD_TEXT);
bitmap.Image.Save($@"d:\Image{i}.png", ImageFormat.Png);
Console.WriteLine($"Page {i} : {width}x{height} - {MS.Length}");
}
}
}
The width and height for those pages are correctly detected but the output is a blank PNG. From a human point of vue, those pages seems no different than the others. I have tested another extraction API and the images are correctly processed. I can provide the PDF but only via private email as it contains customer information.
|
|
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,138
Thanks: 10 times Was thanked: 133 time(s) in 130 post(s)
|
This issue occurs due to out of memory in your 32 bit environment. You need to add the page.Dispose() statement before ending the foreach() iteration. Code:
foreach (var page in doc.Pages)
{
...
page.Dispose();
}
Edited by user Saturday, October 15, 2016 8:07:12 PM(UTC)
| Reason: Not specified
|
 1 user thanked Paul Rayman for this useful post.
|
|
|
|
Rank: Member
Groups: Registered
Joined: 5/30/2016(UTC) Posts: 14  Thanks: 4 times
|
Originally Posted by: Paul Rayman  This issue occurs due to out of memory in your 32 bit environment. You need to add the page.Dispose() statement before ending the foreach() iteration. Code:
foreach (var page in doc.Pages)
{
...
page.Dispose();
}
Thanks Paul, indeed it does work like that
|
|
|
|
|
|
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.
Important Information:
The Patagames Software Support Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close