Viewing PDF or CHM (compiled HTML) files in a JEditorPane (Editorkit av.?)

I want to view PDF or CHM files in a JEditorPane, for example for use in JavaHelp. Does anybody know if there is a free EditorKit available for viewing at least one of these two kinds of files (especially for PDF), or if it is possible to "plug" the Adobe Acrobat reader into a JEditorPane???

a usuful url, but I'am afraid this is not the answer for the question :)
as far as I know, either Sun or other third vendor does not provide the toolkit for PDF
or CHM viewing in JEditorPane.

Similar Messages

  • Writing html file in a jeditorpane

    I have read one of your threads titled as "How to insert a string in a JEditorPane (Urgent)". according to this thread I am using insertString() method to write in an jeditorpane. what I am writing is an html file. when I used insertString() method it doesn't show the html content in my jeditotpane. it displays the source code of my html file. I have setContentType("text/html"); moreover I used setText() and it shows the html file correctly but it over writes the previous content of jeditorpane. please help me to be able to
    write to a jeditorpane without overwriting and displaying html file properly not its source code.
    following is my code:
             fr = new FileReader("myfile.html");
         BufferedReader br = new BufferedReader(fr);
         while ((lineread = br.readLine()) != null)
              find.append(lineread);
                       do{
                             last = find.lastIndexOf("str");
                          Integer index = myJEditorPane.getSelectionEnd();
                   String temp = index.toString();     
                   start=find.indexOf(temp, end);
                   end=find.indexOf("str", start);
                            Document doc = mynewContentPane.getDocument();
                   try{
                        doc.insertString(doc.getLength(),find.substring(start, end),null);
                   catch(BadLocationException exc){
                        exc.printStackTrace();
                   }Edited by: nasi on May 7, 2010 8:59 PM
    Edited by: nasi on May 8, 2010 12:09 AM
    Edited by: nasi on May 8, 2010 1:37 AM

    Welcome to the Sun forums.
    Subject: writing html file in a jeditorpane
    If you mean a JEditorPane then please use the correct case, so we can be confident you refer to the J2SE class, as opposed to a 3rd party jeditorpane that we neither know, nor support.
    nasi wrote:
    I have read one of your threads titled as "How to insert a string in a JEditorPane (Urgent)". ..I guess you mean [How to insert a string in a JEditorPane (Urgent)|http://forums.sun.com/thread.jspa?threadID=282569] from 2002. A lot has changed since 2002, but I suspect the basic way of appending text to a Document has not.
    BTW - Good to see you arrive with some Google-foo. ;-)
    ..according to this thread I am using insertString() method to write in an jeditorpane. what I am writing is an html file. when I used insertString() method it doesn't show the html content in my jeditotpane. it displays the source code of my html file. I have setContentType("text/html"); moreover I used setText() and it shows the html file correctly but it over writes the previous content of jeditorpane. I've not played much with changing existing documents, but try this source (adapted from code nabbed from the thread you mentioned).
    import javax.swing.text.*;
    import javax.swing.*;
    public class InsertStringTest {
        public static void main(String[] args){
            Runnable r = new Runnable() {
                public void run() {
                    //set GUI
                    JFrame f = new JFrame();
                    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                    JEditorPane editorPane = new JEditorPane();
                    editorPane.setContentType("text/html");
                    editorPane.setText("<html><body><h1>Test!</h1><p>");
                    f.getContentPane().add(new JScrollPane(editorPane));
                    String testStr = "This is a test string. " +
                        "This is a test string. This is a test string. \n";
                    f.pack();
                    f.setSize(400,300);
                    f.setVisible(true);
                    //test with insertString()
                    long diff;
                    long startTime = System.currentTimeMillis();
                    Document doc = editorPane.getDocument();
                    for(int i=0; i < 500; i++){
                        try{
                            doc.insertString(doc.getLength(),testStr,null);
                        catch(BadLocationException exc){
                            exc.printStackTrace();
                    diff = System.currentTimeMillis() - startTime;
                    System.out.println("Time spent with doc.insertString() : " + diff);
                    editorPane.setCaretPosition(0);
            SwingUtilities.invokeLater(r);
    }

  • Html files, images and JEditorPane

    Hello all,
    I've got some HTML file that need be displayed in a JEditorPane. Those HTMLs contain image references and I'm using relative paths to those jpegs, for example:
    <img src="image.GIF">
    ...where image.gif is in the same folder as the HTML file that contains the reference. Now I'm displaying this HTML file inside a JEditorPane and I get only a placeholder instead of the image; only text gets displayed properly.
    Here's how I'm constructing the JEditorPane instance:
              pane = new JEditorPane();
              pane.setEditable(false);
              pane.setContentType("text/html");
              HTMLEditorKit kit = new HTMLEditorKit();
              kit.createDefaultDocument();
              pane.setEditorKit(kit);and later...
          try {
              URL u = new URL("file", "localhost", ivHelpPath);
              pane.setPage(u);
            } catch (IOException iox) {
            }I saw on some other thread that I should be setting the document's base URL for the reference I get from getDocument(), but that does not seem to work when I use "http://localhost/" to make my URL object.
    So... help! :)
    Thanks much.

    Not sure what you're trying to do with new URL( "file" "localhost", ...
    Try this code and see if it helps you - display a page that already exists though - perhaps that's the diff?
        JTextPane() jtp = new JTextPane(); //JEditorPane();
        jtp.setEditable( false );
        JScrollPane jsp = new JScrollPane( jtp,
                                     JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                                     JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED );
        ( ( HTMLEditorKit ) ( jtp.getEditorKit() ) ).setLinkCursor( new Cursor( Cursor.HAND_CURSOR ) );
        jtp.addHyperlinkListener( new HyperlinkListener() {
          public void hyperlinkUpdate( HyperlinkEvent hle ) {
            try {
              if ( hle.getEventType() == HyperlinkEvent.EventType.ACTIVATED )
                jtp.setPage( hle.getURL() );
            } catch( Exception e ) {
              // do something;
        });... There's also code here that will activate hyperlinks which you may or may not want. But this will display embedded .gif files.

  • Acrobat 8.1 Pro .mht And Some .html files Do Not Convert To PDF

    Acrobat 8.1 Pro with Windows Vista. .mht files are saved complete webpage single files similar to complete html files except they're as a single file instead of a file and a folder. When using Create From File, Acrobat does not recognize .mht files and will not convert them to PDF. Some complete .html files will not convert using Create from File, even though Acrobat does recognize them.
    Also, when I'm logged into a website and want to convert a webpage to PDF using Create From Web, often the resulting PDF document is of the login page and not the page I selected with the error message "can't locate file". These difficult webpages can be converted to PDF using the Print Adobe PDF function, but hyperlinks are not preserved with this function.
    I would like to be able to convert all files (including .mht) and webpages to PDF while preserving hyperlinks. Can anyone help me with this?

    Bruce,
    mht files are not standard html files. Acrobat will not handle those. If
    you are on a website that most be logged into, then Acrobat cannot get
    to those files since it is not logged in. You can print to pdf, since
    your browser is logged in.
    Mike

  • Why can't I drag an image or html file into a browser window with Firefox 17

    to get a quick view of various images or html files, I like simply dragging the files from my local drive into a Firefox browser window.
    since upgrading to FF 17, I can no longer do that. a NO symbol comes up when attempting this. and Dreamweaver will no longer preview with Firefox, even though it's my designated, preferred browser.
    anybody know if both of these are some setting or something?

    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance).
    *Do not click the Reset button on the Safe mode start window or otherwise make changes.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • HTML file is not being shown properly in the JEditorPane

    Hi,
    I am using JEditorPane to display an HTML file from the local disk. This HTML file contains the html tables. Now when this file is getting displayed in the JEditorPane, one top row grid is not being displayed in the editor pane. content of the row is there...but the column grid is missing. All other rows and columns are being shown but the first row-column grid which contains the heading for column.
    Also when I m printing the content of this JEditorPane using Java Print API then no grid is being printed on the paper. content is coming properly but no table grids. when i have taken the print out of the original html file from the browser then table grids are being printed out properly.
    Please do help me out in showing the HTML file in the JEditorPane properly and printing the same.
    Many Thanks,
    gshankar

    Hi,
    JEditorPane renders HTML with many limitations.
    You can use JDIC for the same. refer: jdic.dev.java.net
    But JDIC does not work on windows 98.
    Anand

  • Xml to JTree, and JTree node to html file.

    I have been trying to figure out a way to do this and I think I have a solution, but I am not sure how to structure the application and methods.
    working with BorderLayout Panel p, JSplitPane split, JTree tree, and JEditorPane rpane
    1st. My JSplitpane is divided with the tree, and rpane. The tree is on the left, and the rpane is on the right. both of these are then added to the Panel p
    2. I will create a method that will read through a modules.xml file, and create a JTree - tree. When you click on the node element it's information is displayed in the right pane - rpane.
    The Problem. I think it would take to long to create the html file on the fly each when I click on each individual node.
    So my idea is to create the html files from many xml files when I run the program. I can then just load the html file when I click on each individual node.
    This means alot of heavy processing in the front end, and everything will be static, but it will be faster when the user is in the program.
    Problem. How do I associate each node element with the correct html file?
    The Tree elements are always the same, but I can have 1 or many modules.
    Here is an example:
    <device>  // - root
       <module1>
          <Status>
             <Network></Network>
             <Device></Device>
             <Chassis></Chassis>
             <Resources></Resources>
          </Status>
          <ProjMngt></ProjMngt>
          <ProjEdit></ProjEdit>
          <Admin>
             <admNetwork></admNetwork>
             <admUsers></admUsers>
          </Admin>
          <Logging></Logging>
       </Module1>
       ...  Now I can have 1 or many Modules depending on what the xml file  has in it.
       <Module*n>
    </device>Other problems. Some of the information I want to store as a sortable Table, but I cannot seem to get any of the sort methods to work. They work if I just open a browser, and run the html file, but if I stick the html file into the JEditorPane it does not work? - any suggestions?
    Also, can I pass a JTabbebPane to the JEditorPane, or can I create a tabbed pane in html that will do the same thing.
    I am working with a very small device. It does not have a web application container like Tomcat on it. Just Apache, and Java. That is why I am using Swing.

    Using 'productAttribute/text()' gets you all three productAttribute nodes and then grabs all the text under that node. It simply concatenates together all the text under the desired node, hence the results you are seeing. If you want to get the text for each child node separately, then you need to do something like (assumes 10.2.x.x or greater)
    WITH your_table AS (SELECT
    '<root><productAttribute>
    <name>Baiying_attr_03</name>
    <required>false</required>
    </productAttribute>
    <productAttribute>
    <name>Baiying_attr_04</name>
    <required>false</required>
    </productAttribute>
    <productAttribute>
    <name>Baiying_attr_05</name>
    <required>false</required>
    </productAttribute></root>' xmldata
    FROM DUAL)
    -- Above simulates your DB table as I don't have it
    -- You only care about the following
    SELECT xt.*
      FROM your_table yt,
           XMLTable('/root/productAttribute'
                    PASSING XMLTYPE(yt.xmldata)
                    COLUMNS
                    prd_nm   VARCHAR2(30)  PATH 'name',
                    prod_rqd VARCHAR2(5)   PATH 'required') xt;Note: I added a <root> node as you had just provided a XML fragment. You will need to adjust accordingly.
    The above produces
    PRD_NM                         PROD_RQD
    Baiying_attr_03                false
    Baiying_attr_04                false
    Baiying_attr_05                false

  • How to put an HTML file into JEditorPane

    Hi
    I am doing an aplication on swing.But I don't know how to add a html file to the JeditorPane keeping the html file on the source code. i.e my html file is in my source code.Then how to add this source code to Jeditor pane.
    Thanks
    Srikant

    hi srikkant,
    ur html code is inside the source code..? are you working on applets..? if ur html file can be read as a file and the file stream can converted to a string and put into a Jeditor pane using the setText() method. for editing HTML text a editor called javax.swing.text.html.HTMLEditorKit can be used.
    Refer to JAVA API for further clarifiactions and examples.

  • How to add a html file into JEditorPane

    Hi
    I am doing an aplication on swing.But I don't know how to add a html file to the JeditorPane keeping the html file on the source code. i.e my html file is in my source code.Then how to add this html file to Jeditor pane.
    Thanks
    Srikant

    QuickTime requires player and plugins that most people don't have.  You'll reach a much wider audience if you use HTML5 <video> with mp4, webm and ogg files.
    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>HTML5 with Video</title>
    <!--help for older IE browsers-->
    <!--[if lt IE 9]>
    <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    </head>
    <style>
    video {
        max-width:100%;
        display:block;
        margin:0 auto;
    </style>
    <body>
    <h2>Use 3 File Types to support all browsers &amp; mobile devices:  MP4, WEBM and OGV.</h2>
    <h3>Online Video Converter
    http://video.online-convert.com/</h3>
    <!--begin video-->
    <video controls poster="Your_poster_image.jpg">
    <!--these are 6 sec sample videos for testing purposes. Replace sample-videos with your own files-->
    <source src="http://techslides.com/demos/sample-videos/small.webm" type="video/webm">
    <source src="http://techslides.com/demos/sample-videos/small.ogv" type="video/ogg">
    <source src="http://techslides.com/demos/sample-videos/small.mp4" type="video/mp4">
    If you're seeing this, you're using an
    outdated browser that doesn't support
    the video tag. </video>
    <!--end video-->
    </body>
    </html>
    Nancy O.

  • JEditorPane.... HTML file

    Please Help...
    I have been trying to add an HTML file to my JEditorPane
    using the setPage(URL/String) methods, I have had no luck,
    it throws some "unknown protocol: c" i understand that it
    is expecting a protocol like http:, the likes, but how do
    I bypass this as I want it do display an html file which
    is on my local drive... I do not want to use setText(String)
    setting my HTML tags in string...
    Thanks in advance
    Kaneval

    Create a file object for you local html file. Convert
    this file to a URL object.
    File htmlFile=new File(fileName);
    URL myhtmlUrl=htmlFile.toURL();
    Then you can use this URL object to display the html
    page.
    Thanks a lot
    Kaneval

  • Regarding displaying html page in a JEditorPane

    i want to display a html page in a JEditorPane but the problem is it is displying the page but the script part of html page is printed as it is in the pane . please tell the solution for it . i will be highly thankful to u.

    What you are doing exactly? you are displaying the html file into a JEditorPane or After displaying you are tring to Print it out in the Paper or what.
    If this the First Sinario then this code will help you.
    import javax.swing.*;
    import java.awt.*;
    import java.net.URL;
    import java.net.MalformedURLException;
    import java.io.*;
    import javax.swing.text.*;
    import javax.swing.event.*;
    public class Htmlexample extends JInternalFrame {
         //Constructor of Class.
         public Htmlexample () {
              //super(Title, Resizable, Closable, Maximizable, Iconifiable)
              super (title, true, true, true, true);
              setSize (500, 350);
              HtmlPane html = new HtmlPane ("Help/Keys.htm");     
              setContentPane (html);                    
              setVisible (true);
    //Following Class Show HTML Help inside an EditorPane.
    class HtmlPane extends JScrollPane implements HyperlinkListener {
         JEditorPane html;
         public HtmlPane (String filename) {
              try {
                   File f = new File (filename);          
                   String s = f.getAbsolutePath();          
                   s = "file:" + s;
                   URL url = new URL (s);               
                   html = new JEditorPane (s);          
                   html.setEditable (false);          
                   html.addHyperlinkListener (this);
                   JViewport vp = getViewport();     
                   vp.add (html);                    
              catch (MalformedURLException e) { }
              catch (IOException e) {     }
         //Function Perform By the HyperLinks of HTML Help File.
         public void hyperlinkUpdate (HyperlinkEvent e) {
              if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                   linkActivated (e.getURL());
         //Function for Loading other HTML Pages in Your HTML Help.
         protected void linkActivated (URL u) {
              Cursor c = html.getCursor();
              Cursor waitCursor = Cursor.getPredefinedCursor (Cursor.WAIT_CURSOR);
              html.setCursor (waitCursor);
              SwingUtilities.invokeLater (new PageLoader (u, c));
         //Following Class Load Other Pages Included in Our HTML Help File.
         class PageLoader implements Runnable {
              //Constructor of Class.
              PageLoader (URL u, Cursor c) {
                   url = u;
                   cursor = c;
              public void run () {
                   if (url == null) {
                        html.setCursor (cursor);
                        Container parent = html.getParent();
                        parent.repaint();
                   else {
                        Document doc = html.getDocument();
                        try {
                             html.setPage (url);
                        catch (IOException ioe) {
                             html.setDocument (doc);
                             getToolkit().beep();
                        finally {
                             url = null;
                             SwingUtilities.invokeLater (this);
              URL url;
              Cursor cursor;
    }if there is any other issue Let me Know
    Thank you
    Jofin

  • Unable to view PDF (baggage file) in CHM

    Hi,
    I have recently started using a new desktop pc running Windows 7. I am now unable to view PDF files (added as baggage files in RoboHelp) in the CHMs generated by RoboHelp. Even existing CHMs (generated before switching desktops) have this problem. Has anyone experienced the same problem and managed to solve it?
    Sofie

    A while back someone told me they had a similar problem with IE8 and advised they fixed as below:
    "After fiddling around with some settings, I found that if you go to Settings/Safety and enable Active X Filtering, the embedded files open normally."
    That will only fix it on your machine though. Do these CHMs work on other machines OK?
    See www.grainge.org for RoboHelp and Authoring tips
    @petergrainge

  • How to view PDF files like a flipping magazine?

    Hi, I am new here. I didn't know if it is the optimum catagory for my question, I hope you guys will help me.
    In brief, I want to view PDF files like a flipping magazine. You know, just the same flipping effect that ibook did on ios. Adobe reader is the only choice to browse PDF on computer for me. It's kind of bothering and annoying now.
    So, any ideas for that? Plus, my computer runs on win7 64bit.

    This is also a good site:  http://www.issuu.com/  You can sign up and use it for free or you can upgrade(for a price) to make custom changes (like background color, button color, etc.)  You can also embed the html code into your website if you would like someone to view it there.  Good luck!

  • Does anyone know how i can view PDF files using Galaxy Note 2?

    Does anyone know how i can view PDF files using Galaxy Note 2?
    This is what i have been doing;
    I click on the file i wish to view (via a portal)
    this file goes to notification widget (i drag down screen)
    notification/message says download complete
    i click on notification/message
    nows it says complete action using (here i only have 2 icon options 1= DB Text Editor 2 = HTML Viewer)
    I have installed Adobe Reader.

    Can you confirm if the downloaded file is a pdf file, that is it ends with .pdf?

  • A working method to load local PDF and HTML files on iOS

    I had a lot of trouble getting this to work, and I'm hoping this post saves someone time. Some of the information that's been posted in other locations is either wrong, incomplete, or might only work on Android. By the time you read this message the information here may no longer be accurate, so here's the testing environment:
    Window 7
    Flash CS 5.5.0
    AIR 2.7.0.19530, which was compiled on June 28, 2011
    iPad 1, version 4.3.5 of iOS
    Let's get started.
    On iOS, you load external PDF and HTML files using the StageWebView class.
    On Windows, StageWebView works but the HTMLLoader class is a better choice if you're creating a desktop app.
    You can also load HTML files by reading in the file's text. The information in this post is only for loading external HTML files.
    StageWebView will not load a file that's in File.applicationDirectory. All files bundled in your app are placed in File.applicationDirectory, which means you'll have to copy any external file you wish to load with StageWebView to another directory.
    So where can you copy your file? File.applicationStorageDirectory won't work. File.documentsDirectory does work.
    Several people have recommended copying to a temporary file using File.createTempFile(). This works, but there's a catch: it seems that, like Windows, StageWebView relies on a file's extension when determining how to load it. When you create a temporary file on iOS using File.createTempFile(), the file will have no extension (and on Windows, File.createTempFile() creates a file with the extension .tmp, which is equally problematic).
    The solution to the file extension problem is to rename the temporary file by appending the original file's extension. AIR currently does not have a <file>.rename() function, so you'll have to do it using <tempFile>.moveTo().
    Here's some code I've successfully tested several times on both iOS and Windows. The file is copied to the temp directory. The file's extension is restored by just slapping the original file name to the end of the temp file.
            private function loadExternalFile():void
                var webView = new StageWebView();
                webView.stage = this.stage;
                webView.viewPort = new Rectangle( 0, 0, 1024, 555 );
                // Works with either html or pdf files.
                // These are stored in the root of the application directory.
                var fileName:String = "euei.pdf";
                //var fileName:String = "euei.htm";
                var sourceFile = File.applicationDirectory.resolvePath( fileName );
                var workingFile = File.createTempFile();
                try
                    sourceFile.copyTo( workingFile, true );
                    // You have to rename the temp file
                    var renamedTempFile:File = workingFile.resolvePath(workingFile.nativePath + fileName);
                    workingFile.moveTo(renamedTempFile, true);
                    webView.loadURL( renamedTempFile.url );
                catch (err:Error) { }

    I tried this with Flash CS5.5 and AIR 4.0 SDK. Any pdf loaded simply fills the viewPort with black. Also tested with a png version of the pdf and that displayed just fine.
    What's the purpose of copying to a temp work file? I found that webView.loadURL( sourceFile.url ); gave me the exact same results.
    Any ideas?
    Thanks!

Maybe you are looking for

  • I can't use word because a box keeps popping up saying that it can't find the spell check files?

    I open Word and there is a pop-up message saying that word cannot start the spelling checker because the files may be missing and to make sure that the spell checker files are installed or use the Microsoft installer to install spell checker. I have

  • Quick link on the second page of a KM iView

    Hi everybody. I need some informations about an KM IView. I have a KM iview that displays some document in a folder of the portal. I have many documents in it, and the Iview is limited at 15 elements by page. I want to know if i can create a quick li

  • Very Urgent : Reordering of fields in Transaction Form

    Hi All, I am trying to reorder fields on the transaction form using form personalization. I would want to interchange the positions of Batch Source Name field and Transaction Number field. Although I am able to interchange the fields. The Prompt of T

  • Alerts missing characters

    Hi, In SharePoint, we have an announcements list with an alert for all the users (when a new item is added). Sometimes in the alert (the mail that we receive), there is 1 random character missing. The announcements we place contains all alphabetic le

  • Mount UFS disk not working

    Hi, I am new to Solaris so this may be something simple I have missed. I am having troubles mounting a MO (magnetic Optical) disk on my Solaris 9 X 86 workstation.. I have just loaded the Solaris operating system, in the workstation I have an interna