SpooledFileViewer class

The SpooledFileViewer class creates a window for viewing Advanced Function Printing™ (AFP™) and Systems Network Architecture character string (SCS) files that have been spooled for printing. The class essentially adds a "print preview" function to your spooled files, common to most word processing programs, as illustrated in Figure 1.

The spooled file viewer is especially helpful when viewing the accuracy of the layout of the files is more important than printing the files, or when viewing the data is more economical than printing, or when a printer is not available.

Note: SS1 Option 8 (AFP Compatibility Fonts) must be installed on the host server.

Using the SpooledFileViewer class

Three constructor methods are available to create an instance of the SpooledFileViewer class. The SpooledFileViewer() constructor can be used to create a viewer without a spooled file associated with it. If this constructor is used, a spooled file will need to be set later using setSpooledFile(SpooledFile). The SpooledFileViewer(SpooledFile) constructor can be used to create a viewer for the given spooled file, with page one as the initial view. Finally, the SpooledFileViewer(spooledFile, int) constructor can be used to create a viewer for the given spooled file with the specified page as the initial view. No matter which constructor is used, once a viewer is created, a call to load() must be performed in order to actually retrieve the spooled file data.

Then, your program can traverse the individual pages of the spooled file by using the following methods:

If, however, you need to examine particular sections of the document more closely, you can magnify or reduce the image of a page of the document by altering the ratio proportions of each page with the following:

Your program concludes with calling the close() method that closes the input stream and releases any resource associations with the stream.

Using the SpooledFileViewer

An instance of the SpooledFileViewer class is actually a graphical representation of a viewer capable of displaying and navigating through an AFP or SCS spooled file. For example, the following code creates the spooled file viewer in Figure 1 to display a spooled file previously created on the server.

Note: You can either select a button on the image in Figure 1 for an explanation of its function, or (if your browser is not JavaScript™ enabled) see the toolbar description.
// Assume splf is the spooled file.
// Create the spooled file viewer
SpooledFileViewer splfv = new SpooledFileViewer(splf, 1);
splfv.load();
// Add the spooled file viewer to a frame
JFrame frame = new JFrame("My Window");
frame.getContentPane().add(splfv);
frame.pack();
frame.show();

Figure 1: SpooledFileViewer

SpooledFile Viewer. For more information about the toolbar icons, see the descriptions that follow this image.

SpooledFileViewer Toolbar description

Actual Size tool iconThe actual size button returns the spooled file page image to its original size by using the actualSize() method.

Fit Width tool iconThe fit width button stretches the spooled file page image to the left and right edges of the viewer's frame by using the fitWidth() method.

Fit Page tool icon The fit page button stretches the spooled file page image vertically and horizontally to fit within the spooled file viewer's frame by using the fitPage() method.

Zoom tool icon The zoom button allows you to increase or decrease the size of the spooled file page image by selecting one of the preset percentages or entering your own percent in a text field that appears in a dialog box after selecting the zoom button.

Go To Page tool icon The go to page button allows you to go to a specific page within the spooled file when selected.

First Page tool iconThe first page button takes you to the first page of the spooled file when selected and indicates that you are on the first page when deactivated.

Previous Page tool icon The previous page button takes you to the page immediately before the page you are viewing when selected.

Next Page tool icon The next page button advances you to the page immediately after the page you are viewing when selected.

Last Page tool iconThe last page button advances you to the last page of the spooled file when selected and indicates that you are on the last page when deactivated.

Load Flash Page tool icon The load flash page button loads the previously viewed page by using the loadFlashPage() method when selected.

Set Paper Size tool iconThe set paper size button allows you to set the paper size when selected.

Set Viewing Fidelity tool icon The set viewing fidelity button allows you to set the viewing fidelity when selected.