1. An image forming apparatus comprising: a conveyance unit configured to convey a recording medium in a predetermined direction; a processing unit configured to generate dot data for forming an image to be printed on the recording medium based on acquired image data; and a detection unit configured to detect a side end position of the recording medium conveyed by the conveyance unit, wherein the processing unit is configured to enlarge the image to be printed on the recording medium such that a portion of the enlarged image protruding into a predetermined margin region at a side end of the recording medium, convert the image data of the enlarged image into dot data, and, process the dot data to trim dot about the portion of the enlarged image protruding into the set margin region so that the portion of the enlarged image protruding into the predetermined margin region is not to be printed on the recording medium, and wherein the processing unit is configured to determine a trimming portion for processing the dot data to trim dot based on the side end position of the recording medium being conveyed by the conveyance unit, detected by the detection unit, and the length of the predetermined margin region in a crossing direction cross to the predetermined direction.