Page Counter Calculation

Page Counter is decremented more than once for a single page in case physical size of this page exceeds physical size of A4 page.

Physical size (inch2) of your image is calculated as follows:

  • physical size of image = ( PageWidthPixel / HorizontalResolutionDPI ) * ( PageHeightPixel / VerticalResolutionDPI )

The number of pages to decrement is counted with this formula:

  • n is always >= 1
  • n = ~(physical size of image) / (physical size of A4 image), where
  • physical size of A4 image = A4PrintHeightInch * A4PrintWidthInch

As you can see, the number of pages to decrement depends not only on resolution but on a ratio between size in pixels and resolution.

We would like to note that all calculations are done with integer variables, so there are some rounding nuances in favor of our users.


Here is an example to try and make this calculation clearer.

If a page, for example, has the following attributes:

Width = 3660 pixels,
Height = 5163 pixels,
XResolution = YResolution = 300 dpi.

So, physical width of each page is (3660/300) = 12 inch,  physical height of each page is (5163/300) = 17 inch, area of each page is 12*17 = 204 inch2. And the page counter decreases by (204 inch2/97 inch2) = 2 times for this page, because the size of A4 page is (8,27 inches * 11,69 inches = 97 inch2).

After recognition of this one image the page counter decreases by 2.

Code sample (C++)

bool CCommandLineProcessor::checkPageSizeIsTooLarge(CSafePtr <IFRPage> currentPage){
BSTR sourcePage;
const double a4Size = 8.27 * 11.69;
CSafePtr <IImageDocument> imageDoc;
check (currentPage->get_ImageDocument(&imageDoc));
CSafePtr <IImage> bwImage;
check (imageDoc->get_BlackWhiteImage(&bwImage));
int imageWidth, imageHeight, xResolution, yResolution;
check (bwImage->get_Width(&imageWidth));
check (bwImage->get_Height(&imageHeight));
check (bwImage->get_XResolution(&xResolution));
check (bwImage->get_YResolution(&yResolution));
double counters = imageWidth / xResolution * imageHeight / yResolution / a4Size;
int counterRoundedUp = (int) (counters); // in the current version, counter is always rounded down.
if (counterRoundedUp > borderline) {
isTooLarge = true;
check (currentPage->get_SourceImagePath(&sourcePage));
fwprintf(stderr, MSG_LARGE_PAGE_WARNING, sourcePage, counterRoundedUp, borderline);
return true;
return false;

Was this article helpful?

3 out of 3 found this helpful

Have more questions? Submit a request


1 comment

  • Avatar
    Kashyap Shah

    How old is this requirement? Is this changed recently.


Please sign in to leave a comment.

Recently viewed