• Post Reply Bookmark Topic Watch Topic
  • New Topic

MediaPrintableArea

 
Patrick Houston
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm using the Java Print Service to print on a label Printer (SII Smart Label Printer 440). When I run the following code (Java1.5, Tomcat5.5, Windows XP, Eclipse 3.2), it lists all the available MediaPrintableAreas from the Label Printer and everything works fine.

<%@ page import="java.util.Enumeration" %>
<%@ page import="java.util.Vector" %>
<%@ page import="javax.print.*" %>
<%@ page import="java.awt.print.*" %>
<%@ page import="javax.print.attribute.*" %>
<%@ page import="javax.print.attribute.standard.*" %>

<%
out.print("<pre>");
PrinterJob printerJob = PrinterJob.getPrinterJob();
PrintService[] pserviceArr = PrinterJob.lookupPrintServices();
DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet();
for (int i = 0; i < pserviceArr.length; i++) {
out.print(pserviceArr[i].getName() + "<br>");
Object[] o = (Object[]) pserviceArr[i].getSupportedAttributeValues(MediaPrintableArea.class, null, attributes);
for (int j = 0; j < o.length; j++) {
MediaPrintableArea pa = (MediaPrintableArea) o[j];
if (pa != null) {
out.print(" MediaPrintableArea " + j + ": " + pa.getName() + " " + pa.getX(MediaPrintableArea.MM)
+ " " + pa.getY(MediaPrintableArea.MM)
+ " " + pa.getHeight(MediaPrintableArea.MM)
+ " " + pa.getWidth(MediaPrintableArea.MM) + "<br>");
} else {
out.print(j + ": PA is null" + "<br>");
}
}
DocFlavor[] df = pserviceArr[i].getSupportedDocFlavors();
for (int j=0; j<df.length; j++) {
DocFlavor d = df[j];
out.print(" DocFlavor: " + d.toString() + "<br>");
}
}
out.print("<br>");
PrintService pservice = PrintServiceLookup.lookupDefaultPrintService();
out.print("DefaultService: " + pservice.getName() + "<br>");

out.print("</pre>");
%>

When I open the JSP-Page on another PC with the same configuration without Eclipse, it shows always the same values for the different MediaPrintableAreas. Has anyone experienced similar problems?

I've been trying to solve this problem for three weeks and the Java Print Service is driving me crazy. I even tried this with another Label Printer (SII Smart Label Printer 240) but the same Problem occurs. I reinstalled the Printer Driver and Software from SII several times, but without success. When I installed the software on another desktop PC with the same hardware, I experienced the same Problem. Any help to solve this problem would be very much appreciated.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!