Sunday, October 25, 2009

Exporting High-Res Graphics from Excel

I've recently been battling with technology, trying to save some Excel charts as high-res (900 dpi) files.
Here's the technique I finally came up with.  (It also works for PowerPoint slides).:
1. Save the chart as a PDF from Office (The PDF output is vector-based, so is very high quality)
2. Use a command line line, this, to use Ghostscript to convert the PDF to a suitable tiff file.  (In my case, I want the final images to be 4 inches wide, at 900 dpi, but here I have specified an output size of 5 inches (72 * 5 = 360), then I'll crop the images back to 4in in the next step.)
gswin32c -dSAFER -dBATCH -dNOPAUSE -sFONTPATH="E:\windows\fonts" -sDEVICE=tiffgray -r900 -dDEVICEWIDTHPOINTS=360 -dDEVICEHEIGHTPOINTS=221 -dPDFFitPage -sOutputFile=%~n1.tiff %1

Key parameters are -dPDFFitPage, to cause resizing when using PDFs ans input, the DEVICExPOINTS to set the size of the output in points (1/72 ths of an inch), and -r to set the DPI.
3. Finally, open the tiff in Photoshop (or similar) to crop and make any other final adjustments, then save from Photoshop.