Patent ID: 8228549

Claim:
A data processing apparatus for generating an image file including a plurality of pages, the data processing apparatus comprising: an input unit configured to cause a reading apparatus to read a document and input image data corresponding to a part of the document; a first generation unit configured to generate an object that configures a page to be included in an image file based on the image data input by the input unit for each time the image data is input by the input unit; a second generation unit configured to generate file end information for specifying a number of pages of the image file in response to an end of data input performed by the input unit; and a storage control unit configured to store the data in a storage medium in response to generation of data in the first generation unit or the second generation unit, wherein when a capacity for storing the file end information is insufficient in the storage medium before the file end information generated in the second generation unit is stored, the storage control unit returns a writing position to an address in which the file end information can be stored, wherein the file end information indicates the number of images to be displayed, and wherein the file end information generated by the second generation unit indicates the number of images excluding an image that is overwritten due to the return of writing position by the storage control unit.