an image forming apparatus according to the present invention , for ejecting liquid from openings to form an image on a printing medium , includes a head cap for covering the opening surface where the opening is open when a liquid ejection head in which the opening is formed are not in use and for protecting the opening from external air , a rechargeable battery for activating the image forming apparatus , a fuel cell for charging the rechargeable battery , and a liquid path along which water generated as the fuel cell is activated is introduced into the head caps . with this arrangement , when the liquid ejection head is not activated , the moisture retention in the head caps can be achieved .