Unable to print with Epson Tm-t81 thermal printer using java in ubuntu 10.04
<p>Can some one help me with printing concept.I am pasting my code.Code is running perfect with no error,printer is accepting job,but nothing is printing. I am getting only white paper.</p>

<pre><code>package demo;

import java.awt.BorderLayout;

import java.awt.Graphics2D;

import java.awt.Shape;

import java.io.FileOutputStream;

import javax.swing.*;

import com.lowagie.text.*;

import java.awt.Graphics;

import java.awt.event.*;



public class JTable2Pdf extends JFrame implements Printable,ActionListener{

  private JTable table;

  public JTable2Pdf() {

    getContentPane().setLayout(new BorderLayout());

    createTable();
  }

  private void createTable() {

    Object[][] data = {{ "a", "b", "e", 4, false } };

    String[] columnNames = { "A", "B", "C", "D", "E" };


    table = new JTable(data, columnNames);

    JPanel tPanel = new JPanel(new BorderLayout());
    tPanel.add(table.getTableHeader(), BorderLayout.NORTH);
    tPanel.add(table, BorderLayout.CENTER);
    JButton b=new JButton("Print");
    b.addActionListener(this);

    getContentPane().add(tPanel, BorderLayout.CENTER);
    getContentPane().add(b, BorderLayout.SOUTH);



  }
  private void print() {

    Document document = new Document(PageSize.A4.rotate());

    try {

      PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("jTable.pdf"));

      document.open();
      PdfContentByte cb = writer.getDirectContent();

      cb.saveState();
      Graphics2D g2 = cb.createGraphicsShapes(500, 500);

      Shape oldClip = g2.getClip();
      g2.clipRect(0, 0, 500, 500);

      table.print(g2);
      g2.setClip(oldClip);

      g2.dispose();
      cb.restoreState();
    } catch (Exception e) {
      System.err.println(e.getMessage());
    }
    document.close();
  }
  public static void main(String[] args) {

    JTable2Pdf frame = new JTable2Pdf();

    frame.pack();

    frame.setVisible(true);

    frame.print();
  }

    @Override
    public int print(Graphics g, PageFormat pageFormat, int pageIndex) throws PrinterException {

        if (pageIndex &gt; 0) { /* We have only one page, and 'page' is zero-based */
            return NO_SUCH_PAGE;
        }

        /* User (0,0) is typically outside the imageable area, so we must
         * translate by the X and Y values in the PageFormat to avoid clipping
         */
        Graphics2D g2d = (Graphics2D)g;
        g2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY());

        /* Now print the window and its visible contents */
        g2d.drawString("dfsdfdsfdsfsdfdsfsdf", TOP_ALIGNMENT, TOP_ALIGNMENT);
        table.print();

        /* tell the caller that this page is part of the printed document */
        return PAGE_EXISTS;


    }

    @Override
    public void actionPerformed(ActionEvent e) {
        PrinterJob job = PrinterJob.getPrinterJob();
         job.setPrintable(this);
         boolean ok = job.printDialog();
         if (ok) {
             try {
                  job.print();
             } catch (PrinterException ex) {
              /* The job did not successfully complete */
             }
         }
    }
}
</code></pre>
