An image forming apparatus includes an area setting unit, a reading unit, a number recognizing unit, and a number determining unit. The area setting unit is configured to set a reading area on the basis of a page number. The reading unit is configured to read image data in the reading area. The number recognizing unit configured to recognize a number from a result of reading by the reading unit. The number determining unit is configured to compare results of recognizing of two consecutive pages by the number recognizing unit, determine the presence of consecutive numbers, and determine one of the consecutive numbers as the page number.