Hallo Zusammen!
Im Folgenden wird ganz banal, ein PDF-Dokument an den jeweilig definierten Standarddrucker übergeben. Wird dieser Code in Eclipse selbst ausgeführt, so funktioniert er einwandfrei->
import java.awt.print.Book;
import java.awt.print.PageFormat;
import java.awt.print.Paper;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import javax.print.PrintService;
import com.sun.pdfview.PDFFile;
import com.sun.pdfview.PDFPrintPage;
public class pdfPrintUI {
String fehler;
//######################################################################################
public static void main(String[] args) throws IOException, PrinterException {
// 4 Test only
String fileName = "D:/Temp/test.pdf";
new pdfPrintUI().pdfPrint(fileName);
}
//######################################################################################
public boolean pdfPrint(String filePath) {
try {
String printerName = "";
String jobName = "PDF Print Job";
FileInputStream fileInputStream = new FileInputStream(filePath);
byte[] pdfContent = new byte[fileInputStream.available()];
fileInputStream.read(pdfContent, 0, fileInputStream.available());
ByteBuffer buffer = ByteBuffer.wrap(pdfContent);
final PDFFile pdfFile = new PDFFile(buffer);
PDFPrintPage pages = new PDFPrintPage(pdfFile);
PrinterJob printJob = PrinterJob.getPrinterJob();
PageFormat pageFormat = PrinterJob.getPrinterJob().defaultPage();
printJob.setJobName(jobName);
Book book = new Book();
book.append(pages, pageFormat, pdfFile.getNumPages());
printJob.setPageable(book);
Paper paper = new Paper();
paper.setImageableArea(0, 0, paper.getWidth(), paper.getHeight());
pageFormat.setPaper(paper);
PrintService[] printServices = PrinterJob.lookupPrintServices();
for (int count = 0; count < printServices.length; ++count) {
if (printerName.equalsIgnoreCase(printServices[count].getName())) {
printJob.setPrintService(printServices[count]);
break;
}
}
System.out.println("1");
printJob.print();
System.out.println("2");
return true;
}
catch(PrinterException p){
this.fehler = p.getMessage();
System.out.println(p.getMessage());
p.printStackTrace();
return false;
}
catch (IOException e) {
this.fehler = e.getMessage();
System.out.println(e.getMessage());
e.printStackTrace();
return false;
}
catch (Exception x) {
So weit so gut!
Erfolgt der Aufruf der Funktion aus LotusScript heraus.....
Function java_pdfPrintUI (quellfile As String) As Boolean
On Error Goto fehler
Dim js As JAVASESSION
Dim pdfPrintClass As JAVACLASS
Dim bPClass As Variant
Dim result As Variant
Dim myError As JAVAERROR
' #######################################################################################################
java_pdfPrintUI = False
Set js=New JAVASESSION
Set pdfPrintClass = js.GetClass("pdfPrintUI")
Set bPClass = pdfPrintClass.CreateObject
' #######################################################################################################
quellfile = "D:/temp/test.pdf"
result = bPClass.pdfPrint( quellfile )
' #######################################################################################################
ende:
java_pdfPrintUI = True
Exit Function
' #######################################################################################################
fehler:
Set myError = js.getLastJavaError()
Messagebox myError.errormsg,, "Error"
js.ClearJavaError
End Function
so "bleibt LN ( 8.5.3FP6 ) stehen"...was da heißt:
Das PDf-Dokument landet noch im Spoolmananger und die "1" wird noch ausgegeben. Dann stehen sowohl LN als auch der Spoolmanager still...keine Fehlermeldung..garnichts..keinerlei Abbruchmöglichkeit.

Hatte jemand von euch schonmal ein ähnliches Verhalten oder gar eine Lösung