An image forming apparatus for forming a code pattern image, which
includes position-dependent information differing at every position and
position-independent information in common at various positions, the
image forming apparatus includes: a position-dependent code storage
section that stores a position-dependent code, in which
position-dependent information corresponding to each position is encoded,
or a position-dependent code image, in which a position-dependent code is
expressed as an image code; a code pattern image generator that generates
a code pattern image by combining a position-dependent code image at each
position obtained on the basis of information stored in the
position-dependent code storage section and a position-independent code
image representing position-independent information; and an image forming
section that forms, onto a surface of a medium, the pattern code image
that is generated by the code pattern image generator.