Print PDF from any Linux program

The CUPS PDF program saves printed PDFs to the ~/PDF directory from any program.

apt install cups-pdf

The output directory can be configured by editing the “Out” directory in /etc/cups/cups-pdf.conf

Matlab/GNU Octave figure save PDF

  • if you already have Matlab open, just restart Matlab to make the PDF printer available.
  • Workaround for Java bug stopping Matlab from printing in color–this will create a color PDF test.pdf in your current directory.
    imagesc(rand(10))
    
    print(gcf,'-dpdf','test.pdf')
    

Matplotlib figure save PDF

This can be accomplished by either

  • save to PDF from the Matplotlib figure GUI
  • use figure.savefig() to save to PDF from Matplotlib. Example:
    from matplotlib.pyplot import figure
    
    fg = figure()
    ax = fg.gca()
    ax.plot(range(10))
    
    fg.savefig('line.pdf',bbox_inches='tight',dpi=300)
    

Leave a Comment