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. See Figure 1 below.
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 AS/400 system.
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 would conclude with calling the close() method that closes the input stream and releases any resource associations with the stream.
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 AS/400.
Note: Select each button on the image in the figure below for an explanation of its function. If your browser is not JavaScript enabled, use the button link for a description of each button on the image instead.
// 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();
SpooledFileViewer |
![]() |