As easy as 1, 2, 3...
The wonderful thing about Java is that no matter which
platform your application is deployed on, a Java Graphical User
Interface (GUI) will always look the same - thanks to the power of
Java2D, the api on which JFC/Swing (the standard widget library for
Java applications) is based.
But wait ... Java2D? Isn't that the API supported by jPDF Creator?
Indeed ... and we will see in this tutorial how it can be used to create GUI screen shots.
The first thing we need for this demonstration is a GUI. We
won't get into the details here as there is already a lot of tutorials
available to program Swing/JFC. The important thing to remember,
though, is the fact that JFC/Swing is based on Java2D. Thus, any
component built with these API's can be easily converted to PDF using
jPDF Creator.
The figure below shows the GUI you will get if you run SimpleJava2DScreenshot.java - (the file is part of the distribution)

Now that we have a GUI, you might be wondering: "How do I convert it to PDF?"
Answer? With one line of code. See the code below:
import com.crionics.jpdf.creator.*;
JPdfScreenshotPrinter.printComponent(this.getContentPane(), clippingPreference);
That's it! The method takes two arguments:
- A Java2D Component ... it can be a JPanel, JTree, JTable, etc., ...
- A clipping preference, where you can choose to resize the components on: X,Y; X and Y; or to span it on several pages.
Once the method is called, it displays the print preview
page. There you can change generation properties or change the paper
size.
