JEditorPane - backmapping highlighted text to source html document

Hello everyone,
I have the following problem: I display a HTML document in JEditorPane. Then I highlight some chunk of text and get the start and the end selection offsets by using getSelectionStart() and getSelectionEnd() methods, respectively. What I would like to know is the exact position (character offset) of the highlighted text in the original HTML document that is being displayed.
Does anybody know the solution for that?
Thanks.

I don't think it's possible. The parser builds a Document out of the text and doesn't keep the original source text. For example if your html is like this:
String text = "<html><body>     some     text     </body></html>";All the multiple spaces between the text is parsed out.
Use a JTextPane and use attributes. Its easier to work with than using HTML.

Similar Messages

  • How do i highlight text in a pdf document

    how do i highlight test in PDF document?

    Thank you so much, Bill, for your reply.  My problem was/is that I could
    not get the highlight tool to work.  I tried countless times before posting
    my query on the website.  You assumed correctly; I was/am working with text.
    I was using Adobe reader to highlight text in an Adobe doc I had created
    and need to forward to a third party.  I wanted to highlight that text in
    the document that is salient to the actions I am asking of the third party.
    Perhaps the highlight tool cannot be used in a previously created Adobe
    document.  In any event, I do appreciate your reply.

  • Problem of reading source HTML document  via URL object?

    Hi, Friends,
    why the following simple program can't work correctly?
    import java.net.*;
    import java.io.*;
    public class URLReader {
    public static void main(String[] args) throws Exception {
         URL ieee = new URL("http://www.ieee.com/");
         BufferedReader in = new BufferedReader(
                        new InputStreamReader(
                        yahoo.openStream()));
         String inputLine;
         while ((inputLine = in.readLine()) != null)
         System.out.println(inputLine);
         in.close();
    you know, when we use http://www.ieee.com/ to visit the ieee website via browser, it works well, only the adress is reset to http://ieee.com/portal/site/iportals/ , why the browser can do that, while the URL object can't?

    A URL is simply a reference to a "file" location.
    To do I/O on that object requires some sort of protocol. HTTP (a "web server"), will allow you to do this, but uses the HttpURLConnection object.
    The Java Tutorials shows you CAN read/write to a URL, but requires the underlying HTTP protocol client implementation.
    I think you are using this code from the Sun site: http://java.sun.com/docs/books/tutorial/networking/urls/readingURL.html
    Which may be why you create 'ieee' but reference 'yahoo' in your code.
    Were you getting an error message when trying to compile your program?
    You may wish to look further into the tutorial pages at: http://java.sun.com/docs/books/tutorial/networking/urls/readingWriting.html
    But I still would refer you in the end to HttpURLConnection which is much more in-depth.

  • Highlighting Text

    Hello
    Since updating Adobe Reader XI I have been unable to highlight text in any pdf document. While other functions, such as the insert text function work, highlighting does not. I have tried to change the base colour but that does not work either.
    I would be grateful for any help/tips.
    Regards
    Anthony

    Hello
    I opened three files:
    One says "Adobe PDF Library 2"
    Another says "Acrobat Distiller 8.0.0. (Windows)"
    Another says "1.5 (Acrobat 6.x)"
    However, in none of the does the text highlight work.
    Is a UK/English encoding problem eg Unicode instead of Western?
    Regards
    Anthony

  • HTML document feedback to java

    hi,
    I am trying to load a HTML document into JEditorPane (for viewing only). The HTML document contains a TextField and a Button, is there a way to notify my application whenever the Button is pressed?
    Thank You!

    Wow, it must take quite some time to figure this out:
    http://forum.java.sun.com/thread.jsp?thread=414212&forum=57&message=1885273

  • Highlight text not working in multi-thread client-server application plug-in

    I'm developing a plugin application for my dissertation research on multi-application environment. I have an application server that communicate with the PDF document via plugin.
    The plugin acts as both client and server, depending on the situation.
    - Plugin as Server
             I have a multi-threaded winsock2 IOCP running to catch client connections and when a client connected, get the data from the client (set of words), and highlight these words in the pdf document.
    - Plugin as client
               I use 2 procedures, one to collect all the text from PDF and send to the server using tcp win-socket connection and another to collect data from highlight tool and send these text. both these are not threaded.
    Here's my question, because I want to listen to multiple client connections, when the plugin is the server, I'm running this procedure in a thread and then wait for clients to connect and use IOCP to serve the client connections.  When the client is connected I use the data coming from client to highlight some text in the PDF document. All of these functionalities are already implemented, but when I receive data from client and try to highlight text in the PDF document my application freezes up and stop working. I think this is something to do with the thread. I'm using _beginthreadex to start the server and then another _beginthreadex inside the IOCP worker thread.
    I can post the code, but before that let me know if you can see any problem in this situation. What I see from other posts is that acrobat is not multi-threaded.

    Thanks a lot for the reply.
    I guess I probably need some sort of a notification when the data is received and do a callback to the main thread to run the acrobat API. Is there anyway I can create custom notifications? Something like this,
    AVAppRegisterNotification(AVDocDidOpenNSEL, gExtensionID, ASCallbackCreateNotification( AVDocDidOpen, (void *)DocIsOpenedCallback), NULL);
    or should I use a custom action listener?

  • Can you export highlighted text?

    Is there a way to create a summary of highlighted text in a pdf document and export it using the adobe reader android app.?

    Even easier than that....just select the playlist, hit Command P and then select song listing. Print.

  • Adobe Reader X Highlight Text button is grayed out

    I'm trying to highlight text in a pdf document.  At the top of the doc there is an informational note that says "...has been opened in read-only mode to prevent modification." Read-only is ont checked in the properties box. I checked the security and there is none. I have renamed the file with no luck. This is not a scanned document and the text is searchable. I can highlight text in other pdf documents. Any ideas how to get around this read-only setting?
    Also when I tried to add tags to this question I could not underline multiple words as indicated inthe instructions.
    Penthor

    Is there something special about a pdf/a doc?

  • Highlighting Text in pdf Documents using Preview

    Am using Snow Leopard (10.6.3) with Preview version 5.0.2.
    Tried highlighting text using the instructions in Preview help. No success.
    I click Annotate; chose the Highlight Colour but then appear to be unable to select the text.
    Anyone any ideas?
    Thanks

    Thanks for the hint. I think I've just discovered why I cannot do it. The pdf document I'm trying to highlight is the result of the output from a scanner. Hence it is effectively a "picture" - not text. The only thing that I have been able to do is to choose Annotate and then choose "Add Oval" or whatever and select its size and colour and then position this over the text I wish to highlight.
    Because it is effectively a picture you cannot select text. I tried it on another pdf document that IS text and your solution works a treat.
    Thanks again
    Malcolm

  • Highlighting text in PDF document

    I am a surgeon and subscribe to lot of medical journals which are now increasingly made available for downloading in PDF format. I am used to highlighting the important text in an article with an ordinary hi-lighter pen to make it easy when I need to go back to that article.
    Is there a way one can highlight the text in a PDF document the way one can highlight it on a paper? Will professional versions of Acrobat solve my problem?
    Sanjay Ghotkar

    A little late for the original post, but for anyone else looking to highlight text in Acrobat Pro 9 and be able to change the highlighter color...
    Accessing the highlighter tool:
    Right-click on the Toolbar.
    Select/check "Comment and Markup." This is the toolbar that contains the Highlight Text tool.
    Changing the highlighter color:
    You can right-click on the highlighted text and go to Properties, etc, but there's a more convenient method.
    While using the Highlight Text tool, turn on the Properties Bar (make it visible)
    Window:  Ctl+E
    Mac:  Cmd+E
    Mouse:  Right-click on the Toolbar and select/check Properties Bar.
    This will give you quick access to your highlighter properties, and it will remember your selected color between uses.
    The Properties Bar is context aware and will change based on the tool you're actively using, so you have access to change your highlight color through it when the Highlight Text tool is selected/in use.

  • How do you highlight text in Pages for iPad? The document I want to create and highlight is a pages document

    I am trying to create a document in Pages for iPad and want to highlight various bits of text but can not find a function in the inspector for this. Can anyone help,please?

    Hi stuartdj,
    I'm not finding a way to highlight text as one can do with iBooks (hold and swipe for black text, background yellow for example).
    One option is to actually color the text itself.
    Select the text, then in Style tools, tap the Font name at the top which shows the Text Options sheet where there is a Color option.  Would changing the font color to Red, Green or Purple accomplish your goals?
    If you do want black text on a colored background (highlighted) it would need to be text in a text box where you can change the fill (background) color.  Style, Style Options, Fill.  But this is not inline text and doesn't flow like just coloring the font itself.
    ivan

  • Is there a way to control Adobe PDF plugin from within a Web Application? For Example, Can we highlight text in the PDF/A document programatically?

    Hi,
    I am trying to open a PDF document in browser using Adobe PDF plug-in for IE 9. The plugin version is 10.x
    I need to highlight certain text in the PDF document ( which is searchable) programmatically. For example, when a user selects certain text on the web-page, we want to automatically highlight that in the PDF document.

    I don't think this is a question one can answer by simply downloading the SDK. And even if one reads all the documentation (it rarely happens for obvious reasons), it is not easy to reach an answer because its explanation is not trivial at all.
    In my own opinion, this is right the type of question to be put and (hopefully) answered in a Forum.
    Now, I am not sure about the correct answer but I will give one hint.
    If I am not wrong, the Internet Explorer, IE, PDF viewer by Adobe is actually a .dll file which is put under IE once Adobe Reader is installed. A custom plug-in for Reader or Acrobat is also a .dll file (Windows) but its extension is .api and it needs to be copied under Reader or Acrobat (or both). Therefore, I don't see how we can merge the IE viewer .dll with a custom plug-in .api. Though maybe technically possible, I don't think it is something we can do.
    If above reasoning is correct, the answer to the question is No.

  • How do I find highlighted text, one-by-one, in a document?

    Hi,
    I have highlighted many lines, texts at lot of places in a document.
    I just want to "find" the hightlighted text one by one (like a find-next) so that I can just view the important information immediately.
    Till now I have been scrolling and looking for highlighted text, which is definitely not a good way to do in a medium-large sized document.
    Thanks
    Saurabh

    Open the Comment pane on the right. There's a list of all comments there.
    If you click on one of them, the display will "jump" to it.
    On Wed, Feb 27, 2013 at 11:14 AM, saurabhagarwal_2000 <

  • How do you highlight text in document in Pages

    How do you highlight text in document in Pages

    but Pages is NOT a 3rd party app.  it's an application that's programmed by apple.  it's supposed to act something like Word in MS office, but that is not at all true. 
    choices for editing text, highlighting, et al., like what you find in MS Office Word, should be immediately available whenever you are inside of a Pages document, but that is not the case. 
    don't you wish that when you buy an apple app for apple/macs that is supposed to be like a windows something or another that it really is? 

  • Acrobat: summarize highlighted text only in a new document?

    Hi everyone,
    I have marked some passages with the "highlight text"-tool in a big pdf file and want to extract only the marked text in a new file. Is this possible?
    So far I could only print a new file with information ABOUT the highlighted text, but not the highlighted text itself.
    This means I get a file telling me only who highlighted the text and when he did that.
    I'm using Adobe Acrobat X, but if you know another program that is able to do this please tell me!
    Thanks for your help!

    Although i generally recommend people to user PDFMaker as it provides more features. But if you have already converted the files using PDF Printer, you can also creates tags. Try this:
    1). Open PDF in Acrobat.
    2). Click on Tools-> Accessibility.
    3). Add Tags to document.
    4). Save the document and then try the steps I mentioned above. This resolves the issue related to Tags.
    You can also do that in MS Word once the PDF is tagged.
    1). Open MS Word. Click on Acrobat Tab
    2). Click on Acrobat Comments->Import Comments from Acrobat.
    3). Now Follow step 6,7,8, and 9 and you are done.
    Once you get the comments exported to word you need to change the layout of those using features in word.
    Also, you can try this:
    In the comments pane->Under Comments List-> Click on the bubbles and select Hide All Comments. No Click on the same bubble and select Type->Highlight. This will show you only Highlight annotations.
    Now Click on Options(Box) and select create comment summary.
    Under Comment summary select third radio button-> Comments Only.
    For Include option -> Select Only the comments currentyly showing.
    Click Create Comments Summary
    This will generate the PDF file with only highlight annotations.
    Now you can easily export this to MS Word, Using SaveAs-> Microsoft Word-> Word Documents.
    (This might create a problem if the highlighted tag is on a Scan document that is OCRed/ not OCRed. That may slightly change the layout). Otherwise its okey.
    Does that resolve the issue??
    I am not sure if i followed the second issue of yours. Is update a problem or adding Acrobat tab in Word?
    ~SaVe

Maybe you are looking for

  • How to get Time Machine on a PC?

    My MacBook Pro (with OS X Lion) won't log in. When I start it up, I see the login screen but cannot click on my username to enter my password. I have restarted, shut down, charged, left over night. Nothing works. So I am trying to access my data from

  • Can i use apple tv on clear spot wifi network?

    I am using clearwire spot wifi device to share internet. Can i use apple tv on the dvice and stream ipad video on the tv thru airplay?

  • DW, MSAccess w/o PHP or MySQL

    I'm thinking about building a database driven web-site. Vendors w/post info about their products and customers will purchase or post requests for special orders. I'm contemplating buying the latest version of Dreamweaver. I want to integrate MSAccess

  • I can't open the apps from different accounts on my iPad 2

    The apps from my current account are working but not apps from the others.

  • Upgrade NI-FBUS 3.2 and NI-Configurator 3.1

    Is it possible to upgrade my NI-FBUS Communications Manager version 3.2 to Version 3.2.1 and also use NI-FBUS Configurator Version 3.1? According to the install notes for NI-FBUS software Version 3.2.1 I must use Configurator Verison 3.2. Is NI forci