Convert a word position in a document into an X-Y position

Hello,
I have a JEditorPane and I want to convert the position of a word into an XY position.
For example, I open a document in my JEditorPane that contains the word "hello".
The following code gives me the position of the word "hello" in the document text:
int position = 0;
javax.swing.text.Document doc = documentManager.getDocumentEditor().getDocument();
try {
   position = doc.getText(0, doc.getLength()).indexOf("hello");
} catch (BadLocationException ex) {
}What I want is to convert this position into an XY position that corresponds to the real position of the word in the document.
In fact, I am searching for a method that give the same results as getMagicCaretPosition(), but without the need to use the caret...
Edit: I found myself, it's the "modelToView(int position)" method that return a Rectangle. The x-y values indicates the exact starting position of the word according to the document.
Edited by: pydon on Jul 11, 2008 11:22 AM

I found myself, it's the "modelToView(int position)" method that returns a Rectangle. The x-y values indicates the exact starting position of the word in the document.

Similar Messages

  • After converting to word cannot type in document?

    cannot type in exported documents, word, scaned pdf?
    ms office 2011 for mac , with latest updates

    Hi,
    It seems that your Word file is an image rather than selectable text.
    If your PDF file contains scanned images please turn "ON" OCR to recognize those images to selectable text when you export the PDF file to Word.
    Please let me know if you still have the same issue.
    Note: To turn ON OCR:  Check ON for "Recognize scanned text in" in Export Options dialog of  web ui(https://createpdf.acrobat.com/signin.htmlor hhtps://exportpdf.acrobat.com/signin.html) or "Recognize text in English" in Reader X or Reader XI
    Thank you.
    Hisami

  • I know only Javascript and would like to convert a large numbers of scanned documents into layers to mount on white a4 canvas

    I have got more than 400 scanned documents of A4 size. But they are not of uniform size. Luckily they are all of 300 dpi.They were created on a scanner. When opened in photoshop they contain random patches that are transparencies, although there seems to be no difficulty viewing themon adobe reader.
    My laptop had "Gb RAM and does not accept CS4 I have Photoshop CS3. My javascript and photoshop are both limited to basic skills.
    I would like to mount each document on a white A4 sized photoshop background of300dpi, as a layer, flatten it out and save as the desired page.
    As this is rather time-consuming, I would like to have a script that will perform this task, on a single file.
    I would like to manually run this script on each file.
    If possible I would additionally like to  put the individual pages in a folder and run the script repetetively on all files in the folder.
    Any suggestions or held will be gratefully appreciated
    thanks, peter

    This has now been modified for single page PDF's.....
    #target Photoshop
    app.bringToFront;
    function main(){
    var inFolder = Folder.selectDialog("Please select folder to process");
    if(inFolder == null) return;
    var startRulerUnits = preferences.rulerUnits;
    preferences.rulerUnits = Units.PIXELS;
    var pdfOpenOptions = new PDFOpenOptions();
    pdfOpenOptions.antialias = false;
    pdfOpenOptions.suppressWarnings = true;
    pdfOpenOptions.usePageNumber = true;
    pdfOpenOptions.mode = OpenDocumentMode.RGB;
    pdfOpenOptions.page = 1;
    var fileList = inFolder.getFiles(/\.(pdf)$/i);
    var FillColour = new SolidColor;
    FillColour.rgb.hexValue = 'ffffff';
    app.backgroundColor= FillColour;
    var outfolder = new Folder(decodeURI(inFolder) + "/Edited");
    if (outfolder.exists == false) outfolder.create();
    for(var a = 0 ;a < fileList.length; a++){
    if(fileList[a] instanceof File){
    var file= open(fileList[a],pdfOpenOptions);
    var doc = activeDocument;
    doc.flatten();
    var docname = fileList[a].name.match(/(.*)\.[^\.]+$/)[1];
    if(doc.resolution != 300) doc.resizeImage(undefined,undefined,300,ResampleMethod.NONE );
    if(doc.width.value > doc.height.value){
    app.activeDocument.resizeCanvas(3508, 2480, AnchorPosition.MIDDLECENTER);
    }else{
      app.activeDocument.resizeCanvas(2480, 3508, AnchorPosition.MIDDLECENTER);
    var saveFile = new File(decodeURI(outfolder) + "/" + docname + ".jpg");
    SaveJPEG(saveFile, 8);
    activeDocument.close(SaveOptions.DONOTSAVECHANGES) ;
    app.preferences.rulerUnits = startRulerUnits;
    main();
    function SaveJPEG(saveFile, jpegQuality){
    jpgSaveOptions = new JPEGSaveOptions();
    jpgSaveOptions.embedColorProfile = true;
    jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
    jpgSaveOptions.matte = MatteType.NONE;
    jpgSaveOptions.quality = jpegQuality; //1-12
    activeDocument.saveAs(saveFile, jpgSaveOptions, true,Extension.LOWERCASE);

  • How to make a Word for Mac 2008 doc into a PDF using Acrobat Macintosh

    Any ideas how to turn a Word for Mac 2008 document into a PDF using Acrobat Pro?
    Thank you if you can help.

    In Word  2008 for Mac:
    go to Save As... from File menu.
    when window open click on Button show the current file type.
    when thi menu drops down you will see the following
    Choose PDF
    save.
    Then open up in Acrobat.

  • Acrobat XI Pro Won't Convert 206 Page Word Document into PDF

    Hi there
    As menetioned above, Acrobat XI Pro Won't Convert my 206 Page Word Document into a PDF.  The Word document was originally a PDF file that I converted to Word and it has split all the text into sections.
    It sounds like converting a PDF into Word isn't the best way to edit, re-format and then save as a PDF again.  I would love to hear your advice on this.
    Thanks very much for your help!
    Fiona

    First before you recreate the PDF from the Word Document.
    In word: Open Document
    Next open a new Blank docment
    switch back to Word click on the ¶ button
    scroll to of go to very end of docment.
    click just to right of the perion in the last sentence.
    now go to very beginning of document
    Hold down the Shift and click to the right of first letter in document.
    Now choose copy.
    Now switch to Blank document
    Choose Paste special.
    Now choose Text only.
    If works all the words will be there spaced correct but with no ¶'s.
    Now insert returns as desired.
    Now save as a docx file under a different name.
    IF you are on a Mac use the following directions:
    go to File menu > Print > PDF Hold down PDF button until Context menu pops up.
    Choose adobe PDF.
    follow steps when the first window opens.
    Save as PDF in desired location.
    Now open the PDF in Acrobat. Document should be properly formatted and ready to go.
    AS you've found The conversion is not seamless. Acrobat doesn't distingish between automatic end of line breaks and Returns and you have to put the pieces back again.  I wish Adobe and MS would get over the jealouscy of each other and share howcode works so Thatapplications could work seamlessly together.  BUt they never will.

  • How do I convert a word document into a pdf and then upload it to a web site

    How do I convert a word document into a pdf and then upload it to a web site so people can read it from my
    site with Dreamweaver 4?. How can I do this? Can anyone please help? I'm only a newbie. Thanking you in anticipation.

    First you need to install a means of printing to pdf from word.  I like cutepdf writer ( http://cutepdf.com/Products/CutePDF/writer.asp ).  Once installed you will print the doc in word and under the printer selection you choose pdf.
    Once you have the file you put it in your local site folders and upload it using Dreamweaver.  Be sure to link to it from a page so users can get to it and I would recommend giving the link a target of _black so it will open in a new window (see the properties inspector in DW).

  • Converting word documents into pdf and sending

    IA company that I am applying for a position to requires that I send my resume and cover letter in a pdf format.  These two documents currently exist in WORD format.  How can I successfully export the documents into a pdf format and send?

    Hi,
    I think you have startged two discussions for the same question:
    Please check the below mentioend
    http://forums.adobe.com/message/5318601#5318601
    ~Pranav

  • Using Adobe Export PDF, I converted a PDF document into MS Word. However, all the images are missing

    Using Adobe Export PDF, I converted a PDF document into MS Word. However, all the images are missing--replaced by black rectangles. How can I fix this? Thanks for any assistance.

    Hi Ravinder,
    As I mentioned in my email to you, I wasn't able to reproduce the behavior your described.  The images appear properly.
    Please let me know if you have any questions.
    -David

  • I am converting all my word 97 documents into word 2010.

    When i convert a word 97 document into 2010 in some of the documents i am facing an issue. The issue is that in 97 word the content is present in two lines where as after converted to 2010 the content is present in three lines. Could any one please help
    me out to resove this issue.
    Many thanks.

    What happens when I send my document to someone else? Will Word mess up my formatting?
    Why has my page layout changed when I open my document on a different machine?
    First, you should not be mass converting Word 97 documents to Word 2010. Documents are historical items, not something to be used as the base for future work on a regular basis. For future work, you want to be using templates.
    My guess is that another difference is that you have a different operating system on the computer with Word 2010 than the one with Word 97. This is not necessarily the case but is likely.
    The two articles linked above may answer most of your questions. There are two principal issues: a different printer driver, and a document setting to update styles from the template.
    Note also, there is a difference between opening a Word 97-2003 style .doc file in Word 2010 and converting it to Word 2010. When you convert to .docx format, there can be some formatting change.
    Charles Kenyon Madison, WI

  • Converting Word Document into Robohelp format

    I am new at Robohelp and have been recently assigned a task to convert several Word documents into Robohelp using version 9 of RoboHelp. Can someone please direct me in the right direction (location, URL, tutorials etc.) to find some step-by-step help, it would be most appreciative

    Hi Michael.
    Rick asked that question because there IS a method of linking a Word file to a Robohelp project and bringing in any changes to them. It was designed exactly for the scenario where a SME or client writes the content and someone else just acts as a kind of content curator. However if you just want to import the Word file, this is fine also but you'll need to understand that once the content is in RoboHelp, the content would need to be changed in Robohelp.
    There is a good tutorial on the benefits of both linking and importing over on Peter Grainge's website (see the link below). This is a very useful resource for all things RoboHelp and well worth bookmarking.
    http://www.grainge.org/pages/authoring/importing/about_importing_linking.htm

  • How can I convert a secure pdf document into word?

    How can I convert a secure pdf document into word?

    Hi,
    Please refer to below mentioned article:
    http://forums.adobe.com/docs/DOC-1515
    ~PRanav

  • Convert word document into .JPG image. Possible?

    Hello
    I need to convert a word document into a .JPG image... Anyone who can recommend a mac program that can help, or how word can do it for me?
    Best regards
    Jesper Pedersen

    In Word go to File > Print... > PDF > Save As PDF.Open the resulting file in Preview.
    Choose File > Save As... > Format: JPEG.
    Hope that helps.
    mrtotes

  • How can I convert a PDF file in my computer into a word document?

    How Can I convert a PDF file in my computer into a Word Document?

    You might try posting to the Adobe ExportPDF forum:
    http://forums.adobe.com/community/exportpdf
    If you would like to email me ([email protected]) the PDF, I'll see if there's anything I can do to help.
    Regards,
    Brian

  • How to convert a word document into the PDF format?

    Please instruct me step by step on how to convert several Word documents into the PDF format?

    If properly installed and updated (depending on the WORD version), you can simply do any of the following:
    1. Open the doc in WORD and select Print, choose the Adobe PDF printer, print.
    2. Open the doc in WORD and go to the Acrobat menu in WORD and select create PDF (this uses PDF Maker).
    3. Open the doc in Acrobat and the conversion should be done based on PDF Maker.

  • Is there an app for converting a Pages document into a Word document

    is there an app for converting a Pages document into a Word document?

    In pages, Use the menu Share - Export - to Word.
    Matt

Maybe you are looking for

  • Safari and Firewall in Security panel in System Preferences

    I'm on Mac OS 10.5.8 on 2 GHz Intel Core Duo with 1.5 GB of memory When I access www.myspanishlab.com with Safari 4.0.3 and run the last item on the browser tuneup, I'm always asked to allow or deny incoming network connections. In the Security Prefe

  • I am looking for what type/setup of Read/Write command in RSLogix 5000 to be used with the NI Ethernet I/P Driver

    I am working on trying to get LabView to communicate with an Allen-Bradley Compact Logix PLC using the NI Ethernet I/P driver.  I am currently getting errors on both system of a CIP Message instruction error and cannot determine if the problem is in

  • Some metadata not or differently exported

    Just discovered to my disappointment that when an image is exported LR takes away a lot of meta date. I use Nikon D80 and lots of specific Nikon meta data disappear. Gone from the EXIF fields are also white point setting, compression type and Pixel X

  • MB_UPDATE_INVENTORY_DOCUMENT

    Hi Gurus, what is this function module MB_UPDATE_INVENTORY_DOCUMENT used for and how to use it..I need to set the flag XLOEK = 'X' for the table ISEG. Can i do it using this fun.mod. Please Help.

  • Nokia 6300 connection to MB bluetooth SAP unit; mi...

    Just brought a Bluetooth SAP unit for my MB - and a NOkia 6300 to enable connection; but I cannot make them connect...There is really no information to get out of the Nokia Manual (thanks for nothing...) but in the MB manual it gives information conc