This is an archive of the Maximo Yahoo Community. The content of this pages may be a sometimes obsolete so please check post dates.
Thanks to the community owner Christopher Wanko for providing the content.
Dear all,
I have successfully "direct print" a text file (phone.txt) but still
getting an error while printing a pdf file.
Printer output says:
PDF Error Page
Error Number: 04.007
Error Type: File Format Error
Error Description: Invalid XREF Table
PDF Operator: Unknown Operator
The idea is, if user click button then it will print a document on
spesific printer & specific tray. We have 2 printers with 3 or 4 trays
with different color paper.
Source:
========================================================================================
...
import javax.print.*;
import javax.print.attribute.*;
import javax.print.attribute.standard.*;
void printDoc() {
String printerName = "TESTPRINT";
try {
FileInputStream psStream = new FileInputStream("C:\\TEMP\\PHONE.PDF");
//FileInputStream psStream = new
FileInputStream("C:\\TEMP\\PHONE.TXT");
PrintService service = getPrinterByName(printerName);
if(service != null) {
DocPrintJob printJob = service.createPrintJob();
DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
Doc document = new SimpleDoc(psStream, flavor, null);
try {
PrintRequestAttributeSet pset = new
HashPrintRequestAttributeSet();
pset.add(MediaTray.TOP);
pset.add(MediaSizeName.ISO_A3);
printJob.print(document, null);
} catch (PrintException e) {
e.printStackTrace();
}
}
} catch (Throwable t) {
t.printStackTrace();
}
}
PrintService[] getPrintersList() {
DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
PrintService[] services = PrintServiceLookup.lookupPrintServices(flavor,
null);
return services;
}
PrintService getPrinterByName(String printerName) {
PrintService[] list = getPrintersList();
if(list.length > 0) {
for(PrintService service : list) {
if(service.getName().contains(printerName))
return service;
}
} return null;
}
========================================================================================
Does anyone have any idea?
Many thanks & regards,
Yudi
This might help
http://juixe.com/techknow/index.php/2008/01/17/print-a-pdf-document-in-java/
From: MAXIMO@yahoogroups.com [mailto:MAXIMO@yahoogroups.com] On Behalf Of yudi.irianto@ytljt.com
Sent: 05 March 2014 02:00
To: MAXIMO@yahoogroups.com
Subject: [MAXIMO List] Can not print pdf file
Dear all,
I have successfully "direct print" a text file (phone.txt) but still getting an error while printing a pdf file.
Printer output says:
PDF Error Page
Error Number: 04.007
Error Type: File Format Error
Error Description: Invalid XREF Table
PDF Operator: Unknown Operator
The idea is, if user click button then it will print a document on spesific printer & specific tray. We have 2 printers with 3 or 4 trays with different color paper.
Source:
========================================================================================
...
import javax.print.*;
import javax.print.attribute.*;
import javax.print.attribute.standard.*;
void printDoc() {
String printerName = "TESTPRINT";
try {
FileInputStream psStream = new FileInputStream("C:\\TEMP\\PHONE.PDF");
//FileInputStream psStream = new FileInputStream("C:\\TEMP\\PHONE.TXT");
PrintService service = getPrinterByName(printerName);
if(service != null) {
DocPrintJob printJob = service.createPrintJob();
DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
Doc document = new SimpleDoc(psStream, flavor, null);
try {
PrintRequestAttributeSet pset = new HashPrintRequestAttributeSet();
pset.add(MediaTray.TOP);
pset.add(MediaSizeName.ISO_A3);
printJob.print(document, null);
} catch (PrintException e) {
e.printStackTrace();
}
}
} catch (Throwable t) {
t.printStackTrace();
}
}
PrintService[] getPrintersList() {
DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
PrintService[] services = PrintServiceLookup.lookupPrintServices(flavor, null);
return services;
}
PrintService getPrinterByName(String printerName) {
PrintService[] list = getPrintersList();
if(list.length > 0) {
for(PrintService service : list) {
if(service.getName().contains(printerName))
return service;
}
} return null;
}
========================================================================================
Does anyone have any idea?
Many thanks & regards,
Yudi
GDF SUEZ E&P UK Ltd (Company Number 3386464), registered in England and Wales with a registered office address at: 40 Holborn Viaduct, London, EC1N 2PB.
**************************************************************************************************************
This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed.
If you have received this email in error please notify the system manager.
**************************************************************************************************************