An image forming apparatus, comprising: a conveyor to convey a recording medium; a plurality of head units (310a, 310b, 310c, 310d) arranged side by side with certain spacing therebetween in a conveyance direction of the recording medium, the plurality of head units including discharge ports (313a, 313b, 313c, 313d) to discharge droplets on the recording medium; a plurality of edge sensors (312a, 312b, 312c, 312d) arranged in correspondence with at least two sensor-corresponding head units of the plurality of head units (310a, 310b, 310c, 310d), to detect edge positions of the recording medium in a direction perpendicular to the conveyance direction of the recording medium; an actuator (311b, 311c, 311d) to move at least one actuator-driven head unit of the at least two sensor-corresponding head units in the direction perpendicular to the conveyance direction of the recording medium; a memory to store reference values generated in advance based on data on the edge positions of the recording medium read by the plurality of edge sensors (312a, 312b, 312c, 312d); and a controller to control the actuator according to the edge positions of the recording medium read by the plurality of edge sensors (312a, 312b, 312c, 312d) and the reference values to correct a position of the at least one actuator-driven head unit, characterized in that the controller is configured to determine the reference value (r1, r2, r3, r4) of each of the plurality of edge sensors (312a, 312b, 312c, 312d) based on the edge position detected by each of the plurality of edge sensors (312a, 312b, 312, 312d) when the recording medium is stably conveyed. a conveyor to convey a recording medium; a plurality of head units (310a, 310b, 310c, 310d) arranged side by side with certain spacing therebetween in a conveyance direction of the recording medium, the plurality of head units including discharge ports (313a, 313b, 313c, 313d) to discharge droplets on the recording medium; a plurality of edge sensors (312a, 312b, 312c, 312d) arranged in correspondence with at least two sensor-corresponding head units of the plurality of head units (310a, 310b, 310c, 310d), to detect edge positions of the recording medium in a direction perpendicular to the conveyance direction of the recording medium; an actuator (311b, 311c, 311d) to move at least one actuator-driven head unit of the at least two sensor-corresponding head units in the direction perpendicular to the conveyance direction of the recording medium; a memory to store reference values generated in advance based on data on the edge positions of the recording medium read by the plurality of edge sensors (312a, 312b, 312c, 312d); and a controller to control the actuator according to the edge positions of the recording medium read by the plurality of edge sensors (312a, 312b, 312c, 312d) and the reference values to correct a position of the at least one actuator-driven head unit, characterized in that the controller is configured to determine the reference value (r1, r2, r3, r4) of each of the plurality of edge sensors (312a, 312b, 312c, 312d) based on the edge position detected by each of the plurality of edge sensors (312a, 312b, 312, 312d) when the recording medium is stably conveyed.