Results 1 to 6 of 6
  1. #1
    asai is offline Senior Member
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    115
    Rep Power
    0

    Default View pdf inside JPanel

    Hi,

    I am trying to view a pdf file inside a JPanel.
    Any suggestions how to do this?

    For picture type files i am using a label like this:
    Java Code:
    label.setIcon(new javax.swing.ImageIcon(filename));
    Last edited by asai; 01-19-2013 at 05:45 PM.

  2. #2
    asai is offline Senior Member
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    115
    Rep Power
    0

    Default Re: View pdf inside JPanel

    Have been playing around with this and have come a bit further.
    However I am a bit stuck...

    I am using icepdf for this, ICEpdf Open Source Java PDF Viewer - ICEsoft Technologies
    Here is some of my code:
    Java Code:
    SwingController controller = new SwingController();
    SwingViewBuilder factory = new SwingViewBuilder(controller); 
    readerPanel = factory.buildViewerPanel();
    controller.openDocument(filename);
    But there isn't anything showing up in my readerpanel. Any suggestions?

  3. #3
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,585
    Rep Power
    12

    Default Re: View pdf inside JPanel

    There's not enough to go on. What (type) is readerPanel? Do you add it to a frame? And make it visible (including making sure it has a larger than zero size)? What does the builder class do if there is an io error (like not being able to find the file)?

    Things would be clearer if you posted a small program that compiles, runs and illustrates the problem. Your best bet for having someone look closely at it would be to make it small: no logic that isn't part of the (non-)appearance of the pdf.

    ---

    ICEpdf javadocs are at ICEpdf Viewer RI

  4. #4
    asai is offline Senior Member
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    115
    Rep Power
    0

    Default Re: View pdf inside JPanel

    I am going at it differently: Any examples in how to use default program for a file type to open files from Java?

  5. #5
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,585
    Rep Power
    12

    Default Re: View pdf inside JPanel

    Check out the Desktop class. As its API docs state, it "allows a Java application to launch associated applications registered on the native desktop to handle a URI or a file".

  6. #6
    asai is offline Senior Member
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    115
    Rep Power
    0

    Default Re: View pdf inside JPanel

    Thanks, I think this is the solution I want.

Similar Threads

  1. Replies: 1
    Last Post: 12-19-2012, 09:04 PM
  2. An image inside JPanel.
    By Rinas in forum AWT / Swing
    Replies: 4
    Last Post: 10-03-2011, 08:17 PM
  3. JPanel inside Jtabbed isn't display
    By Ravanelly in forum Advanced Java
    Replies: 7
    Last Post: 06-08-2010, 11:19 PM
  4. How to add JFrame inside JPanel
    By niteshwar.bhardwaj in forum Java 2D
    Replies: 8
    Last Post: 12-13-2009, 09:41 PM
  5. refresh view of Jpanel
    By VineetKumar in forum AWT / Swing
    Replies: 1
    Last Post: 11-21-2008, 02:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •