Background
OpenOffice Writer lacks the ability to link to an ASCII text source file, apply syntax highlighting, wrap it in a frame, and update the frame contents whenever the source file changes. However, OpenOffice Writer can link to images, and will update the images automatically when they change.
Problem
The images need to be high-resolution (300 dpi or greater) with syntax colouring appropriate for a white background (i.e., a printed page).
Question
How can high-quality images be created automatically from source code files, such as:
- SQL;
- PostgreSQL functions;
- Java;
- bash scripts; and
- R and PL/R?
Attempts
Most attempts have been a variation on the following theme:
$ enscript --color -f Courier12 -B -1 --highlight=sql -h -o - source.sql |\
convert - -trim -border 10 source.png
There are a few problems with this approach:
- The resolution is lacking (using
-resample
and-density
offer no improvement). - The syntax highlighting is unsuitable for a white page (can probably change enscript's colour theme).
- Using
Courier100
produces several.png
files, which would need to be stitched together. - The
-border 10
unexpectedly changes the background colour from white to lightgray.
Manual Solution
Converting the source files to PostScript -- avoiding ImageMagick altogether -- and then importing them into The GIMP will produce the desired results. Unfortunately, that solution involves a bit of manual work, and my GIMP batch programming experience is next to nil.
Thank you!