Printing
Webswing implements seamless printing support, which works out of the box without any change needed in your application. Webswing generates a PDF file from the printed document and opens it in a new browser tab using default browser PDF viewer.
Printing is demonstrated in Webswing Demo application with sample source code included.
Multiple printing options are supported:
- print using
javax.print.DocPrintJob.print()
- print using
java.awt.print.Printable
andjava.awt.print.PrinterJob.print()
- print using
java.awt.Desktop.getDesktop().print()
- print multiple pages using
java.awt.print.Pageable
andjava.awt.print.PrinterJob.print()
- print GUI using
java.awt.Toolkit.getDefaultToolkit().getPrintJob()
- print using
JasperReports
- embedding fonts in printed PDF file (see Embed fonts in PDF)
Server printing
If you want to use printers connected to the remote server when printing, you can enable this in Webswing app configuration.
Direct printing
Webswing prints by generating PDF files on server and serving it to the client's browser. However, if you need to print directly from Webswing application to the client's printer, there are some options how to do this. You can create a custom print page that shows a printing dialog, that user must submit. To remove the user submission step you can start the browser in kiosk
mode. Refer to this documentation for more information.
Custom print service
Since Webswing 22.2 the print service is customizable. Please follow these steps:
- Implement a print service class that implements
org.webswing.ext.services.PdfService
interface included inwebswing-app-toolkit
project. - Put JAR with the class in
/extensions
folder in webswing installation folder. - Run application with system property
-Dorg.webswing.ext.services.PdfService=com.company.CustomPdfService