1. An image forming apparatus comprising: a storage unit that stores therein a a correspondence of a plurality of sheet sizes and an image size printable on each sheet size; an acquiring unit that acquires image data from a host device, the image data including a header section; an extracting unit that extracts an image size of the image data from attribute information in the header section; a searching unit that searches for a sheet size corresponding to the image size based on the stored correspondence and the image size of the image data extracted from the attribute information; a selecting unit that selects, when the searching unit cannot find a sheet size corresponding to the image size, a sheet size that can accommodate the image data when printed; and a printing unit that prints the image data on a print sheet corresponding to the sheet size selected by the selecting unit.