'How to print into a pdf file a graph generated in xmgrace?

I've a plot in xmgrace which I would like to save separately from the main project as a pdf file. The thing is that when I'm in the print setup selecting the Device there is no pdf option just the usual X11, PostScript, JPE, PNG, etc. Is there some way I can save graphs with a .pdf extension?

Thanks

Device setup for printing in xmgrace



Solution 1:[1]

For reasons unknown to me, some xmgrace pre-compiled binaries don't come with the "print to PDF" option (Ubuntu's binary is one example). In this case you either re-compile xmgrace (enabling the PDF output) or use a combination of commands to generate an eps and then convert it to pdf. This is what I use (with a Linux distro):

f=my_file
base=${f%.*}
LANG= xmgrace -hardcopy -hdevice EPS $f -printfile $base.eps
epstopdf $base.eps --outfile=$base.pdf
rm $base.eps

The LANG= is there to avoid localisation issues (with some locales the comma is used in place of the dot as decimal separator and I don't want that). If you don't have epstopdf installed you can use any other software to do the conversion.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 lr1985