fig2pdf
Xfig and Transfig (fig2dev) already produce PDF output, so why does this program, which is less fully functional than fig2dev exist? In practice fig2dev converts to PDF by producing EPS, and then calling ghostscript to convert. This has advantages and disadvantages.
The EPS is generated using jpeg2ps code to embed JPEGs losslessly, but bizarrely PNGs (and similar) are stored in the EPS uncompressed and hex encoded. This is why when one wants EPS output from Xfig, and wishes to include non-JPEG bitmaps, it is a good idea to convert the bitmaps to EPS first oneself, preferably using something of the excellence of bmp2eps.
Early versions of fig2dev let gs re-encode bitmaps at will. JPEGs were decompressed and recompressed with a different quality factor, and losslessly compressed images could end up with lossy "JPEG" encoding. Since 3.2.5 fig2dev passes options to gs so as to encode all images in its output losslessly using flate (zlib) encoding with PNG predictors. This means that JPEGs can be greatly inflated, but no quality is lost.
The code here, written mostly for the amusement of its author, draws on bmp2eps to embed JPEGs in its PDF output unchanged, and to recompress everything else losslessly. As it writes PDF directly, the output is arguably cleaner and more likely to be acceptable to PDF editors. Each XFig object becomes one (or more) PDF objects.
The list of things which fig2pdf cannot do is quite long. However, to dwell on its successes, there follows a screenshot of Xfig displaying the image used to test fig2pdf:
The Xfig source for this image, and the PDF which fig2pdf produces.
I regard this code as being an alpha-quality demonstration which I hope will inspire someone else to rewrite it properly. Are you really sure you want it? If you must, try fig2pdf.tar.gz and be aware that the README states:
Supported --------- Polylines, ellipses, arcs, boxes, boxes with rounded corners. Text, left right and centre justified. Depths. Rotations. User defined colours. Fills with colours, including intensity. Fonts from the "PDF 14" set (Times x 4, Courier x 4, Helvetica x 4, Symbol, Zapf Dingbats) Including pictures which are jpeg, png, gif, pcx, pnm, pgm, pbm. LaTeX specials via pdflatex EPS pictures via gs Partially supported ------------------- Approximated and interpolated splines -- a rather poor approximation is used. Including pictures which are pdf Embedding fonts. Not yet supported (but might be if there is demand) ----------------- Fill patterns. A better approximation for splines. Extremely unlikely ever to be supported ---------------------------------------- X-splines. End notes --------- This code is pretty buggy, and I make no claim that it is fit for any purpose. Someone might find it useful, so here it is. Licence: GPL v2.
The version above, 0.14a, was last updated in April 2024. The previous version downloadable from this page was 0.12e (of February 2015). Changes since then:
Remove .setpdfwrite from gs input, so support gs>=9.54 Tidy code to eliminate compiler warnings Include PCX support Include progressive JPEG support Do not require libpng for reading PNGs Support right and centre aligned text Improve boundingbox with splines Fiddle boundingbox to allow for text with descenders