Archive for the ‘linux’ Category
Printing to PDF Using CUPS
- Install CUPS-PDF based on your distro, you can download if from here.
- Click this link http://localhost:631 or type it into your browser.
- If the page requested a username and password, just enter your root username and password.
- Go the “Administration” tab and select “Add Printer” in the Printer section.
- For “Add Printer” page, put a name for your virtual PDF printer, any name will do. Then click “Continue”.
- For the second page, that is “Device for a”, you should select “CUPS-PDF (Virtual PDF Driver)”. If it’s not there, then you haven’t execute Step 1 successfully.
- In the 3rd page, choose “Generic” as the Make and then click “Continue”.
- 4th page, choose “Generic CUPS-PDF Printer (en)” as the model and then click “Add Printer”. You’re done, but we need to customize where the file will be located when you printed it.
- Edit /etc/cups/cups-pdf.conf in your favourite editor.
- Put these lines at the end of the file and save it (both can be customized):
1 2 | Out /home/${USER}/Desktop
Label 1 |
- The first line actually tell CUPS to print your file to the Desktop and the second line will make sure your file won’t be overwritten by the newer one.
- Restart your CUPS, for Slackware users, you can type this command /etc/rc.d/rc.cups restart
- So, that’s all and good luck !
Tested on Slackware 12.1, CUPS 1.3.7
Java Printing Fix for Linux with CUPS
Apparently, there’s a bug in Java where people using newer version of CUPS cannot print (can’t even display the print dialog) due to a null pointer exception and this is actually a known bug. So, how do we fix this? For people who use Gnome, you can refer to this page.
However, for people who uses non gui environment such as Fluxbox, Openbox and etc (Gnome and KDE user can use these steps too), you can fix it by editing your CUPS printers configuration file. You can get edit the file at /etc/cups/printers.conf
<DefaultPrinter Printer> # Printer configuration file for CUPS v1.3.7 # Written by cupsd on 2008-09-08 11:24 . . . Option orientation-requested 3 </Printer>
Make sure you add line 7 to every configuration for every printer you’ve installed. If you cannot find the file, you probably haven’t configured any printer yet.
This fix is simply to make sure CUPS will provide a page orientation setting to Java.
The exception:
Caused by: java.lang.NullPointerException: null attribute at sun.print.IPPPrintService.isAttributeValueSupported(IPPPrintService.java:1147) at sun.print.ServiceDialog$OrientationPanel.updateInfo(ServiceDialog.java:2121) at sun.print.ServiceDialog$PageSetupPanel.updateInfo(ServiceDialog.java:1263) at sun.print.ServiceDialog.updatePanels(ServiceDialog.java:437) at sun.print.ServiceDialog.initPrintDialog(ServiceDialog.java:195) at sun.print.ServiceDialog.(ServiceDialog.java:124) at javax.print.ServiceUI.printDialog(ServiceUI.java:188) at sun.print.RasterPrinterJob.printDialog(RasterPrinterJob.java:855) at sun.print.PSPrinterJob.printDialog(PSPrinterJob.java:421)
Refer to some of the discussions here:
UPDATE: I forgot to add, you need to restart your CUPS after editing the configuration (Thanks to Brandon Bell)
Tested on Slackware 12.1, JDK 1.6 Update 7, CUPS 1.3.7