Issue with GetPageImageResolution on image-only PDF file

Discussions about PDF management.
Post Reply
Posts: 6
Joined: Tue Aug 08, 2017 5:09 am

Issue with GetPageImageResolution on image-only PDF file

Post by fervelas » Thu Oct 12, 2017 8:51 am

Hello everyone,

I'm using the latest GdPicture build and my scenario is this:

I load a PDF file into a GdViewer which consists of only a single page with a single image of it, with a resolution of 300dpi, then I draw an area on it so that I may replace it with a filled rectangle. This is the code I use and that is currently working but only the first time:

Code: Select all

float hres = 0, vres = 0;
//get the resolution of the page's image
gdPdf.GetPageImageResolution(0, ref hres, ref vres);
float resolution = hres;
float top = 0, left = 0, width = 0, height = 0;
 imageViewer.GetRectCoordinatesOnDocumentInches(ref left, ref top, ref width, ref height);
 left *= resolution;
 top *= resolution;
 width *= resolution;
 height *= resolution;
int tempImage = gdPdf.ExtractPageImage(1);
MessageBox.Show("drawfilledrect Status: " + gdPicture.DrawFilledRectangle(tempImage, (int)left, (int)top, (int)width, (int)height, Color.White, true).ToString());
string imageRes = gdPdf.GetPageImageResName(0);
MessageBox.Show("ReplaceImage Status: " + gdPdf.ReplaceImage(imageRes, tempImage, false).ToString());
 MessageBox.Show("Release Status: " + gdPicture.ReleaseGdPictureImage(tempImage).ToString());
 MessageBox.Show("Save Status: " + gdPdf.SaveToFile(fileName, true).ToString());
All operations return a status of OK and indeed a white filled rectangle is drawn and the PDF file is saved correctly; however, if I select another area and execute the exact same code, then this time it doesn't work. All operations still return a status of OK, but I've noticed that the following line:

Code: Select all

gdPdf.GetPageImageResolution(0, ref hres, ref vres);
Correctly fetches the image's resolution the first time, but for some reason the second time around it returns a value of 46, so naturally the rest of the operations are incorrectly done. If I close the PDF and open it again then the code works again, but still just one time. For other samples with different resolutions the same thing happens: the first time the resolution is correctly calculated but the second time a lower resolution is reported.

I'd appreciate any thoughts regarding this matter.

Kind regards.

User avatar
Site Admin
Posts: 5524
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Re: Issue with GetPageImageResolution on image-only PDF file

Post by Loïc » Mon Oct 16, 2017 2:14 am


I was not able to reproduce the problem. Could you open a ticket on our helpdesk by providing the input pdf document used and a demo application including the snippet you've provided?

Kind regards,


Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests