Is the 2007 iMac currently bootable and operating?
If not, do you have access to another Mac?
Everymac.com says the pre-installed OS that came with the 2007 iMac was 10.4.10 "Tiger". It can run up to OS 10.11 "El Capitan".
One alternative might be to look on ebay (or elsewhere) for a 10.6 "Snow Leopard" universal install DVD. Snow Leopard was one of Apple's best OS releases.
For a long time, Apple still sold Snow Leopard as a DVD -- not sure if they still do.
If you want to "go as far as El Capitan", there are may not be DVDs for that.
Instead, you will have to create (or buy) a bootable USB flash drive. Then you can boot from the flashdrive and do the OS install that way.
You can download El Cap directly from Apple:
Download and install current or previous versions of the Mac operating system on compatible Mac computers.
support.apple.com
You'll need a USB flashdrive, 16gb or larger.
You'll also need a utility app to create the bootable installer. Two that I know of:
- Install Disk Creator
- DiskMaker X
Both are FREE. Be sure to download the right version for the OS you will be using.
Another tip:
Sometimes, installing from a bootable flashdrive won't go through. A "fix" for that is to "set back" the Mac's internal clock to a date in, say, 2018. Then try again.