Developer Tools
|
Office Productivity Applications
|
Platform-Agnostic APIs
|
Home | Online Demos | Downloads | Buy Now | Support | About Us | News | Working Together | Contact Us
XtremeDocumentStudio (for Java) is the next-generation multi-format document-processing component suite for Java SE/EE developers. It can display, print and convert DOCX, PDF and image files without requiring any external software. In this article, you will learn how to print a document.
In this code snippet, we have used a DOCX file. We check whether a printer is installed checking the length of the DocumentPrinter.getAvailablePrinterNames()
array. If there is a printer, we print the document to the default printer.
import java.awt.print.PrinterException; import java.io.IOException; import com.gnostice.core.XDocException; import com.gnostice.documents.controls.swing.printer.DocumentPrinter; public class DocumentPrintingDemo { public static void main(String[] args) { try { DocumentPrinter prn = new DocumentPrinter(); if (prn.getAvailablePrinterNames().length > 0) { // Load a document prn.loadDocument("unicode.docx",""); // Print to default printer prn.print(); // Unload IO resources of the document prn.closeDocument(); } else { System.out.println("No printer found."); } } catch (XDocException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (PrinterException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
To demonstrate the print output, we had set an XPS software printer as the default device. Here is the input DOCX and output XPS documents.
---o0O0o---
Our .NET Developer Tools | |
---|---|
Gnostice Document Studio .NETMulti-format document-processing component suite for .NET developers. |
PDFOne .NETA .NET PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, and bookmark PDF documents in .NET applications. |
Our Delphi/C++Builder developer tools | |
---|---|
Gnostice Document Studio DelphiMulti-format document-processing component suite for Delphi/C++Builder developers, covering both VCL and FireMonkey platforms. |
eDocEngine VCLA Delphi/C++Builder component suite for creating documents in over 20 formats and also export reports from popular Delphi reporting tools. |
PDFtoolkit VCLA Delphi/C++Builder component suite to edit, enhance, view, print, merge, split, encrypt, annotate, and bookmark PDF documents. |
Our Java developer tools | |
---|---|
Gnostice Document Studio JavaMulti-format document-processing component suite for Java developers. |
PDFOne (for Java)A Java PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, bookmark PDF documents in Java applications. |
Our Platform-Agnostic Cloud and On-Premises APIs | |
---|---|
StarDocsCloud-hosted and On-Premises REST-based document-processing and document-viewing APIs |
Privacy | Legal | Feedback | Newsletter | Blog | Resellers | © 2002-2024 Gnostice Information Technologies Private Limited. All rights reserved. |