Hi,
I have the next code, and it works fine in a Windows machine, but when I try to excute the code in an iSeries with JDK 7 it crashes the highlighted line.
Any clues?
Thanks.
@SuppressWarnings("deprecation")
private static void printfile(File file, String printerName) {
// Create PdfViewer object
com.aspose.pdf.facades.PdfViewer viewer = new com.aspose.pdf.facades.PdfViewer();
// Open input PDF file
viewer.openPdfFile(file.getAbsolutePath());
// Set attributes for printing
viewer.setAutoResize(true); // Print the file with adjusted size
viewer.setAutoRotate(true); // Print the file with adjusted rotation
viewer.setPrintPageDialog(false); // Do not produce the page number dialog when printing
com.aspose.pdf.printing.PdfPrinterSettings printerSettings = new com.aspose.pdf.printing.PdfPrinterSettings();
printerSettings.setPrinterName(printerName);
viewer.printDocumentWithSettings(printerSettings);
// close the Pdf file.
viewer.closePdfFile();
}
This is the log
Exception in thread "main" java.lang.NullPointerException: value is null
at javax.print.attribute.TextSyntax.verify(TextSyntax.java:89)
at javax.print.attribute.TextSyntax.(TextSyntax.java:83)
at javax.print.attribute.standard.PrinterName.(PrinterName.java
::77)
at com.aspose.pdf.internal.p605.z3.m1(Unknown Source)
at com.aspose.pdf.internal.p565.z40.(Unknown Source)
at com.aspose.pdf.printing.PdfPrinterSettings.(Unknown Source)
at XXXXXXXXXX.PDFPrinterHelper.printfile(PDFPrin
terHelper.java:38)
at XXXXXXXXXX.PDFPrinterHelper.printPDFs(PDFPrin
terHelper.java:21)
at XXXXXXXXXX.App.main(App.java:12)