JPedal includes a very comprehensive PDF viewer which makes use of both Swing and JavaFX for the best possible viewing solution. It is written in Java and has a simple way of embedding the viewer within your own application.
If you do not have a JPedal, you can download a trial copy from here.
java -jar jpedal.jar --view "pdfFile.pdf"
// If you want to set a look and feel System.setProperty("org.jpedal.userControlledLAF", "javax.swing.plaf.metal.MetalLookAndFeel"); Viewer viewer = new Viewer(rootContainer,null); viewer.setupViewer();
This uses the JPedal Viewer class. If you want to set a look and feel for the viewer standalone, you can as shown on this FAQ or you can add your LookAndFeel to your application by just adding the line show above, if you want your own LookAndFeel just set the flag as “true”.
// If you want to set your a look and feel System.setProperty("org.jpedal.userControlledLAF", "javax.swing.plaf.metal.MetalLookAndFeel"); //Create display JFrame JFrame frame = new JFrame(); frame.getContentPane().setLayout(new BorderLayout()); final JPanel rootContainer = new JPanel(); //additional label to show this is another program final JLabel label = new JLabel("JPedal viewer Test"); label.setFont(new Font("Lucida",Font.BOLD,20)); label.setForeground(Color.RED); frame.add(label,BorderLayout.NORTH); Viewer viewer = new Viewer(rootContainer,null); viewer.setupViewer(); //add viewer to your application frame.add(rootContainer,BorderLayout.CENTER); frame.setTitle("Viewer in External Frame"); frame.setSize(800,600); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true);
As well as adding the Viewer to your own application you can also customize the Viewer to control which options are present using the Viewers properties file. Once you have created a properties file that displays the options you require it can be loaded by the Viewers constructor shown above. To do this you just need to pass in the file’s path as the second parameter.
Still need help? Send us your questions.