Accessing a PDF Document with the Acrobat Viewe.. But when you need to open a PDF in a Java application, Acrobat Reader is not accessible. Fortunately, Adobe provides a viewer API, the Acrobat Viewer Java. Bean, to view and print PDF documents from Java applications, Java. Beans, or Java applets. The Acrobat classes are provided in thecom. Acrobat Viewer distribution. In this tutorial, we shall integrate the Acrobat Viewer in a Java application. Starting from the command line < Previous Page Next Page > You may want to start OOo from the command line (using the keyboard instead of the mouse). Open documents in viewer (read-only) mode. The PDF Developer Junkie Blog Tips, tricks. You can display and print a PDF file with Acrobat and Adobe Reader from the command line. Developing Custom PDF Portfolio Layouts using Flash Builder 4. We'll open an example PDF document in the application with the Acrobat Viewer, and discuss the different features of the Acrobat Viewer. This tutorial has the following sections: Preliminary Setup. Opening a PDF Document. Displaying a PDF Document in Acrobat Viewer. Preliminary Setup. The Acrobat Viewer Java. Bean API is available from the Acrobat Viewer Java. Bean page. Download the bean. The Acrobat Viewer is available for Windows, Macintosh, Solaris, UNIX, and OS/2 platforms. For the purposes of this tutorial, we'll consider the Acrobat Viewer to be installed on the Windows platform. For installation on other platforms, refer to the installation notes for the specific platform. Extract thebean. zip file to an installation directory. The Acrobat Viewer for Java. Bean API classes are included in the%Acrobat. Viewer%/acrobat. jar file, where the%Acrobat. Viewer% environment variable represents the directory in which the Acrobat Viewer Java. Bean distribution is installed. Add %Acrobat. Viewer%/acrobat. Acrobat. Viewer%/MRJToolkit. Stubs. zip to the. CLASSPATH environment variable. A Java application with the Acrobat Viewer API may be developed in an IDE such as Eclipse, JDeveloper, or Net. Beans, or as a command- line application. In this tutorial, a sample Acrobat Viewer Java application is developed as a command- line application. JRE 1. 1. 8 or later is recommended for the Acrobat Viewer. Opening a PDF Document. Having installed the Acrobat Viewer API, we shall open an example PDF document in Acrobat Viewer. The Adobe Document Services PDF document is used as the example document. Store the example PDF document in the C: /Adobedirectory. The Acrobat Viewer for Java. Bean API provides methods for displaying a PDF document from a Java application. First, import the com. Also import thejava. GUI and loading the PDF file, respectively. Specify. Border. Layout as the layout of the frame. Add the. Viewer to the center of the frame. The viewer properties are of two types: static and dynamic. Static properties are set before a viewer is displayed and may not be modified after the viewer is displayed. Dynamic properties may be set and modified after a viewer is displayed. Some of the properties that may be set for the Acrobat Viewer are listed in the following table. Values that may specified are: Single. Page, One. Column,Two. Column (same as Two. Column. Right),Two. Column. Left, and Two. Column. Right. Static. Default. Values that may be specified are: Fixed. Zoom, Fit. Page,Fit. Visible, Fit. Width,Fit. Visible. Width, Fit. Height, and. Fit. Visible. Height. Static. Default. Set to display large images in a PDF document. Dynamic. Server. As an example, print out the number of pages in the example document and the current page displayed. Set the zoom magnification to 1. To()method. Run the Java application in a command- line window. The number of pages for the example PDF document is 3 and the current page is 0, the index of the first page of the PDF document. The example PDF document gets displayed in the Acrobat Viewer. As the zoom level is set to 1. Java application, the PDF document is displayed with 1. Figure 1 illustrates the PDF document in Acrobat Viewer. Figure 1. PDF Document in Acrobat Viewer. Using the Viewer Commands. The Acrobat Viewer provides some viewer commands to edit the document and to modify the view characteristics of the document. The viewer commands are specified in the Viewer. Commandinterface, which is implemented by the Viewer class. To run a viewer command, invoke theexec. Menu. Item(java. lang. String viewer. Command) method of the Viewer class. For example, to run the. Zoom. To. For example, you can remove the Open and Open URL buttons in the Acrobat Viewer with. String. A PDF document may be zoomed in or zoomed out with the Zoom In or Zoom Out buttons. The Open and Open URL buttons allow you to open a different PDF document, which replaces the document currently displayed the Java AWT Component. The Acrobat Viewer GUI functionality may also be accessed with the com. API from a Java application. The different viewer commands are invoked with theexec. Menu. Item(java. lang. String viewer. Command) method of the Viewer class. The viewer commands corresponding to some of the Acrobat Viewer buttons are listed in the following table. This displays the pop- up menu seen in Figure 2. Figure 2. PDF document menu. The File and Edit menu items may also be invoked with a viewer command in a Java application. Some of the viewer commands corresponding to the File and Edit menu items are listed in the following table. The Actual Size button may also be invoked with the viewer command. Viewer. Command. Actual. Size. Displaying document at actual size. To fit the PDF document in the AWT Component's display space, select Fit Page, as illustrated in Figure 4. The Fit Page button may also be invoked with the viewer command. Viewer. Command. Fit. Page. Displaying document to fit page. To fit the PDF document to the width of the component, select the Fit Width button, as illustrated in Figure 5. The Fit Width button may also be invoked with the viewer command. Viewer. Command. Fit. Width. Displaying document to fit page width. Opening a Document. To open another PDF document, select the Open URL button, as shown in Figure 6. The Open URL button may also be invoked with the viewer command Viewer. Command. Open. URL. Opening a document from a URLIn the Open URL frame, specify the URL of the PDF document, as illustrated in Figure 7. The input field for the Open URL frame does not accept a ftp- style URL with an escape sequence, such as ftp: //host/my%2. On the other hand, escapes are OK in http- style URLs. Figure 7. Open URLBookmarking a Document. A PDF document page may be bookmarked in the Acrobat Viewer. The Acrobat Viewer bookmark frame displays the bookmarks to a PDF document with links to the different document pages. To bookmark a page, select the Bookmark button, as illustrated in Figure 8. Figure 8. Bookmarking a document. This adds a bookmark to the Acrobat Viewer, as shown in Figure 9. You can obtain the root bookmark in the Acrobat Viewer frame from a Java application with the get. Root. Bookmark()method of the Viewer class. The. PDFBookmark class represents a bookmark in a PDF document. PDF document with a bookmark. Selecting Text. In the Acrobat Viewer, text may be highlighted with the Select Text button. Select the Select Text button and select the text to be highlighted, as illustrated in Figure 1. Figure 1. 0. Selecting text. Conclusion. A Java application may need to display PDF documents. The Adobe Acrobat Viewer for Java. Bean API makes it feasible to display a PDF document from a Java application.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2016
Categories |