Printing Issue...

From: Harihar Krishnan (harik@bma.gov.bh)
Date: Wed Oct 06 2004 - 05:18:40 EDT


Dear Printing Experts,

We connected an Epson LQ-680 dot-matrix printer to the parallel port of
Host1 (DS10, Tru64 v5.1) and created a printer using "lprsetup". We tried to
execute a java script (see below) and used the command "java
TestBankPrinting" under Unix to print its output. The output on the printer
should be the string "89658958". However, the printer prints some long
driver text titled "!PS - Adobe" etc.etc.

It may be noted that when we run the same script from a Windows client and
send the output to a network laser printer, the correct string is printed.

When setting up the printer driver under Unix, we tried using a few printer
types including "unknown", "ep1050+", "fx80" "PS level 1" "PS level 2", etc.
but none of these achieved the targeted output.

The question now is: Which printer type should I select for my Epson LQ-680
to print the Java script output? You may also note that the printer prints
normal files (e.g. /etc/hosts) without any problems, even when we select
"unknown" as printer type.

We would appreciate a feedback from the Print whizkids. Thanks in advance.
============================================================================
===================
THE JAVA SCRIPT IS AS FOLLOWS:

import java.awt.*;
import java.awt.font.*;
import java.awt.geom.*;
import java.awt.print.*;
import java.text.*;
public class TestBankPrinting implements Printable
//public class TestBankPrinting
{
    private static final String printText = "89658958";
    private static final AttributedString printStyle = new
AttributedString(printText);
  
  public static void main(String[] args)
  {
    TestBankPrinting testBankPrinting = new TestBankPrinting();
    
    PrinterJob printerJob = PrinterJob.getPrinterJob();
    PageFormat format = new PageFormat();

      //Choose printing type
        //format = printerJob.pageDialog(format);
    format = printerJob.defaultPage();

//Paper paper=new Paper();
Book book = new Book();
book.append(new TestBankPrinting(), format);
printerJob.setPageable(book);
//printerJob.setPageable(book);
try {
printerJob.print();
}
catch (PrinterException exception)
{
System.err.println("Printing error: " + exception);
}
}

public int print(Graphics g, PageFormat format, int pageIndex) throws
PrinterException {
Graphics2D g2d = (Graphics2D) g.create();
g2d.translate(format.getImageableX(), format.getImageableY());
Point2D.Float pen = new Point2D.Float();
AttributedCharacterIterator charIterator = printStyle.getIterator();
LineBreakMeasurer measurer = new LineBreakMeasurer(charIterator,
g2d.getFontRenderContext());
float wrappingWidth = (float) format.getImageableWidth();
while (measurer.getPosition() < charIterator.getEndIndex()) {
TextLayout layout = measurer.nextLayout(wrappingWidth);
pen.y += layout.getAscent();
float dx = layout.isLeftToRight() ? 0 : (wrappingWidth -
layout.getAdvance());
layout.draw(g2d, pen.x + dx, pen.y);
pen.y += layout.getDescent() + layout.getLeading();
}
g2d.dispose();
g2d = null;
try {
Printable formatPainter = (Printable) format;
formatPainter.print(g, format, pageIndex);
}
catch (ClassCastException exception) {}
return Printable.PAGE_EXISTS;
}

}
============================================================================
===================

Harihar K

===========================================================================
DISCLAIMER:
"This communication is intended solely for the named recipient and others
authorized to receive it. It may contain confidential or legally privileged
information. If you are not the intended recipient, please notify us
immediately, and note that any disclosure, copying, distribution or action
you may take in reliance on this communication is strictly prohibited and
may be unlawful. Unless indicated otherwise, this communication is not
intended nor should it be taken to create any legal relations, contractual
or otherwise. Bahrain Monetary Agency(BMA) is neither liable for the proper
and complete transmission of the communication, nor for any delay in its
receipt. Whilst BMA undertakes all reasonable efforts to screen outgoing
e-mails for viruses, it cannot be held liable for any viruses transmitted by
this e-mail."
===========================================================================



This archive was generated by hypermail 2.1.7 : Sat Apr 12 2008 - 10:50:08 EDT