A printer that restarts printing from a desired print position after an emergency stop is provided. A printer according to the present disclosure includes a head printing on a work, a driving motor moving at least one of the head and the work in order to change a print position on the work, a rotary encoder and an encoder counter determining a position of the head relative to the work, a control device supplying electric power to the encoder after excitation of the driving motor is turned off during printing and enabling the encoder counter to continue counting.