Open a pdf in a swing jpanel

I have a url for a pdf file and I want to open that file in a swing jpanel.I have upgraded to Java 1.6.0_27 and previously had 1.5.0_06
In Java 1.5 ,I was using jdic to do this for that the user needed to download jdic setup on their desktop to view images
but now I dont find any documentaion for java 1.6.0_27 and jdic setup.So i thought of doing this without the jdic .In java 5, I was using the beow code to show the pdf in swing jpanel.This basically embedds pdf in a web browser and then add it to swing jpanel.
import org.jdesktop.jdic.browser.*;
import org.jdesktop.jdic.browser.internal.*;
WebBrowserUtil.enableDebugMessages(false);
WebBrowserUtil.getDebug();
WebBrowser webBrowser = null;
URL pdfURL = testUrils.getPdf("Pathof .pdf");
try {
webBrowser = new WebBrowser();
webBrowser.setDebug(false);
webBrowser.setURL(pdfURL);
} catch (java.lang.UnsatisfiedLinkError el) {
catch (Exception e) {
//System.out.println(e.getMessage());
System.out.println("Error: " + e.getStackTrace());
JPanel pantestBrowser= new JPanel();
pantestBrowser.setLayout(new BorderLayout());
pantestBrowser.setPreferredSize(new Dimension(700, 500));
pantestBrowser.setLocation(0,0);
pantestBrowser.add(webBrowser, BorderLayout.CENTER);
I want to do the same thing without the jdic webbrowser.Is there a way out to do this?
I tried to do with java.awt.desktop
Desktop desktop=Desktop.getDesktop
desktop.browse(pdfurl.toURI())
This opens the pdf in a new adobe window and not inside the jpanel.
Thanks,

885522 wrote:
I have a url for a pdf file and I want to open that file in a swing jpanel.I have upgraded to Java 1.6.0_27 and previously had 1.5.0_06
In Java 1.5 ,I was using jdic to do this for that the user needed to download jdic setup on their desktop to view images
but now I dont find any documentaion for java 1.6.0_27 and jdic setup.Have you tried to install and use jdic with 1.6 exactly as with 1.5?
To be honest I don't find any documentation either, that would state jdic is independent of the JRE version (various links broken). But since jdic essentially provides a wrapping API to deal with native resources, I would assume it is relatively independant of changes that have occurred in the JRE between 1.5 and 1.6. At least I would try it :o)
So i thought of doing this without the jdic .In java 5, I was using the beow code to show the pdf in swing jpanel.This basically embedds pdf in a web browser and then add it to swing jpanel.Does this code work with 1.6?
I want to do the same thing without the jdic webbrowser.Is there a way out to do this?
I tried to do with java.awt.desktop
This opens the pdf in a new adobe window and not inside the jpanel.Yes, as documented by the Javadoc.
Good luck.
J.
EDIT: please use code tags when posting code, to display it properly formatted. Like this: {noformat}this.isFormattedCode(){noformat}:
this.isFormattedCode()

Similar Messages

  • Open a pdf file in a JPanel

    Hey
    I have one application and for the help part I want to have JPanel with the content of a help.pdf file.
    Can somebody help me...
    Thanks

    Have a look for the api iText at http://www.lowagie.com/iText/

  • 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??

  • Opening a web page in a JPanel

    Is it possible to open a web page in a JPanel? I do not need to browse...just view a single page.

    Is it possible to open a web page in a JPanel? I do
    not need to browse...just view a single page.Have a look at the javax.swing.text.html package - contains functionality for rendering HTML.

  • How to open an PDF file from Java Application

    Hi
    I am developing a GUI application in java swing.
    on clicking one button, I want to open PDF file from my swing application.
    Is there any API through which I can achieve this?
    Tapan Maru
    Sun Certified Java Programmer

    Here's a way to do it (if I understand you
    correctly). Just let explorer.exe do it for you.
    import java.awt.*;
    public class openPDF
         Desktop desktop = Desktop.getDesktop();
         public openPDF()
              open("test.pdf");
         public void open(String path)
              try
                   Runtime.getRuntime().exec("explorer.exe "+path);
    } catch(Exception e) { System.out.println("NAI!
    I! ERROR!\n"+e); }
         public static void main(String[] args)
              openPDF myApplication = new openPDF();
    Why do you have a Desktop object as a member but instead of using it, you execute a command with Runtime (which is not platform independent!)???
    -Puce

  • Opening a PDF files.

    Hi Everyone,
    I'm new to Java so please stay patient. My high school projects requires from me to add swing button to my frame which opens an external pdf file - it'a a manual to this application. I've googled it and there's nothing easy to understand for a dummy like me. The one thing that caught my eye was Desktop.open();
    Please, any suggestions?
    Thanks! :D

    Coduy wrote:
    Hi Everyone,
    I'm new to Java so please stay patient. My high school projects requires from me to add swing button to my frame which opens an external pdf file - it'a a manual to this application. I've googled it and there's nothing easy to understand for a dummy like me. The one thing that caught my eye was Desktop.open();Desktop.open() will work, as long as there is some program installed to "take" a PDF file. Say you have Acrobat Reader installed, Desktop.open() should invoke it to show the PDF file. That is all controlled from within the operating system though, there is no way to guarantee it. Just like there is no way you can guarantee that a user can open a PDF when you instruct them to double click it.
    What you probably don't want to do is try to show the PDF in your application, as then you need to deal with not only loading the PDF data but also displaying it.
    Otherwise here don't expect your find ready-made java code and people are too strict here especially EJP ;)What a bum thing to say, really you should be ashamed and I don't only mean that you shouldn't single someone out. EJP nor any of the other regulars aren't strict, they use their brain. For example: they are smart enough to know that simply spoon feeding code isn't helping anyone. You are either helping a lazy git who doesn't deserve it or you are taking away the opportunity for an eager mind to learn and work things out for him/herself - either way its a disservice to give cut & paste solutions.

  • How can I open a PDF stored in IXOS and then display it in a BSP

    Hello gurus,
    I have created a PDF icon and an onclick action to open a pdf, that displays on every row of an assignment block in the actions column, but I do not know the technical process to determine how to get a PDF from the IXOS system from the line selected. (even if I know it depends on an ID attribute of that assignment block) I want to to call a transaction launcher with the url for the pdf in the IXOS that has an ID that identifies which line in the assignment block the user has clicked the pdf icon for (does that make sense?)
    Therefore, I am assuming the PDF should correspond to the relance ID of the row in the assignment block, but I would like more information as per the business logic involved in able to achieve the desired results for this particular specification. I already confirmed that the XURL or any other attribute in the BOL object does not contain the URL to use for this. I have looked at the class I was told that it may contain the required business logic for determining which PDF in IXOS to fetch for a particular row, and I am currently trying to reverse engineer the logic through looking at other code and using the debugger, but so far I haven'T had much luck.
    Here are some questions I have now for the functional side in the meantime:
    1) Can we fetch the PDF in IXOS for each line of an assignment block?
    2) Which URL should I call with the transaction launcher? a URL link to the PDF on the IXOS system??
    3) Do we have to configure a transaction in the IMG to be launched?
    4) Do we have to create a logical link there that I will make dynamic to call the right PDF for each table line? 
    5) Are there any existing examples of this or a similar functionality/ logic that I could refer to, preferably in CRM 7 WebUI?
    6) Do you have any code to just display a PDF in a new window? Or prompt a download?
    One possible way I thought of would be for me to have a logical link defined in the IMG, that I could call passing it different attributes (eg. some object id, etc) and then return the PDF and display it in the UI in a new browser window by itself. Alternatively, we can just prompt a download. What do you think would be the optimal behaviour here?
    Please do not hesitate to propose any potential solution. Any partial answers/ links to wikis/ other threads, anything would be much appreciated.
    Thank you in advance.
    Best regards,
    Jonathan Laplante

    Hi,
    I partially answered your question in another posting but I feel that you´re in the wrong forum for your problem. This is for BSP development and you talk about CRM.

  • Error while opening a Pdf in Acrobat 9.3.4

    Hi
    Am getting the below error message while opening any pdf on Citrix (built on Windows 2003 Server) with Acrobat 9.3.4.
    Has anyone else also seen the same? and how to resolve the same?

    Update:
    Opened the Pdf and found out that the certified signature has become invalid.

  • Error while opening a pdf file.

    Hi All,
    I have Adobe Reader 10.1.3 installed on my system.
    I am getting the following error : "Adobe Reader could not open 'abc.pdf' because it is either not a supported file type or because the file has been damaged(for example, it was sent as an email attachment and wasn't correctly decoded)". This error is coming at random, i.e. if I open a file at one time, it will open without any problem, but at another time the same file gives this problem. Could anyone please tell me as to why this is happening and how to resolve this?

    This message occurs if a PDF file is damaged, either during downloading from a website, or during transport as an email attachment.
    Are you getting this error for a file that is stored on your local HD?  For this to occur at random, as you write, I can only imagine that the disk sector where it is stored is damaged.
    Can you run a disk diagnostics, e.g. CHKDSK on Windows?

  • When I open a pdf document from my dropbox to view it, the document shows up blank, even though it is filled out. This also happened with pdf documents that have been e-mailed to me.

    When I open a pdf document from my dropbox to view it, the document appears blank, even though I know the information is actually there. This also has happened with pdf documents that have been e-mailed to me, then opened to view and they are blank?? Why are they showing up blank?

    When I open emails with PDFs I click on the attachment (doing this all on my iPad) it gives me the option to "open in iBooks", I accept then after that the document is sucked into my iPad but I can't do anything with the PDF after that.  Where is the actual file on my iPad? Why can't I email or send these PDFs to my cloud (Dropbox)?
    It's like once they go into iBooks they're stuck forever.

  • When I attempt to open a PDF file I saved from a website, I get the message "There was an error opening this document. The file is damaged and could not be repaired." Is there any way to correct this problem?

    When I attempt to open a PDF file I saved from a website using Safari, I get the message "There was an error opening this document. The file is damaged and could not be repaired." When I save the same PDF file using FireFox it opens up immediately. Is there any way to correct this problem with Safari?

    Back up all data.
    Triple-click the line of text below to select it, the copy the selected text to the Clipboard (command-C):
    /Library/Internet Plug-ins
    In the Finder, select
    Go ▹ Go to Folder
    from the menu bar, or press the key combination shift-command-G. Paste into the text box that opens (command-V), then press return.
    From the folder that opens, remove any items that have the letters “PDF” in the name. You may be prompted for your login password. Then quit and relaunch Safari, and test.
    The "Silverlight" web plugin distributed by Microsoft can also interfere with PDF display in Safari, so you may need to remove it as well, if it's present.
    If you still have the issue, repeat with this line:
    ~/Library/Internet Plug-ins
    If you don’t like the results of this procedure, restore the items from the backup you made before you started. Relaunch Safari again.

  • When I sign in to the Adobe Reader XI (which is the only option that I have to open a pdf document, I will sign in to the Adobe ID sign-in page. After I do this, the "Convert To" box goes "gray" and I am unable to convert the document I have selected.  It

    When I sign in to the Adobe Reader XI (which is the only option that I have to open a pdf document, I will sign in to the Adobe ID sign-in page. After I do this, the "Convert To" box goes "gray" and I am unable to convert the document I have selected.  It was working great for the first week that I used it, but now it doesn't give me the converting option.  I am very frustrated as I have done nothing to change anything, and I was thinking this was so great...now I am just pulling out my hair and do not have the option of calling anyone since no phone numbers are listed. I am VERY busy and do not have time to sit and wait over a half an hour to "chat", which I tried to do yesterday.  All I want to do is very simply, convert pdfs to Word.  I have paid for this and am not getting any help. I am not very savvy when it comes to Adobe this program and Adobe that program...I feel I am being scammed as I do not get simple answers for something that appeared was going to be simple. You can't even call customer service to talk to someone live to help walk you through. 

    Hello Kathie,
    Sorry for the inconvenience that has caused to you.
    Please let me know if you have tried converting any other PDF to word with Reader.
    Alos, please sign up at "https://cloud.acrobat.com/" using your Adobe ID credentials. Click on 'ExportPDF' tab and upload the PDF that you want to convert to Word.
    Let me know if this converts fine.
    Hope to hear from you.
    regards,
    Anubha

  • Opening a PDF in a specific page from a PDF created in indesign

    Hello, I'm working with CS4 and I need you to click on a button, or from a "hyperlink" in a text, open a pdf file but for a given page.
    I can not change the target pdf and also I have to access a single pdf into multiple pages, put an example
    persone one speaks at the pdf 1, on page 14
    person two speaking in pdf 1, on page 15
    I wish that when you click on the person 1 opens pdf 1 on page 14, and when you click on the person 2 opens pdf 1 on page 15
    Thanks in advance
    mateo

    Thanks, I had not noticed in the new dialogue coming out. Thank you very much. A greeting.
    Muchas gracias
    mateo
    Rectification
    ohhh, no, the page references are to an indesign document, not a PDF
    I have not indesign files where you created the PDF to which I have to jump and I can not add bookmarks to pdf, pdf files are protected.
    thanks

  • I am Required to Save before opening a PDF file in FF 10.0.1. How do I get FF to open the PDF file?

    I am Required to Save before opening a PDF file in FF 10.0.1. How can I get FF to open a PDF as the default?

    Check your add-ons:
    Cmd+Shift+A
    Make sure the Adobe Acrobat NPAPI Plug-in is set to Always Activate.

  • Can not open all .pdf files in Yahoo Mail.

    Three computers using Windows XP and Internet Explorer can open all .pdf files in Yahoo
    Mail. The fourth and newest Computer with XP Pro, Internet Explorer, and the latest Adobe
    Reader can only open some, but not all, .pdf files in Yahoo Mail. Nothing happens when
    the window is clicked to open file. How can this be fixed?

    Adobe Reader isn't my favorite, but neither are smug and uninformed assertions about Preview. There are PDFs that render only squares and marks under Preview (http://apple.stackexchange.com/questions/24209/this-pdf-displays-with-question-m arks-instead-of-letters), which is a common problem in MS Windows Office generated PDFs, so you may actually need Adobe Reader for Mac.
    If you need to use Adobe Reader (as I do), then it may depend on the filesystem type where you save your PDF.  For example, our Macs are network homed.  Saving to desktop produced the error reported above no matter whether I used Safari:Save As, or the PDF save icon. 
    However, when I saved to a local drive (such as /tmp), then it worked.  I don't know why file system makes a difference, unless Adobe is doing something with extended attributes that doesn't get written correctly to some filesystems.
    Hope this helps.

Maybe you are looking for

  • I get "an error has occured" when trying to download from the AppStore.  I can not re-download as the button is not active.

    I encountered the response "an error has occured" when I downloaded Maverick X from the App Store.  I can not try to re-download as the download button is not active.  I have tried rebooting and to get the download from apple.com but it keeps redirec

  • Newbie trying to make it go with MSN

    I have been through a number of posts but I can't seem to make this thing go. All my family use MSN for video chatting on PCs. We have the new iMac with the camera built in and iChat 3.0.1. How can I set up Video chat with Audio so that I can communi

  • 6 dropped calls in 45 minutes conversation

    Yesterday going and coming form work (in New York- Staten island to Brooklyn )I had 6 dropped calls in 45 minutes conversation, that never happen to my iphone before, well occasionally I did get some dropped calls, but not as much as yesterday. It wa

  • Sun Compiler Opengl

    Hi, Ive tried to install glut and opengl so the sun compiler can compile my opengl sources, however I cant seem to get it to work. Can I use the NVIDIA Opengl Headers and binaries or do I have to use Mesa / Sun GL? Can someone give me a step by step

  • Slow Finder windows

    Why does my new Mac Pro take 3-4 seconds before it will display a listing the files in a folder in the Finder Window set to display columns. It seems like it has to examine the folder because, if I select a different folder and then select the first