A printer comprises: an inkjet head including nozzles for discharging ink; a holding member which holds a print medium; a moving mechanism which moves the holding member and/or the inkjet head so as to move the inkjet head relative to the holding member in a main scanning direction and a sub scanning direction for printing by the inkjet head on the print medium; and a print control unit which controls the inkjet head and the moving mechanism so as to execute flushing printing on the print medium for preventing clogging of the nozzles while moving the inkjet head relative to the holding member in a first printing direction in the main scanning direction and to execute pattern printing on the print medium according to pattern printing data while moving the inkjet head relative to the holding member in a second printing direction in the main scanning direction.