Home » Desktop Java » print

print

Handle print service attribute changes

In this example we are going to see how to handle print services attributes changes in a Java Desktop Applications. This will give you more control when handling print jobs inside your application. To handle print service attribute changes one should take these steps: Use PrintServiceLookup.lookupDefaultPrintService() to locate the default print service for this environment. Create a class that implements ...

Read More »

Handle print job attribute changes

In this example we are going to see how to handle print job attributes changes in a Java Desktop Applications. This will give you more control when handling print jobs inside your application. To handle print service attribute changes one should take these steps: Use PrintServiceLookup.lookupDefaultPrintService() to locate the default print service for this environment. Create a class that implements PrintJobAttributeListener. Override attributeUpdate method to ...

Read More »

Set orientation for print job

With this tutorial we are going to learn how to set orientation for print jobs in a Java Desktop Application. This is a very basic feature, if you want to offer print services inside your application, because it gives the user the ability to choose the orientation of his printing. In order to set orientation for print jobs you simply ...

Read More »

Set copies number for print job

This is an example on how to set copies number for print jobs in your Java Desktop Application. In order to do that, one should follow these steps: Open a new pdf file to print using BufferedInputStream(new FileInputStream("myfile.pdf")). Create a PDF doc flavor using DocFlavor.INPUT_STREAM.PDF that returns aDocFlavor object. Use PrintServiceLookup.lookupDefaultPrintService() to locate the default print service for this environment. Use createPrintJob() to create and return a DocPrintJob capable of ...

Read More »

Print to file with Java

In this example we are going to see how to print a document to a .ps file in Java. This is very useful when you want to create simple and easy previews of the print that the user might perform. In order to print to a file, one should follow these steps: Open a new pdf file to print using BufferedInputStream(new ...

Read More »

Get print service attributes

This is an example on how to get print service attributes in a Java Desktop Application. This is very useful when you want to list these attributes to inform the user about the properties of his print. In short, to get print service attributes one should follow these steps: Use PrintServiceLookup.lookupDefaultPrintService() to locate the default print service for this environment. Use service.getAttributes().toArray() ...

Read More »

Use streaming printing service in Java

In this example we are going to see how to use streaming printing services in a Java Desktop Application. This is very useful when you want to handle print jobs inside your application. It’s very easy to use streaming printing services in Java. All you have to do is: Open an image using new BufferedInputStream(new FileInputStream("myfile.gif")). Prepare the output file ...

Read More »

Cancel print job

This is an example that demonstrates how to cancel print jobs in a Java Desktop Application. This is a very basic step you have to consider when you have to develop error handling procedures for your applications. In short, all you have to do to cancel print jobs is: Open a pdf file you want to print. Create a PDF ...

Read More »

Determine that print job has finished

With this example we are going to see how we can determine that a print job has finished. It’s very easy to do that, as you only have to : Open a pdf file to print. Create a new PrintService. Create a new DocPrintJob. Create a class that extends PrintJobAdapter. Override printJobCanceled, printJobCompleted, printJobFailed, printJobNoMoreEvents to monitor the status of ...

Read More »

Handle print job events

With this tutorial we shall show you how to handle print job events in a Java Desktop Application. This is a very important step to consider when you handle many print jobs in your application an you want to monitor their status as well as inform the user for the progress of his print jobs. Basically, all you have to ...

Read More »

Want to take your Java skills to the next level?

Grab our programming books for FREE!

Here are some of the eBooks you will get:

  • Spring Interview QnA
  • Multithreading & Concurrency QnA
  • JPA Minibook
  • JVM Troubleshooting Guide
  • Advanced Java
  • Java Interview QnA
  • Java Design Patterns