Print Jpanel (linux?)

I'm trying to print a JPanel and use the following code which should work. When I try to print I get the following error "no print service found".
Through google I've found other people having the same problem printing from java applications in linux. Does anybody have any ideas/fixes?
Cheers,
Ally
Used to print a component:
public class PrintUtilities implements Printable {
private Component componentToBePrinted;
public static void printComponent(Component c) {
new PrintUtilities(c).print();
public PrintUtilities(Component componentToBePrinted) {
this.componentToBePrinted = componentToBePrinted;
public void print() {
PrinterJob printJob = PrinterJob.getPrinterJob();
printJob.setPrintable(this);
if (printJob.printDialog())
try {
printJob.print();
} catch(PrinterException pe) {
System.out.println("Error printing: " + pe);
public int print(Graphics g, PageFormat pageFormat, int pageIndex) {
if (pageIndex > 0) {
return(NO_SUCH_PAGE);
} else {
Graphics2D g2d = (Graphics2D)g;
g2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
disableDoubleBuffering(componentToBePrinted);
componentToBePrinted.paint(g2d);
enableDoubleBuffering(componentToBePrinted);
return(PAGE_EXISTS);
/** The speed and quality of printing suffers dramatically if
* any of the containers have double buffering turned on.
* So this turns if off globally.
* @see enableDoubleBuffering
public static void disableDoubleBuffering(Component c) {
RepaintManager currentManager = RepaintManager.currentManager(c);
currentManager.setDoubleBufferingEnabled(false);
/** Re-enables double buffering globally. */
public static void enableDoubleBuffering(Component c) {
RepaintManager currentManager = RepaintManager.currentManager(c);
currentManager.setDoubleBufferingEnabled(true);

Ally: I have a little print test demo I just did. Try it and see if that works in your linux environment.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import com.cpm.common.utilities.*;
import java.awt.print.*;
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
* Applet
* <P>
* @author *
public class CPrinterTest extends JApplet {
   boolean isStandalone = false;
//   JPanel jPanel1 = new JPanel();
   MyPanel jPanel1 = new MyPanel();
   JCheckBox jCheckBox1 = new JCheckBox();
   JEditorPane jEditorPane1 = new JEditorPane();
   JList jList1 = new JList();
   JLabel jLabel1 = new JLabel();
   JButton jButton1 = new JButton();
    * Constructs a new instance.
    * getParameter
    * @param key
    * @param def
    * @return java.lang.String
   public String getParameter(String key, String def) {
      if (isStandalone) {
         return System.getProperty(key, def);
      if (getParameter(key) != null) {
         return getParameter(key);
      return def;
   public CPrinterTest() {
    * Initializes the state of this instance.
    * init
   public void init() {
      try  {
         jbInit();
      catch (Exception e) {
         e.printStackTrace();
   private void jbInit() throws Exception {
      this.setSize(new Dimension(400, 400));
      jCheckBox1.setText("jCheckBox1");
      jCheckBox1.setBounds(new Rectangle(205, 34, 90, 25));
      jEditorPane1.setText("jEditorPane1");
      jEditorPane1.setBounds(new Rectangle(123, 104, 152, 151));
      jList1.setBounds(new Rectangle(55, 25, 79, 37));
      jLabel1.setText("jLabel1");
      jLabel1.setBounds(new Rectangle(161, 285, 98, 17));
      jButton1.setText("jButton1");
      jButton1.setBounds(new Rectangle(160, 330, 79, 27));
      jButton1.addActionListener(new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
            jButton1_actionPerformed(e);
      jPanel1.setLayout(null);
      this.getContentPane().add(jPanel1, BorderLayout.CENTER);
      jPanel1.add(jCheckBox1, null);
      jPanel1.add(jEditorPane1, null);
      jPanel1.add(jList1, null);
      jPanel1.add(jLabel1, null);
      jPanel1.add(jButton1, null);
    * start
   public void start() {
    * stop
   public void stop() {
    * destroy
   public void destroy() {
    * getAppletInfo
    * @return java.lang.String
   public String getAppletInfo() {
      return "Applet Information";
    * getParameterInfo
    * @return java.lang.String[][]
   public String[][] getParameterInfo() {
      return null;
    * main
    * @param args
   public static void main(String[] args) {
      CPrinterTest applet = new CPrinterTest();
      applet.isStandalone = true;
      JFrame frame = new JFrame();
      frame.setTitle("Applet Frame");
      frame.getContentPane().add(applet, BorderLayout.CENTER);
      applet.init();
      applet.start();
      frame.setSize(400, 420);
      Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
      frame.setLocation((d.width - frame.getSize().width) / 2, (d.height - frame.getSize().height) / 2);
      frame.setVisible(true);
      frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } });
   static {
      try {
         UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
      catch(Exception e) {
         e.printStackTrace();
   void jButton1_actionPerformed(ActionEvent e) {
      CPrintUtilities p = new CPrintUtilities();
      JPanel clone = jPanel1;
      clone.setSize(500,500);
      p.AddPage(clone);
      p.print();
class MyPanel extends JPanel {
   public void paintComponent(Graphics g)
      super.paintComponent(g);
      Line2D.Float l1 = new Line2D.Float(0,0,400,400);
      Line2D.Float l2 = new Line2D.Float(400,400,0,0);
      boolean bYes = l1.intersectsLine(400,400,400,400);
      System.out.println(bYes);
}And here is the CPrintUtilities class;
package com.cpm.common.utilities;
import java.awt.*;
import javax.swing.*;
import java.awt.print.*;
import java.awt.event.*;
import java.awt.font.*;
import java.awt.geom.*;
import java.util.*;
/** A simple utility class that lets you very simply print
*  an arbitrary component. Just pass the component to the
*  PrintUtilities.printComponent. The component you want to
*  print doesn't need a print method and doesn't have to
*  implement any interface or do anything special at all.
*  <P>
*  If you are going to be printing many times, it is marginally more
*  efficient to first do the following:
*  <PRE>
*    PrintUtilities printHelper = new PrintUtilities(theComponent);
*  </PRE>
*  then later do printHelper.print(). But this is a very tiny
*  difference, so in most cases just do the simpler
*  PrintUtilities.printComponent(componentToBePrinted).
public class CPrintUtilities implements Printable
  private Component componentToBePrinted;
  protected Book m_book = new Book();
  protected ArrayList m_arrayPages  = new ArrayList();
  protected double m_scaleFactorX = 1.0f;
  protected double m_scaleFactorY = 1.0f;
  protected boolean m_bShowPrintDialog = true;
  protected static PrinterJob printJob = null;
  public static void printComponent(Component c)
    new CPrintUtilities(c).print();
  public CPrintUtilities(Component componentToBePrinted)
    this.componentToBePrinted = componentToBePrinted;
  public CPrintUtilities()
  public CPrintUtilities(Book book)
    m_book = book;
  public void AddPage(Component componentToBePrinted)
     m_arrayPages.add(componentToBePrinted);
  public void SetShowPrintDialog(boolean bShowPrintDialog)
     m_bShowPrintDialog = bShowPrintDialog;
//   public void print()
   public boolean print()
      printJob = PrinterJob.getPrinterJob();
//      if(printJob.printDialog()) {
      if(m_bShowPrintDialog) {
         if(!printJob.printDialog())  {
            return false;
      try {
         // Revise the Page Format
         PageFormat format = printJob.defaultPage();
         double nMargin = 72/4;  // Inch / 4 or one quarter inch
         Paper paper = format.getPaper();
         double nHeight = paper.getHeight() - (nMargin * 2);
         double nWidth  = paper.getWidth()  - (nMargin * 2);
         double scaleFactorX = 1.0f;
         double scaleFactorY = 1.0f;
         paper.setImageableArea(nMargin,nMargin,nWidth,nHeight);
         format.setPaper(paper);
         for(int x = 0;x < m_arrayPages.size();x++) {
            componentToBePrinted = (Component)m_arrayPages.get(x);
            // Scale to print
            double nCompHeight = componentToBePrinted.getHeight();
            double nCompWidth  = componentToBePrinted.getWidth();
            if (nWidth > nCompWidth)
              scaleFactorX = nCompWidth / nWidth;
            else
              scaleFactorX = nWidth / nCompWidth;
            if (nHeight > nCompHeight)
              scaleFactorY = nCompHeight / nHeight;
            else
              scaleFactorY = nHeight / nCompHeight;
            m_scaleFactorX = scaleFactorX;
            m_scaleFactorY = scaleFactorY;
            printJob.setPrintable(this,format);
            printJob.print();
      catch(PrinterException pe) {
         CSystem.PrintDebugMessage("Error printing: " + pe);
      return true;
   public void printBook()
      PrinterJob printJob = PrinterJob.getPrinterJob();
      if (printJob.printDialog())
         try
            for(int x = 0;x < m_book.getNumberOfPages();x++)
               Printable printable = m_book.getPrintable(x);
               printJob.setPrintable(printable);
               printJob.print();
         catch(PrinterException pe)  {
            CSystem.PrintDebugMessage("Error printing: " + pe);
  public int print(Graphics g, PageFormat pageFormat, int pageIndex)
    if (pageIndex > 0)
      return(NO_SUCH_PAGE);
    else
      Graphics2D g2d = (Graphics2D)g;
      g2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
      g2d.scale(m_scaleFactorX,m_scaleFactorY);
      disableDoubleBuffering(componentToBePrinted);
      componentToBePrinted.paint(g2d);
      enableDoubleBuffering(componentToBePrinted);
      return(PAGE_EXISTS);
  /** The speed and quality of printing suffers dramatically if
   *  any of the containers have double buffering turned on.
   *  So this turns if off globally.
   *  @see enableDoubleBuffering
  public static void disableDoubleBuffering(Component c) {
    RepaintManager currentManager = RepaintManager.currentManager(c);
    currentManager.setDoubleBufferingEnabled(false);
  /** Re-enables double buffering globally. */
  public static void enableDoubleBuffering(Component c) {
    RepaintManager currentManager = RepaintManager.currentManager(c);
    currentManager.setDoubleBufferingEnabled(true);
}

Similar Messages

  • How to Print to Linux Terminal

    Would anyone happen to know how to create a VI that prints to Linux Terminal.  I wish to make a test VI that verifies the RTE is working on a Linux Server and no more dependencies/Libraries are necessary.  Going to be pretty simple.  Just a VI that, when ran, will write "Hello World" to terminal then close.  All of that is pretty easy of course.  I just don't know how to print to Terminal.
    Remember, code does exactly what you tell it.

    I don't have a linux system to test on, but it seems like you could modify this comunity code sample to do what you're looking to do.  Have a look: https://decibel.ni.com/content/docs/DOC-40941

  • Printing from Linux to Windows shared printer

    I am trying to print from Linux to a shared printer on a Windows XP PC. I installed cups and foomatic, started cupsd and configured the printer (HP Deskjet 720C) in KDE control centre. When I try to print a test page I get the following message:
    Catastrophe! - KNotify
    A print error occurred. Error message received from system:
    cupsdoprint -P 'deskjet' -J 'KDE Print Test' -H 'localhost:631' -U 'root' -o ' multiple-document-handling=separate-documents-uncollated-copies orientation-requested=3' '/opt/kde/share/apps/kdeprint/testprint.ps' : execution failed with message:
    client-error-not-possible
    I have Googled like crazy but couldn't find a working solution.
    For reference:
    /etc/cups/printers.conf
    # Printer configuration file for CUPS v1.1.23
    # Written by cupsd on Wed 29 Jun 2005 09:33:20 PM BST
    <DefaultPrinter deskjet>
    Info HP DeskJet 720C
    Location
    DeviceURI smb://guest@MSHOME/ANDROMEDA/HPDeskJet
    State Idle
    Accepting Yes
    JobSheets none none
    QuotaPeriod 0
    PageLimit 0
    KLimit 0
    AllowUser root shaurz
    </Printer>
    /etc/cups/cupsd.conf (comments stripped)
    LogLevel info
    Port 631
    <Location />
    Order Deny,Allow
    Deny From All
    Allow From 127.0.0.1
    </Location>
    <Location /admin>
    AuthType Basic
    AuthClass System
    Order Deny,Allow
    Deny From All
    Allow From 127.0.0.1
    </Location>
    lpstat -t
    scheduler is running
    system default destination: deskjet
    device for deskjet: smb://MSHOME/ANDROMEDA/HPDeskJet
    deskjet accepting requests since Jan 01 00:00
    printer deskjet is idle. enabled since Jan 01 00:0

    Rather than use SMB to connect from Lion to the Windows XP printer share, a better method is to enable Print Services for UNIX on Windows XP and then use LPD on the Mac to print via the Windows share.
    To install Print Services for UNIX on Windows XP:
    Log on to the Windows server with an administrative-level account.
    Start the Add/Remove Programs tool in Control Panel.
    Click Add/Remove Windows Components.
    Click Other Network File and Print Services, and then click Details.
    Click to select the Print Services for UNIX check box, and then click OK.
    Follow the instructions on the screen to finish the installation
    If you haven't done so already, share the printer on Windows XP and make the name one word - no spaces or special characters
    With the print services enabled you can then create the printer queue on Lion.
    Open Print & Scan and click + to add a printer
    Select the IP icon and set the protocol to Line Printer Daemon - LPD
    For the Address, enter the IP address of the Windows XP computer
    For the Queue name, enter the share name set for the printer in Windows XP
    Name and Location are free text so you can set this to something meaningful
    For the Print Using menu, select the supporting printer driver. Note that like connections via SMB, the vendors driver for Lion in some cases cannot be used and an alternate like those offered by the Gutenprint suite must be used.
    Click the OK button to complete the queue creation.
    Now you are ready to test the new print queue.   

  • On Mac OS 10.5, can't print to Linux CUPS printing server

    We attached a USB printer to a Linux server, which is CUPS1.3.8 installed.
    The printer is Epson Stylus CX5900.
    Printing from another Linux with CPUS is OK.
    But I can NOT print from my MacOSX10.5 system.
    I tried IPP, SMB, no success.
    Visit the http://127.0.0.1:631 on Mac, the CUPS on Mac even can not discovery the printer shared by Linux server.
    If I add added the printer as samba on MacOS, it will report
    /Library/Printers/EPSON/InkjetPrinter/Filter/rastertoescp.app/Contents/MacOS/ras tertoescp failed
    I see many users report printing issues on MacOSX10.5 on the Internet.
    What's the matter?
    As I know, MacOSX10.4 can print to printer on Linux CUPS server.

    Slow down a bit and think this through.
    CUPS on linux is nearly identical to CUPS on OS X - but there is no Mac-to-Mac Apple proprietary print sharing. Rather, on linux you are sharing the printer using standard printing protocols. Just like on the Mac (when using the standard protocols like Windows/SMB or IP printing), linux print queues expect postscript input. Try using a generic postscript driver from the mac.
    And when you add the printer via Windows Printing or IP > LPD or IPP, you will need to know the queue name for that printer from the linux box. (one computer with one IP address can have multiple printers - so what's the additional address info to print to your desired printer? - queue name.)
    HTH

  • How to configre printer  at linux and R12 instance

    Dear all,
    Please guide me.how to configure printer at linux and configure at R12 also.
    Regards
    Dharma

    933950 wrote:
    Dear all,
    Please guide me.how to configure printer at linux and configure at R12 also.
    Regards
    DharmaThis topic was discussed many times in the forum before, please see old threads for details.
    https://forums.oracle.com/forums/search.jspa?threadID=&q=Printer&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
    https://forums.oracle.com/forums/search.jspa?threadID=&q=Printer+AND+R12&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
    https://forums.oracle.com/forums/search.jspa?threadID=&q=Printer+AND+Setup&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
    Thanks,
    Hussein

  • [PARTIALY SOLVED]Can't see SAMBA share or Printer in Linux

    Greetings all,
    I have built a headless server running Arch linux as the base OS.  I am running SAMBA and CUPS and performing all maintenance of this server via SSH.
    The SAMBA share I can see (read/write) on all the Windows 7 machines on the network as well as the Printer connected to the server.  But I can't see it when I open Thunar or PCManFM.  Nor can I access the printer.
    It's obviously something I am doing wrong but I have Googled different parameters trying to find a solution but have come up short.
    Your assistance and guidance in putting me in the right direction is most appreciated.  All my Linux machines are running Arch.
    Thanks,
    Ian
    Last edited by ichase (2012-10-28 07:19:14)

    I have looked high and low.  The printer is set up via CUPS and the printer in smb.conf is set to CUPS.  All 4 windows computers in the house now have this printer set as default and can print fine.
    But if I try to print in Linux, for example in Libreoffice, I get No default printer found.  Please choose a printer and try again.  When I click ok, the network printer does not show up for me to select.
    I have tried updating the /etc/cups/client.conf on the client computer and it is set as:
    # see 'man client.conf'
    homeserver /var/run/cups/cups.sock
    homeserver 192.168.X.XX
    From what I have read so far, this is correct.  When I go to the CUPS Web Interface it shows under Manage Printer my HP 7300 Series printer there and in idle waiting for job.  And in Windows I can print to it just fine.
    As far as I can  tell SAMBA is set up correctly (I can mount the file drive in Arch with no issues) and CUPS seems to be configured correctly as well from all that I have read.
    Any insight would be great,
    Thanks,
    Ian
    Last edited by ichase (2012-10-28 07:28:31)

  • Unable to print in linux using java 1.5

    Hi i could't able to print in linux system using java 1.5. Printer name is detecting.
    when i execute printDataTransferCompleted then printJobNoMoreEvents happening But print is not happening.
    here i attached the source.
    import javax.print.Doc;
    import javax.print.DocFlavor;
    import javax.print.DocPrintJob;
    import javax.print.PrintService;
    import javax.print.PrintServiceLookup;
    import javax.print.SimpleDoc;
    import javax.print.event.PrintJobEvent;
    import javax.print.event.PrintJobListener;
    public class HellowLinux {
         public static void main(String args[]){
              String printText = "The Java Tutorials are practical guides for programmers" ;
              DocFlavor byteFlavour = DocFlavor.BYTE_ARRAY.TEXT_PLAIN_UTF_8;
              Doc myDoc = new SimpleDoc(printText.getBytes(), byteFlavour, null);
              PrintService[] services = PrintServiceLookup.lookupPrintServices(byteFlavour, null);
              System.out.println("No of printer detected : "+services.length );
              for(int i = 0; i<services.length; i++){
                   System.out.println("Printer Name : "+services.getName());
              if(services.length > 0){
                   DocPrintJob myJob = services[0].createPrintJob();
                   myJob.addPrintJobListener(new PrintJobMonitor());
                   try{
                        myJob.print(myDoc, null);
                        System.out.println("Printed Successfully ... ");
                   }catch(Exception e){
                        System.out.println("Error : "+e.getMessage());
         private static class PrintJobMonitor implements PrintJobListener {
              public void printDataTransferCompleted(PrintJobEvent pje) {
                   // Called to notify the client that data has been successfully
              // transferred to the print service, and the client may free
              // local resources allocated for that data.
                   System.out.println("Data transfer Completed : "+pje.hashCode()
                             +"\n"+pje.getPrintEventType());
              public void printJobCanceled(PrintJobEvent pje) {
                   // Called to notify the client that the job was canceled
              // by a user or a program.
                   System.out.println("Cancelled : "+pje.hashCode()
                        +"\n Event Type "+pje.getPrintEventType());
              public void printJobCompleted(PrintJobEvent pje) {
                   // Called to notify the client that the job completed successfully.
                   System.out.println("Completed : "+pje.hashCode()
                             +"\n Event Type "+pje.getPrintEventType());
              public void printJobFailed(PrintJobEvent pje) {
                   // Called to notify the client that the job failed to complete
              // successfully and will have to be resubmitted.
                   System.out.println("Failed : "+pje.hashCode()
                             +"\n Event Type "+pje.getPrintEventType());
              public void printJobNoMoreEvents(PrintJobEvent pje) {
                   // Called to notify the client that no more events will be delivered.
                   System.out.println("No More Events : "+pje.hashCode()
                             +"\n Event Type "+pje.getPrintEventType());
              public void printJobRequiresAttention(PrintJobEvent pje) {
                   // Called to notify the client that an error has occurred that the
              // user might be able to fix.\
                   System.out.println("Requires Attention : "+pje.hashCode()
                             +"\n Event Type "+pje.getPrintEventType());
    Edited by: 936393 on May 24, 2012 12:08 AM

    Hi ,
    Go to Help menu >> update
    it will update your application to 13.1
    then go to  Editor 's Edit menu >> Preferences and click on Reset Preference on next launch .
    after that relaunch your application..
    Refer article for the same:
    https://helpx.adobe.com/photoshop-elements/kb/elements-printer-issue-incompatible-error.ht ml

  • Negative error code when trying to print from Linux OS

    What does a negative error code mean when trying to print from Linux OS.
    Terminated with error: REP-50157: Error while sending file to printer apps_dev. Exit with error code -1
    It is Oracle Application Server 9.0.4 on Redhat Linux when I'am directly sending the output to the printer.
    Thanks for the help in advace.
    -P

    Reinstall or update your Lexmark printer driver.

  • Resolution problem when printing JPanel with picture on bg

    Hellow!
    I have some problems with printing JPanel component. I have a picture drawn on the background of the JPanel and several buttons on it. The whole JPanel is about 1600x800px. When i print whole the component with the help of PDF virtual printer, component is printed larger than A4 list. It is strange for me because print resolution is 600 dpi, so whole component must be a rectangle with the size about 2.5x1.5 inches. When I scale the graphics before painting component to fit image to page (i mean ... {color:#ff0000}g2d.scale(sc,sc); panel.paintAll(g2d);{color} ...), the picture's quality becomes very bad.
    I understod it so: I draw the component on the paper in screen resolution, then I decrease image size, so quality also decreases.
    My question is: how to draw on the graphics of printing paper the component in printers resolution (600dpi), but not in screen resolution.

    Hi there,
    Could you provide the community with a little more information to help narrow troubleshooting? What operating system?
    You can say thanks by clicking the Kudos Star in my post. If my post resolves your problem, please mark it as Accepted Solution so others can benefit too.

  • Print JPanel GUI components cut off

    I saw some examples in this forum for printing JPanel GUI components.
    I scaled and double buffered but still have some problem.
    I have a JPanel that has a few component added (Another JPanel's) with GUI.
    How can I avoid a specific Component Cutting in the printing process and put it in the
    next page to be print?
    Thanks in advance,
    Lior

    I have been trying all day to find a solution but did not managed to do it.
    Is there another component (Not a JPanel) that I can add to it components and it is already defined
    for printing purposes ?
    Any othere idea ?
    Thanks,
    Lior.

  • Does printing in Linux RedHat requires CUPS?

    Does the jdk1.4 Printing API require CUPS to run in Linux RedHat? I installed the JDK and programs run well but I cannot direct the printing to a particular prnter. The printing allways goes to the default printer. I ran the examples in Print2DPrinterJob.java (code at the end of this posting) and I find that the windows to select the printers appear, I select the printer to output the image, but the printout allways goes to the default printer regardless of the printer selected.
    Since the java Printing API requires the IPP and since LPR is not based in this protocol, I was wondering if I must install CUPS in the server in order to use the printing API
    import java.io.*;
    import java.awt.*;
    import java.net.*;
    import java.awt.image.*;
    import java.awt.print.*;
    import javax.print.*;
    import javax.print.attribute.*;
    import javax.print.attribute.standard.*;
    public class Print2DPrinterJob implements Printable {
         public Print2DPrinterJob() {
              /* Construct the print request specification.
              * The print data is a Printable object.
              * the request additonally specifies a job name, 2 copies, and
              * landscape orientation of the media.
              PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
              aset.add(OrientationRequested.LANDSCAPE);
              aset.add(new Copies(2));
              aset.add(new JobName("My job", null));
              /* Create a print job */
              PrinterJob pj = PrinterJob.getPrinterJob();
              pj.setPrintable(this);
              /* locate a print service that can handle the request */
              PrintService[] services =
                   PrinterJob.lookupPrintServices();
              if (services.length > 0) {
                   System.out.println("selected printer " + services[0].getName());
                   try {
                        pj.setPrintService(services[0]);
                        pj.pageDialog(aset);
                        if(pj.printDialog(aset)) {
                             pj.print(aset);
                   } catch (PrinterException pe) {
                        System.err.println(pe);
         public int print(Graphics g,PageFormat pf,int pageIndex) {
              if (pageIndex == 0) {
                   Graphics2D g2d= (Graphics2D)g;
                   g2d.translate(pf.getImageableX(), pf.getImageableY());
                   g2d.setColor(Color.black);
                   g2d.drawString("example string", 250, 250);
                   g2d.fillRect(0, 0, 200, 200);
                   return Printable.PAGE_EXISTS;                         
              } else {
                   return Printable.NO_SUCH_PAGE;
         public static void main(String arg[]) {
              Print2DPrinterJob sp = new Print2DPrinterJob();

    i have experienced the same problem as you - inability to print to a particular printer on linux. this appears to be a bug - if you look closely at what is happening, you get the following exception thrown when you try to print to any printer other than the default one (however, by default it will just recover and print to the default printer so you won't see this exception unless you force it by trying to do a print service lookup with no attributes set). I have not had any luck gettign around this. CUPS does not help either - i have installed CUPS and still see this behavior. Let me know if you have found a workaround.
    - Dan Kokotov
    javax.print.PrintException: java.io.IOException: Bad file descriptor
         at sun.print.UnixPrintJob.print(UnixPrintJob.java:485)
         at PrintTest.printJava(PrintTest.java:67)
         at PrintTest.main(PrintTest.java:16)
    Caused by: java.io.IOException: Bad file descriptor
         at java.io.FileInputStream.readBytes(Native Method)
         at java.io.FileInputStream.read(FileInputStream.java:191)
         at java.io.BufferedInputStream.fill(BufferedInputStream.java:183)
         at java.io.BufferedInputStream.read1(BufferedInputStream.java:222)
         at java.io.BufferedInputStream.read(BufferedInputStream.java:277)
         at java.io.FilterInputStream.read(FilterInputStream.java:90)
         at sun.print.UnixPrintJob.print(UnixPrintJob.java:477)
         ... 2 more

  • How to print from linux to Mac printer using cups - password?

    I think that I have done the correct things to share my printer from my OS X 10.4 Mac mini (my MacBook is happy to print on the Mac mini printer), and my Ubuntu Linux computer seems to be ready to print using cups. Linux can see the printer on Mac mini, but when I try to send a print job the Mac refuses access. I assume the problem is that the Linux computer needs to send the Mac a password, but I don't know how to do that -- where in the sequence of information coming from the Linux computer the password should be, what format, how to get the Linux computer to send the info through lpadmin or the GUI. All that.
    Can anyone help? Preferably with step-by-step instructions for the complete idiot. I have seen FAQs on printing, but there is no information about passwords. And most are focussed on smb rather than cups.

    I use linux and print through the Mac - but I don't have the trouble you are describing.
    There are 2 places to enable print sharing on Mac - have you done both of those?
    What protocol are you using - the easiest for CUPS is IPP (port 631). I have an Ubuntu computer at home - describe exactly how you add the printer and I'll be able to follow through.

  • Printing from linux machine to Mac shared printer?

    I have a brand new Brother MFC 6800 that is connected to my Mac (10.4.4) via USB. I have a Linux box at home (Mandriva 2006), and I'd like to be able to print through the network to this printer.
    I've been searching the web for instructions for how to set up CUPS and/or SMB to allow me to print this way, but have only come up with a few tangential references. Almost everything I've found is how to print from a Mac to a Linux print server. I want to do the opposite.
    I'm handy enough with Un*x to edit config files, but not handy enough to know what to put in there. I'd appreciate anyone who can point me to a site that might show me how to do it.
    Quicksilver   Mac OS X (10.4.4)  

    Hi Chris,
       I've not done this with a Mac but CUPS is CUPS. Open the /etc/cups/client.conf file on your Linux machine and change the ServerName line to point to your Mac. That may be all you have to do because the Mac's CUPS automatically adds the local printer for you. You may have to define a queue for it; I'm not sure but I don't think so. Also, you will probably have to authorize it on the Mac. The /etc/cups/cupsd.conf file on the Mac should have a line in it that look like:
    Listen <Mac_IP>:631
    where <Mac_IP> should be replaced by the IP address of your Mac, (not 127.0.0.1) and similarly for <Linux_IP> below. Such a line should already exist for 127.0.0.1. Just copy-and-paste in a new copy of this line and change the IP address. Inside the definition of root directory you similarly may need to add an "Allow From" statement:
    <Location />
       Allow From <Linux_IP>
    </Location>
    The directory definitions are modeled on similar definitions in Apache's httpd.conf file. There may be more that is necessary; I'll see if I can find more specific information that I've saved. If you have to do more, please post it to this thread so that there is complete documentation for others. Of course a consistent configuration depends on having static IP addresses on your local network.
       I'm not really surprised that you didn't find much if you searched for strings including Mac or Apple; this is a purely UNIX question. The CUPS administration documentation can be found online at cups.org or even on your own machine at http://localhost:631/ or on your drive in the /usr/share/doc/cups directory.
    Gary
    ~~~~
       It's no surprise that things are so screwed up: everyone
       that knows how to run a government is either driving
       taxicabs or cutting hair.
             -- George Burns

  • Pdf printing with linux client

    hi,
    i'm working with a SuSE 9.3 Client and I want to use PDF-Printing with the Acrobat Reader. With Windows Xp it works fine, but if i choose the PDF-Printer with the Linux-Client nothing happens. The PDF-Job exist in the cue. What do i have to do that it works?
    P.S. I`am from germany ;-)

    Thanks! But on which machine do i have to put the lp command?
    Application-Server?
    Tarantella Server?
    Client?
    I have put it on my Client! But nothinng happens.
    My PATH --> /home/me/bin:/usr/local/sgdee:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin:/opt/kde3/bin:/usr/lib/jvm/jre/bin:/usr/lib/qt3/bin
    my script -->
    me@my-notebook:~> cat /usr/local/sgdee/lp
    #!/bin/bash
    LPINFILE=/tmp/.nclp.$$
    PATH="/bin:/usr/bin:/usr/local/bin:/usr/bin/X11:/usr/X11R6/bin"
    export PATH
    [ -f $1 ] && mv $1 $LPINFILE
    [ -f $2 ] && mv $2 $LPINFILE
    echo "Print: $* -> $LPINFILE" >> /tmp/nclog.`logname`
    echo "/usr/bin/xpdf -display $DISPLAY $LPINFILE; rm -f $LPINFILE" | at now
    exit 0
    me@my-notebook:~>

  • Air Print to any printer - using linux cups server

    For those folks who may have Linux boxes with a printer configured, you can make this printer available for air print using a tweak to your CUPs config and adding an avahi service. Details are here (no need to download & purchase additional software)
    http://hartlessbydesign.com/blog/view/197-airprint-with-ubuntu-1010
    I tested this procedure myself on a Canon MP140 printer sending a print job from the photos App on an iPad. It took a couple of refresh attempts to find the printer but once it did, print jobs sent just fine.

    I do not have the exact printer model that you have, but have used several HP wireless printers that all work just fine with an AirPort Extreme.
    Your wireless printer will connect to the wireless signal provided by an AirPort Extreme.....or any other wireless router.....just like any wireless device would connect to a network:
    1) Identify the network to be joined during setup
    2) Enter the wireless password to connect to the network

Maybe you are looking for

  • Number of times main memory has been unloaded in last 24 hours "0"

    Hello Experts, I am getting  error "BIA server is overloaded"  in RSDDBIAMON2 tcode.   Description is below: BIA server is overloaded Message no. RSD_TREX154 Diagnosis The SAP NetWeaver BI Accelerator server is overloaded. Either there has recently b

  • Formatting HD and re installing OSX SL

    Hello, My MBP been busy over the past 2.5 years, the HD is full of junk from redundant apps installations. I wish to format the HD and then install SnowL. I do have TC backup at work and another TM backup at home. What are the steps?

  • Password logon no longer possible---too many failed attempts

    Dear All, I Have a problem with one user-id , with out entering the wrong password it automatically locked 4 to 5 times it is locking daily , no one not entering any wrong password, why it's locking  ?  it shows this message  : *password logon no lon

  • Picture lag

    So im watching a you tube video and my internet is just fine and its high speed and im watching a u tube video and the picture lags ! also in the search bar the response from the keys to the cpu to the display is slow as a snail. so slow infact it ta

  • Flash SSD for Adobe Premiere Pro - problem, or not?

    Hi, I've just ordered a new workstation specifically for Adobe Premiere Pro use. Then I saw this on Adobe's technical requirements page for PP: 10GB of available hard-disk space for installation; additional free space required during installation (ca