Open PDF in Swing Application

Hi Java GURUS
Firts of all, I would like to start with my introduction. My self Prashant Kadam. Right now i am developing a small system in java for my organization. This application is realted with art. And here we are dealing with PDF files. So application needs to open a PDF file within the frame / applet.
I have tried my level best to creack this problem. But still i am unable to solve it. I will be thank full to you, if i get solution from your end. I have also tried with some APIS. but they don't allow me to draw on this.
Thanks in adavnce
Waiting for a reply
Regards
Prashant Kadam

Hello,
The following should help:
http://sourceforge.net/projects/itext/
http://www.oreillynet.com/pub/d/1305
http://sourceforge.net/projects/gnujpdf/
http://sourceforge.net/projects/pdfbox/
Best regards,
Bert Szoghy
Quadmore Software Services
http://www.quadmore.com
"Home of Java Rollout for Windows"

Similar Messages

  • Open image in Swing Application

    Hi,
    I'm having trouble getting an image to open into my swing application and I cant figure out whats wrong. In response to selecting the "Open" button or menu item a JFileChooser opens up and i select an image but the image doesn't actually load. If anyone could help i'd really appreciate it.
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import java.io.*;
    import javax.swing.border.*;
    import javax.imageio.*;
    class PhotoEditor extends JPanel implements ActionListener {
         * Create the GUI and show it.  For thread safety,
         * this method should be invoked from the
         * event-dispatching thread.
        JMenu imageMenu, effectsMenu;
        JFileChooser fc = new JFileChooser();
        BufferedImage img = null;
           public JMenuBar createMenuBar() {     
         JMenuBar menuBar = new JMenuBar();
        /* Build the first menu: */
        JMenu fileMenu = new JMenu("File");
        menuBar.add(fileMenu);
        fileMenu.setMnemonic(KeyEvent.VK_F);
        //a group of JMenuItems under the File option:
            String[] menuItems1 = {"Open", "Save","Save As..", "Close"};
        String[] menuIcons1 = {"Open.gif", "Save.gif", "", ""};
        for (int i = 0; i<menuItems1.length; i++)
                  JMenuItem fileMI = new JMenuItem(menuItems1, new ImageIcon(menuIcons1[i]));
              fileMI.addActionListener(this);
              fileMenu.add(fileMI);
    //adding a separator to the drop down menu list
    fileMenu.addSeparator();
    JMenuItem exitMI = new JMenuItem("Exit", new ImageIcon("Exit.gif"));
    exitMI.addActionListener(this);
    fileMenu.add(exitMI);
    /* Code which builds all the menu here */
    return menuBar;
         public JToolBar createToolBar() {     
         JToolBar toolB = new JToolBar(FlowLayout.LEFT);
    toolB.setLayout(new FlowLayout());
    // contentPane.add(toolB, "North");
    JButton newButton = new JButton(new ImageIcon("new24.gif"));
    newButton.addActionListener(this);
    toolB.add(newButton);
    newButton.setToolTipText("New");
    newButton.setActionCommand("New");
    //adding a separator to the drop down menu list
    toolB.addSeparator();
    JButton openButton = new JButton(new ImageIcon("open24.gif"));
    openButton.addActionListener(this);
    toolB.add(openButton);
    openButton.setToolTipText("Open");
         openButton.setActionCommand("Open");
    /* More code building the toolbar*/
    return toolB;
         public void actionPerformed(ActionEvent e) {
    Object eventSource = e.getSource();
    if ((eventSource instanceof JMenuItem) || (eventSource instanceof JButton));{
    String label = (String) e.getActionCommand();
    //Sets up the Action Listeners
    if (label.equals("Exit")) {
    System.exit(0);
    // Closes application
    else if (label.equals("Open")) {
         openImage();
    /* More codes for each button or menu item */
    protected void openImage() {
              int returnVal = fc.showOpenDialog(this);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
    File file = fc.getSelectedFile();
         try {
                   img = ImageIO.read(file);
                        catch (IOException e1) {
    public void paintComponent(Graphics g) {
         super.paintComponent(g);
    g.drawImage(img, 500, 500, null);
    private static void createAndShowGUI() {
    //Create and set up the window.
    JFrame frame = new JFrame("Photo Editor");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    //Create a main label to put in the content pane.
    JLabel main = new JLabel();
    // main.setOpaque(true);
    // main.setBackground(new Color(128, 128, 128));
    main.setPreferredSize(new Dimension(800, 600));
    //Set the menu bar and add the label to the content pane.
    PhotoEditor mainmenu = new PhotoEditor();
    frame.setJMenuBar(mainmenu.createMenuBar());
         frame.getContentPane().add(mainmenu.createToolBar(), BorderLayout.PAGE_START);
    frame.getContentPane().add(main, BorderLayout.CENTER);
    //Display the window.
    frame.pack();
    frame.setVisible(true);
    public static void main(String[] args) {
    //Schedule a job for the event-dispatching thread:
    //creating and showing this application's GUI.
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    createAndShowGUI();

    Your PhotoEditor class extends JPanel. In that class you override paintComponent(). But you never add the panel to the GUI, so that method is never invoked.
    Personally I would have the PhotoEditor class extend JFrame. Then in the constructor you build all the components for the frame
    a) build the menu
    b) build the toolbar
    Then I would create a PhotoPanel class that you extend and override the paintComponent(). Then you add this panel to the GUI as your main panel.
    For a simple example of drawing a background image on a panel search the forum for my BackgroundImage example.

  • Opening pdf's in applications from safari - ipad

    When opening a pdf in an application from safari (i.e. pdf expert, goodreader) the pdf name does not show correctly.  Is there a way to properly create the pdf or open it differently to keep the name in the application?
    Thank you,
    Tom

    Hi Gerard
    You'll need to use at least Adobe Reader 8.1 with Safari 3, otherwise, Safari crashes. To install Reader 8.1.3, go here. At the site, click on the drop down selection menu and choose "Power PC 10.4.3 - 10.4.10". Otherwise, Adobe points you to Reader 9 instead of 8.
    Before installing Reader 8, go to your HD>Library>Internet Plug-ins folder and move to the trash the existing Adobe PDF plug-in. This way, you're ensured of a clean install of version 8.
    After the install, and prior to opening Safari, I suggest you go to your Applications>Utilities folder, open Disk Utility, highlight your HD and select "repair permissions".
    Post back and let us know if that stops the crashes.

  • Problem in Opening HTML Page in Internet Explorer from my Swing Application

    Hi,
    I am opening a HTML file in Internet Explorer from my swing application.I am using the code given below
    private final static String WIN_FLAG = "url.dll,FileProtocolHandler";
    private final static String WIN_PATH = "rundll32";
    String cmd = WIN_PATH + " " + WIN_FLAG + " " + url;
    // url is HTML file Path
    Process p = Runtime.getRuntime().exec( cmd );
    Here there are two things i need to address ...
    1)The HTML file is opening up,but it always opens behind the swing application,that makes me every time to maximize the HTML file after it being opened up.I want to open it in front of the Swing Application.I need to implement "Always On Top" functionality for the html page.
    2)Whenever i trigger action to open different HTML page,it opens in new Internet Explorer window.
    I need to open it in same IE window.
    how to solve out these problems ??? any help would be greatly appreciated .Thanks in advance.
    - Manikandan

    any idea about this ????

  • Help Needed in opening a HTML File from swing application

    Hi,
    I am opening a HTML file in Internet Explorer from my swing application.
    I am using the code given below
    private final static String WIN_FLAG = "url.dll,FileProtocolHandler";
    private final static String WIN_PATH = "rundll32";
    String cmd = WIN_PATH + " " + WIN_FLAG + " " + url;
    // url is HTML file Path
    Process p = Runtime.getRuntime().exec( cmd );
    The HTML file is opening up,but it always opens behind the swing application,that makes me every time to maximize the HTML file after it being opened up.
    I want to open it in front of the Swing Application.
    Any Help Please ?
    - Manikandan

    Check your Application's JFrame properties (may be ur Frame is set to be in top position ,always),and also check running your application in some other OS.

  • How to use Adobe Reader, open pdfs with OS X 10.6.7?

    I just got a new MacBook Pro. When I try to download Adobe Reacer or open PDFs, I get messages that say this type of Mac doesn't support Adobe Reader. I use PDFs all the time.  How do I get around this?

    I am not being allowed to downoad/install Adobe Reader or open PDFs.  When I try to do either one, I get a message that this type of Mac doesn't support Adobe Reader.  I just talked to Apple Care. They told me how to open PDFs with another application andd referred me to Adobe for installation questions.  Thanks.

  • Launching Browser From Swing Application - Help Needed

    Hi,
    I am opening a HTML file in Internet Explorer from my swing application.
    I am using the code given below
    private final static String WIN_FLAG = "url.dll,FileProtocolHandler";
    private final static String WIN_PATH = "rundll32";
    String cmd = WIN_PATH + " " + WIN_FLAG + " " + url;
    // url is HTML file Path
    Process p = Runtime.getRuntime().exec( cmd );
    The HTML file is opening up,but it always opens behind the swing application,that makes me every time to maximize the HTML file after it being opened up.
    I want to open it in front of the Swing Application.
    Any Help Please ?
    - Manikandan

    Browser Utility - Class to launch a URL in a web browser in
    a platform independent manner. Includes an optional swing
    GUI allowing user customization. [Open Source - GPL]
    http://ostermiller.org/utils/Browser.html
    BrowserLauncher - Open the system web browser with
    particular attention paid to various Macintosh systems.
    (Freeware)
    http://browserlauncher.sourceforge.net/
    Java World - With a little platform-specific Java code, you
    can easily use your system's default browser to display any
    URL in Windows or Unix.
    http://www.javaworld.com/javaworld/javatips/jw-javatip66.html
    JConfig - Class Libraries that allow a URL to be launched in
    a browser on Windows, Unix, or Macintosh. [Commercial]
    http://www.tolstoy.com/samizdat/jconfig.html
    Apple - MRJFileUtils.openURL() not implemented in Mac OS X.
    http://developer.apple.com/techpubs/macosx/ReleaseNotes/JavaGMWebReleaseNotes.html#MRJToolkit
    Apple - How one would open a URL in a web browser on a
    Macintosh.
    http://developer.apple.com/qa/java/java12.html

  • Blank window when opening PDF

    Hello,
    When I try to open one PDF file from http://www.adobe.com/products/livecycle/digitalsignatures/ via open in the new tab, and it will prompt up the following window, is there anybody who know the reason or May I know how I shall troubleshoot?  So far, this issue happens in Win 7 and most versions of Adobe Reader.
    I also got this issue when opening PDF in web application. Please help.
    Joe

    I got this log from event log, anybody knows why?
      Faulting application name: java.exe, version: 5.0.110.3, time stamp: 0x45826b52
    Faulting module name: AcroPDF.dll_unloaded, version: 0.0.0.0, time stamp: 0x49a8480b
    Exception code: 0xc0000005
    Fault offset: 0x71a09550
    Faulting process id: 0xc18
    Faulting application start time: 0x01cd85884ffd4d6b
    Faulting application path: c:\program files\application\jre\bin\java.exe
    Faulting module path: AcroPDF.dll
    Report Id: d5b84c6d-f17d-11e1-8ad9-001e65fc33d2

  • Opening a PDF file from a swing application in MAC

    HI everyone,
    Actually I am developing a swing application which should be executable in both windows and Mac (even other) platformes. In my panel I have an icon which leads to a pdf file. I saw in the following thread:
    http://forum.java.sun.com/thread.jspa?forumID=17&threadID=617767
    that we can use
    Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + file);to open what ever file in windows. I want to know what should I do if this application is running on Mac or Linux! I have never worked with these OS so I do not have any idea how to resolve the problem.
    Can anyone help me with this matter?? That would be really nice of you to reply :)
    Thanx and have a great day.

    Thank you for replaying so soon..
    Well you are right by using a widget and etc.. but the problem is that I have been told that this application should open a PDF file that has bookmarks to each chapter of the text and one can make a search on this text by using pdf search.. So I do not have any other choice than opening a pdf :D and my time is unfortunately limit.
    For solving the problem that the user may not have PDF reader.. well I have been told that user should install the pdf reader, so in my application package I am putting the installation file of PDF.
    But going back to my problem.. I guess is someway I have to get the OS type of the user and I have to do a SWITCH or something on the OS type and then change the content of the Runtime.exec(). But the question is how can I get the OS type and what should I change in Runtime.exec().
    So now any idea? any solution??

  • Viewing and printing a PDF file from Java Swing Application

    Hello,
    I need to view and print PDF files from Java Swing Application.How do I do that?I appreciate your help.
    Thank you
    Sumana Somareddy

    If you have a link to the URL pointing to the PDF file, you can allow the browser to open it. Then use the print function of the browser to print the PDF document.
    Regards,
    Tak.

  • Is there any Open source Reporting Toll for using in swing application ?

    Is there any reporting system like crystal report or any thing for report generation. Using JTable class it is so time taking job. I have downloaded Eclipse with crystal report embedded, and have created a report but can not integrate the report with JFrame with any menu item action. All the code i got releted to JSP. and few code get that are using
    //Crystal Java Reporting Component (JRC) imports.
    import com.crystaldecisions.reports.sdk.*;
    import com.crystaldecisions.sdk.occa.report.lib.*;
    //Java Imports.
    import javax.swing.*;
    public class JRCViewReport {
         private static final String REPORT_NAME = "JRCViewReport.rpt";
         public static void launchApplication() {
              try {
                   //Open report.
                   ReportClientDocument reportClientDoc = new ReportClientDocument();
                   reportClientDoc.open(REPORT_NAME, 0);
                   //Launch JFrame that contains the report viewer.
                   new ReportViewerFrame(reportClientDoc);          
              catch(ReportSDKException ex) {     
                   System.out.println(ex);
              catch(Exception ex) {
                   System.out.println(ex);               
         public static void main(String [] args) {
              //Event-dispatching thread to run Swing GUI.  This is good practice for Swing applications
              //to help ensure that events are dispatched in a predicatable order.
              //For more information on using this method, refer to the SUN site below for more details:
              //http://java.sun.com/products/jfc/tsc/articles/threads/threads1.html
              SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                        //Hand-off to worker function to start application.
                        launchApplication();                    
    }Also there is one file ReportViewerFrame.java
    but the error is "*com.crystaldecisions.reports.sdk*" not found
    Please help ..........................................................

    I have already use Jasper Report. Thakns a lot for your suggestion. Now I think i have solved your problem...... View the code.. this code will not open the JasperViewer but from the background it will be printed and after calling the printing function you can save a data in the database ------------------------
    JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
            Connection con = Database.getConnection(); // your database connection
            jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, con);
            for(int i=0;;i++) { //print all pages
                try{
                    JRPrinterAWT.printPages(jasperPrint,i,i,false);
                }catch(Exception e) {
                    break;
            }

  • Is there  a way to make Safari open PDF pages without opening Finder and select Reader from my applications folder?

    Simple, When I want to open a .pdf page from the web, I get Finder to open and I have to go to my applications folder to pick up Acrobat reader, Is there a way to have Safari doing it all by itself, Preview, or any other program?

    Right or control click a PDF file you have on the hard drive then click: Get Info
    In the Get Info panel click the pop up menu next to:  Open with
    Select the app you want to open PDF files from the pop up menu then click:  Change All

  • Firefox won't open PDF files after I removed older version of PDF-xChange Viewer and installed the lastest version of PDF-xChange Viewer. MS Explorer which I am now force to use works OK. I have checked the Applications window in Tools/Options and it l

    Firefox no longer opens PDF files. Explorer works OK. I have checked the Applications window in the Tools/Options and it says I am using PDF-xChange viewer....It just does not do anything. I get the message in the Download Error window which says...."could not be saved, because you cannot change the contents of that folder. Is the same error which I get when I attempt to open a PDF file on a webpage using the Firefox browser....Explorer works OK so I am now forced to Explorer to read PDF files via a browser.
    == This happened ==
    Every time Firefox opened
    == After removing a old copy of PDF-xChange Viewer and updating to the last version

    The error message suggests that the file (pdf) that you're trying to download cannot be saved in the folder Firefox tries to save it in.
    This can be due to several things - it could be a non-existing folder (could be a problem with the updated application), the hard drive could be too full to store the file (less likely if you can generally surf the net without error messages) or it could contain an error.
    To complicate things a little further, it seems to me that you have (at least) 3 different PDF-handling plugins in Firefox from different programs:
    PDF-XChange Viewer Netscape Gecko Plugin
    Adobe PDF Plug-In For Firefox and Netscape "9.3.2"
    Zeon PDF Plugin For Mozilla
    This shouldn't matter too much, thou, as it will most likely simply use either the latest installed or the first one it finds when looking up associations for files of type 'pdf'.
    First, in Tools > Options... > tab General > section File download, select "Save files in" and Browse your way to a (non-writeprotected!) folder on a drive where you're certain there is enough free space - like the Desktop folder to make the files end up on your Windows desktop.
    Second, under Applications as you mention yourself, find all document types related to PDF files, and set these to one of the programs. Check the entire list to be sure there isn't one hiding under one of the other programs' document types (Adobe Acrobat document, PDF X-Change and Zeon).
    Restart Firefox, and try opening a PDF again.
    If it fails once more, try changing the documents again to one of the other programs, like "Use Adobe Acrobat (in Firefox)".
    If it STILL fails, change it to simply "Save file". Then you can simply browse your way to the download folder with Windows Explorer, and doubleclick the PDF file to see which program actually handles PDF files as default on the machine, and if it works properly.
    If Firefox flatly refuses to save the PDF files in a folder which you're certain both exist and has space for the file, some (probably security related) program is most likely interfering with Firefox, preventing it in storing PDF files on the system.

  • This is actually a FF 4 RC question...but I can no longer open PDF files...the page just goes blank. No option in applications to set a PDF viewer as default. Help!

    How do you open PDF files in FF4 RC? The application section in options doesn't have PDF as an option to associate with a program. Whenever I click on a PDF file, I just get a blank tab.

    Hi there,
    You're running an old version of Safari. Before troubleshooting, try updating it to the latest version: 6.0. You can do this by clicking the Apple logo in the top left, then clicking Software update.
    You can also update to the latest version of OS X, 10.8 Mountain Lion, from the Mac App Store for $19.99, which will automatically install Safari 6 as well, but this isn't essential, only reccomended.
    Thanks, let me know if the update helps,
    Nathan

  • Help - "Acrobat is being used by another application and cannot open PDF files until the other application is closed."

    Hello,
    I searched this site and google for this error terminology and come up dry.  I support a user who has been for years using Acrobat 5 (yes, I know...) to read files in a client DB program, as well as other PDF files on their PC.  In the last week or so, they have started gatting this error "Acrobat is being used by another application and cannot open PDF files until the other application is closed." any time they attempt to open a PDF file attached to an email (via Outlook).
    It is my understanding that they cannot upgrade to a newer version of Acrobat because of limitations of their client software, but had not previously had any issues viewing PDF notes from the DB, and PDF attachments in their email.
    I have tried uninstalling and re-installing, as well as tried using Adobe Reader 7 & 9 in conjunction with Acrobat to try to get around this issue, but have not been successful.
    Any ideas?
    Thanks,
    Jesse

    I don't have an answer to your technical problem. The product I assume is Acrobat that you are talking about (based on the post title), Adobe is the company name. This is a good place to ask questions on Acrobat if folks can figure out what you are talking about. They will ask for the product version number (like AA9.3.3), operating system, and other applications if appropriate. Also, just what you are doing that generates the message.
    As for Adobe, you are not likely to get an answer from them here in the user forum. You will be lucky if you can get an answer if you can contact them and not be on hold for more than an hour (sorry, this is why a lot of folks end up in the forum).
    So, to help others try to answer your question, what are the products and versions involved? What OS? What are you doing when the message comes up.

Maybe you are looking for

  • How do i save a .m4v file to the movie folder when it will only save to the music folder?

    I have a movie file in my ITunes music folder that i want to mover to the movie folder because it is a movie. The file type is a .m4v. When i click and drag it itunes wont let me drop it in movies. What do i do??

  • Re: Windows message on Adobe Media Player.Ink

    Please forgive if this is the wrong Forum but I am having a difficulty accessing a correct one!! Although using Adobe Reader, etc I am getting a popup window stating "The drive or Network connection that the shortcut 'Adobe Media Player.Ink ' refers

  • My Dock is not opening - Please help.

    I have my dock hidden so when i hover my mouse over it, the dock pops up usually but now it stay hidden unless i use a keyboard shortcut to open it. I have reinstalled the OS via archive and install but i still have the problems. Can anyone help me r

  • Enterprise or Standalone CA for Windows and linux computers

    Hi i plan to deploy a certificate architecture mainly for our internal web server and no more receive the certificate warning pop up So first i will install an offline Root CA Then i will setup a subordinate CA My question is about the type : standal

  • The Best Way To Edit Multiple Photos On One Scan

    Hi... I would like to know what the best way to edit out photo's from a scan that has multiple photo's? It seems like I must make a duplicate of the scan, in the amount of photos, on that one scan and then crop each "duplication". Is there some other