Ack! This site is moving to tomhorsley.com since Comcast's efforts to improve their world's worst customer service ranking apparently include terminating web hosting for their existing customers.
This is the story of the ongoing quest [forget the quest, take me to the results] to tweak the .ppd file for my HP Photosmart C5580 All-in-One device so that any linux application (with sufficient printing support) will be able to easily print to inkjet printable DVD/CD media.
Certainly you can print to DVDs by carefully setting up templates and printing with the exact correct offsets to match what the printer hardware actually does, but that is a painstaking process (I know, because I did it for inkscape and gimp as you will see below :-). It would be ever so much simpler to just print the image in the center of a DVD media sized page, and have it magically come out in the exact correct spot because the painstaking offsets and adjustments are built into the printer definition file.
The first step was to verify that different applications print with the same incorrect alignment. Only if they already make the same errors can I hope for one fix to the .ppd file to fix them all. That involved defining different page size, and printing from different applications over and over again. So as not to use up too many disks during this process, I just used one and printed in different colors and patterns after rotating the disk. That eventually got me this mess:
During the production of that mess, I did discover many things:
I discovered that some advice I got from Richard Shaw to make a copy of the printer and in the copy, set the default page size to DVD120 and paper tray to DVD holder was really good advice. All I was ever able to do without that was confuse the printer. Now I can print to my new printer named C550-DVD (as opposed to the original one named Photosmart-C5500-series) and there is no question about it printing to the DVD.
I discovered that a page size of 360 points (where 1 inch is 72 points) seemed to be the only size that was safe to print (the existing .ppd file does say the page size for 120mm DVD media is 360 points, so it makes sense that 360 would be the size to use). Some page sizes I tried (especially non square ones) had me cleaning printer ink off the DVD holder.
I discovered that all the attempts I made to fiddle with any of the numbers in the .ppd file also left me cleaning ink off the DVD holder (or left the printer refusing to print).
I discovered that in gimp it is vitally important to use the Page Setup menu to define a custom page size of 360 points square with no margins before you try to print an image of that size.
I discovered that Open Office Writer is apparently unable to define a custom page size. Every other application I tried printed consistent results, but Open Office was always off by different amounts. I finally poked around in the Open Office support forums and found lots of complaints about custom page sizes not working for folks trying to print non standard envelopes, so I guess Open Office is just a hopeless case.
On the plus side, I discovered that the scanner support in hplip works so well, I didn't have to do anything to setup the scanner (it just worked as soon as I plugged it in — as did the printer — you could have knocked me over with a feather), and the scanner was very handy. I could pop the printed DVD into the scanner, and use the measuring tool in gimp to pick off coordinates and see how far out of alignment I was. [Aside: Since Bill Gates introduced the new Plug & Play technology by famously blue screening the new Windows 98 operating system when plugging in a scanner, I have never once had any so-called Plug & Play device more complicated than a thumb drive just work by plugging it in. I was stunned when that finally happened for my new C5580 All-In-One: January of 2009 and a Plug & Play device actually plugged and played, and it was on Fedora 10 Linux, not Windows. It only took a little more than a decade for it to happen.]
OK, so the attempts to change the .ppd by blindly poking the unintelligible gibberish with a stick didn't happen to work. I might as well go ahead and build a file in inkscape with circles positioned at just the right offset inside a 360 point square to print the outer and inner edges of the printable DVD surface. Knowing the position I need the center to be at is bound to be of use if I ever figure out how to get the image shifting to be automatic.
The old disk was getting kinda cluttered and I wanted a clean set of measurements for positioning my circles correctly, so I wound up wasting a second disk:
While slowly increasing the diameter of the outer circle, I noticed that a flat spot shows up. Apparently at the edge nearest the center of the DVD holder, the print heads cannot go all the way to the edge of the white DVD printable surface. Not wanting flat spots, I decided to make the outer diameter of the outer circle be just inside the flat area, so all my disks using these borders will have a white outer ring, but won't have any flat spots.
That led to the following .svg file produced in inkscape:
Note that if you open this in inkscape (or your browser), you won't see anything unless you do something like turn on outline mode. The background is normally white in inkscape, and the inner and outer circles are while in this .svg file, but the important point is that they are positioned on a 360 point square page so that they mark the outer and inner edges of the printable surface of the DVD media.
The y coordinate of the center is 191.53 points and the x coordinate of the center is 173.274 points. (Using the inkscape coordinate system where zero is at bottom left of page on the screen and x grows right and y grows up).
Note that I have no idea how much variation there is between individual printers, but this certainly positions the circles just right for my printer.
This file was produced with inkscape, but you can also open it with gimp. When you do, you'll need to tell it the dimensions are 360 points for width and height and that the dots per inch should be 300 (the native printer dots per inch). For some reason this never works for me the first time, so I always have to close the image and open it again and on the 2nd try all my .svg parameters get accepted. (I added gimp bugzilla 570353 for this problem). I did discover that if I leave the units as points and tell it 1500, then I can open the file on the 1st try.
For use with gimp I made a couple of separate files starting with the .svg file. In one I filled the donut between the circles with white. This is good for a bottom layer showing what areas are actually printable. I also created an inverse copy with transparent pixels in that donut and white in the non-printable areas. This is good for a top layer to clip off and hide anything sticking out beyond the edge of the printable media.
To print this, I had to add a custom Page Setup defining a page 360 points on a side with zero for all margins that prints in portrait mode (even though the page is square, portrait mode is important because the circle isn't in the center of the page).
Using those layers and fiddling with other images I had around led me to my first custom printed DVD for The Guide To Babylon 5 I recorded off TNT TV a few years ago:
So printing works well with manual alignment, but I'd still like to build the alignment into the .ppd file. I know it is possible because I've done it for more ordinary printers, but the technique using the alignmargins perl script doesn't really work when there are no corners to point at :-).
The alignmargins script winds up generating a postscript fragment that stashes a couple of definitions in the setpagedevice dictionary for /.HWMargins and /Margins. Who does what with those numbers later in the print process is not documented in any google searches I've managed to come up with (though I'd guess it is probably is the ghostscript printer drivers using the information), so I guess I'll have to experiment with changing the numbers and see what happens to the printouts for ordinary printing, then I can perhaps deduce what I might need to do to achieve the desired shift for DVD printing.
AAUGH! The more things improve, the worse things get. Recent versions of gimp have lost the ability to print a custom page size at all, so printing from gimp became impossible. That led to my writing the qp program, a simple Qt program (to avoid any print problems that seem to be in gtk) to print my image files. (This is a preliminary version with many menu items not yet implemented, put print setup and print are working, as well as load image, so the minimum necessary items to print do work). See redhat bug 496512. I include the full sized B5 DVD image I printed for my first DVD and I was also able to print it using qp by picking the photosmart printer, setting all page sizes available to 120mm DVD and margins to 0 on all sides.
Double AAUGH! In fedora 11, the latest version of the hplip and hpijs software can't talk to the DVD try at all. Looks like I'll have to boot f10 if I want to print DVDs, even with my qp program. See hplip bug 63943 and redhat bug 495672.
The quest continues...
I've visited lots of places and started lots of threads and bug reports in various lists and forums (but no useful answers as of this writing, and if the bugs keep getting worse, setting the margins right will be the least of my problems :-).