How to insert a word document or an RTF document into RichTextEditor?

How to insert a word document or an RTF document into af:richTextEditor. I am using Apache POI for reading the Word document and getting its contents. I am able to display the whole content of the document except the table and image within the document. The data in the table is getting displayed as a string and not as a table inside the editor.
Can we insert a word/RTF document into a rich text editor?
Can we insert images into the rich text editor?
The following is the code that I used. On clicking a button the word document has to be inserted into the <af:richTextEditor>.
<af:richTextEditor id="rte1" autoSubmit="true"
immediate="true"
columns="110" rows="20">
<af:dropTarget dropListener="#{SendEmail.richTextEditorDrop}">
<af:dataFlavor flavorClass="java.lang.String"/>
</af:dropTarget>
</af:richTextEditor>
<af:commandButton text="Insert at position" id="cb2">
<af:richTextEditorInsertBehavior for="rte1" value="#{RichTextEditorUtil.docFile}"/>
</af:commandButton>
Java Code: I am using Apache POI for reading the word document.
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.extractor.WordExtractor;
public String getDocFile() {
File docFile = null;
WordExtractor docExtractor = null ;
WordExtractor exprExtractor = null ;
try {
docFile = new File("C:/temp/test.doc");
//A FileInputStream obtains input bytes from a file.
FileInputStream fis=new FileInputStream(docFile.getAbsolutePath());
//A HWPFDocument used to read document file from FileInputStream
HWPFDocument doc=new HWPFDocument(fis);
docExtractor = new WordExtractor(doc);
catch(Exception exep)
System.out.println(exep.getMessage());
//This Array stores each line from the document file.
String [] docArray = docExtractor.getParagraphText();
String fileContent = "";
for(int i=0;i<docArray.length;i++)
if(docArray[i] != null)
System.out.println("Line "+ i +" : " + docArray);
fileContent += docArray[i] + "\n";
System.out.println(fileContent);
return fileContent;

Hi,
images are not yet supported. Its an open enhancement request for the rich text editor.
For tables, it seems they are supported but in a basic way (just HTML 4 style) if I interpret the tag documentation correct
http://download.oracle.com/docs/cd/E15523_01/apirefs.1111/e12419/tagdoc/af_richTextEditor.html
Frank

Similar Messages

  • How to Append two  word documents into single  using   java

    How to Append two word documents into single using java
    we tried this but it's not append the one word document to other
    source code:public class AppendTwoWordFiles {
         public static void main(String []arg)throws IOException
              FileInputStream fi=null;
              FileOutputStream fo=null;
              try {
                   System.out.println("Enter the source file name u want to append");
                   BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
                   File f1=new File(br.readLine().toString());
                   System.out.println("Enter the Destination file name ");
                   File f2=new File(br.readLine().toString());
                   fi = new FileInputStream(f1);
                   fo = new FileOutputStream(f2,true);
                   byte b[]=new byte[2];
                   while((fi.read(b))!=-1);
              fo.write(b);
    System.out.println("Successfully append the file");
              } catch (FileNotFoundException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (IOException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              finally{
              fi.close();
              fo.close();
    plz reply me quickly ,,,what can i follow

    Use this code ..
    and give the path of the both file like this.....
    source file ---- C:/workspace/Practice/src/com/moksha/ws/test/practice.text
    destination file ---- C:/workspace/City/src/com/moksha/ws/test/practice1.text
    import java.io.*;
    public class AppendTwoWordFiles {
         public static void main(String[] arg) throws IOException {
              FileInputStream fi = null;
              FileOutputStream fo = null;
              try {
                   System.out.println("Enter the source file name u want to append");
                   BufferedReader br = new BufferedReader(new InputStreamReader(
                             System.in));
                   File f1 = new File(br.readLine().toString());
                   System.out.println("Enter the Destination file name ");
                   File f2 = new File(br.readLine().toString());
                   fi = new FileInputStream(f1);
                   fo = new FileOutputStream(f2, true);
                   byte b[] = new byte[2];
                   int len = 0;
                   while ((len = fi.read(b)) > 0) {
                        fo.write(b, 0, len);
                   System.out.println("Successfully append the file");
              } catch (FileNotFoundException e) {
                   e.printStackTrace();
              } catch (IOException e) {
                   e.printStackTrace();
              } finally {
                   fi.close();
                   fo.close();
    }

  • I want to know how to turn a word document into a jpeg so I can put the document on Facebook as a picture. I have made posters and if I do a print screen they are unable to be read, or if i turn it into a PDF there is no save as jpeg??

    I want to know how to turn a word document into a jpeg so I can put the document on Facebook as a picture. I have made posters and if I do a print screen they are unable to be read, or if i turn it into a PDF there is no save as jpeg??

    iOS device backups are stored in your iTunes library.
    Move your iTunes library to an external drive.

  • Insert One Word Document into another using OLE ABAP

    Hi,
    I want to insert one word document into another Word Document called by OLE ABAP.
    ie.first word document having 6 pages have been displayed and I want first page of
    second document as a 7th page.I want to dispaly the entire data in  one document.
    Hope to get the reply soon.
    Thanks & Regards,
    Divya.

    T.code :- DWDM
    u can check OLE and OFFICE INTEGRATION tree  have so many demo report
    Report :- RSOLETT1
    Edited by: Krupaji on Feb 18, 2010 2:00 PM

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

  • How to insert a PDF document into a Word file?

    I'm using Acrobat Standard 9 and Microsoft Word 2010 and I'm unable to insert a PDF document into a Word file. Operating system is Windows 7 Enterprize. Can someone help?

    Thanks for the reply, Bill. 
    Yes, let me elaborate further:
    I have a four page document in WORD with instructions. Examples of the instructions are in PDF files. I want to insert each PDF example next to or below each line item in WORD.The PDF will open when clicking on the icon without having a hyperlink attached to it.  

  • How to insert a pages document into another pages document?

    How can I insert a pages document into another one?
    How can I insert 1 page of a document into another document?

    Open your files & show thumbnails. Sections have a yellow border around all of the pages in that section. Now click on the page in the thumbnail pane & copy. If the file is more than one page & you only want one, you'll need to insert a section break to separate the pages. Then go to your other file, click in the thumbnail pane & paste. The whole copied page will be pasted in. Repeat with another section. Styles will copy over with the sections but headers & footers will not.

  • How to pass a Word Document into a byte array?

    Hi All
    I have an application wherin i select multiple files and send them over to a webservice method.The files selected are zipped internally and sent across as a single entity.
    I could pass the files and retrieve them using my test tool to check thir successful send and retrieval as long as the files were in "text" format.
    But now i need to figure a way out to pass word docs or any other content types.I tried passing word docs in the mechanism that works fine for "text" files.But when i retrieve the files,and try to open the word documents the MS Word states that "the file is corrupt and cannot be opened". The following is the code.
    public byte[] getContent(IDfSessionManager sessionManager,String repositoryName, String objectIdString) {
       ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
       StringBuffer sb = new StringBuffer("");
        try {
              System.out.println("Repository Name " + repositoryName);
               mySession = sessionManager.getSession(repositoryName);
               // Get the object ID based on the object ID string.
                DfId dfId = new DfId(objectIdString);
                 if (dfId.isObjectId())
         System.out.println("Successfully fetched id " + dfId);
              IDfSysObject sysObj = (IDfSysObject) mySession.getObject(dfId);
              System.out.println("Content Type ++++++ " + sysObj.getContentType());
              ByteArrayInputStream buf = sysObj.getContent();
              int i = 0;
             InputStreamReader readInput = new InputStreamReader(buf, "UTF8");
             BufferedReader br = new BufferedReader(readInput);
             while (br.ready()) {
            sb.append(br.readLine());
             sb.append("\n");
              String captureText = sb.toString();
         try {
         is = new ByteArrayInputStream(captureText.getBytes("UTF-8"));
                         } catch (UnsupportedEncodingException e) {
                                    e.printStackTrace();
         final int BUF_SIZE = 1 << 8; // 1KiB buffer
         byte[] buffer = new byte[BUF_SIZE];
                    int bytesRead = -1;
                     while ((bytesRead = is.read(buffer)) > -1) {
         outputStream.write(buffer, 0, bytesRead);
         is.close();
         System.out.println("This is byte acquisition ###### >>>>>>>>>>>>>>>>>>>");
         binaryData = outputStream.toByteArray();
         File temp1 = File.createTempFile("Test",".docx");
         FileOutputStream fos = new FileOutputStream(temp1);
         fos.write(binaryData);
         fos.close();
              // Handle any exceptions.
              catch (Exception ex) {
              ex.printStackTrace();
              finally {
                   sessionManager.release(mySession);
              return binaryData;
         }I assume that UTF8 must be applicatbe only to deal with .txt files.
    I would really appreciate your guidance to obtain a way to acquire data from word documents so that i could open and read them without errors.
    Thank You
    Regards

    Hi B1J001
    Following your suggestion i curtailed the code as follows:
    public byte[] getContent(IDfSessionManager sessionManager,String repositoryName, String objectIdString) {
       ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
       StringBuffer sb = new StringBuffer("");
        try {
              System.out.println("Repository Name " + repositoryName);
               mySession = sessionManager.getSession(repositoryName);
               // Get the object ID based on the object ID string.
                DfId dfId = new DfId(objectIdString);
                 if (dfId.isObjectId())
         System.out.println("Successfully fetched id " + dfId);
              IDfSysObject sysObj = (IDfSysObject) mySession.getObject(dfId);
              System.out.println("Content Type ++++++ " + sysObj.getContentType());
              ByteArrayInputStream buf = sysObj.getContent();
              *String testbuf = buf.toString();*
              *testbytearray = testbuf.getBytes();*
            File temp1 = File.createTempFile("Test",".docx");
            FileOutputStream fos = new FileOutputStream(temp1);
            fos.write(testbytearray);
            fos.close();
         // Handle any exceptions.
         catch (Exception ex) {
         ex.printStackTrace();
         finally {
         sessionManager.release(mySession);
         return testbytearray;
         }I am using just the ByteArrayInputStream to access the content. Still my attempt to open the document from the temporary file yields "file corrupt message".Am i going the right path?
    Thank You
    Regards

  • How to insert one XML document into another

    Hi,
    I've been working on a simple CMS.
    There is a main template that is just a HTML page. The main template has a few extra 'module' tags that indicates places where individual modules have to be placed.
    main template: template.xml
    <html>
    <body>
    <div>
    <module id="centre"/>
    </div>
    </body>
    </html>module template: module_centre.xml
    <div>
    <a>This is a MODULE and it may be much more complex</a>
    <div>My application has to detect every 'module' tag from the template.xml and insert there XML content from a proper module template.
    The result file has to be generated dynamically on a request. The structures of 'modules' can be only defined in module_*.xml files.
    The expected result
    <html>
      <body>
        <div>
            <div>
                <a>This is a MODULE and it may be much more complex</a>
            <div>
        </div>
      </body>
    </html>What's the best practice do solve this case?
    Pawel

    I think I've came up with a better solution.
    SRC file
    <?xml version="1.0" encoding="utf-8"?>
    <html>
      <head>
        <title></title>
        <style type="text/css">
    div.c4 {background-color:pink;width:400px;height:50px}
    div.c3 {background-color:green}
    div.c2 {background-color:blue;width:400px;height:299px}
    div.c1 {background-color:red}
    </style>
      </head>
      <body>
      <module id="XXX"/>
        <div id="main" class="c3">
          <div id="top" class="c1"><module id="menu_test"/></div>
          <div id="bottom" class="c2"><module id="menu_test2"/></div>
        </div>
        <div id="footer_container" class="c4">    <module id="menu_footer"/></div>
      </body>
    </html>MODULE src file
    <?xml version="1.0" encoding="UTF-8"?>
    <div id="admin_panel_module" style="background-color:orange;width:200px;height:50px">
        <p>Control Panel TEST</p>
    </div> @param source  -  NODES from MODULE document
    *@param target - TEMPLATE document where MODULES are going to be inserted*
    @throws Exception
    public static void insertModules(Node source, Document target) throws Exception {
    Node importedNodes = target.importNode(source, true);
    // Use XPath to find all 'module' nodes in ''
    XPath xpath = XPathFactory.newInstance().newXPath();
    NodeList nodes = (NodeList) xpath.evaluate("//module", target, XPathConstants.NODESET);
    // Remove MODULE node and insert there an XML content from MODULE template
    for (int idx = 0; idx < nodes.getLength(); idx++) {
    Node editedModuleElement = nodes.item(idx);
    // parent of module mode
    Node parentNode = editedModuleElement.getParentNode();
    // replace <module/> node with imported nodes from 'module' XML document
    parentNode.replaceChild(importedNodes, editedModuleElement);
    // nodes.item(idx).appendChild(node);
    importedNodes = target.importNode(source, true);
    }Edited by: maestr0 on May 24, 2010 12:44 AM

  • Loading Word document into Adobe Captivate

    I would like to know how to upload MS Word document into Adobe Captivate format.

    Hi there,
    Welcome to Adobe Community.
    Could you please elaborate a little more on what exactky you are trying to do?
    You can open a word document on a button or on an object but you cannot import it. You can import a PowerPoint Slide.
    Thanks!

  • 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).

  • Adobe Acrobat 9/Win7 - Inserting Word documents into PDF file intermittently leads to missing or garbled text?

    Heya.
    I have a user who is creating a PDF essentially compiled from inserting word documents into the position she wants inside of the PDF.
    The problem is that sometimes this leads to missing or garbled text. For example, 6-8.1 is displayed as 6- .1. Which is just plain weird.
    Other times, the text looks garbled or uneven. She turned off her PC but I took screenshots of both of these scenarios. I fear that I am not going to be able to retroactively fix the corruption in this document for her.
    She says she's using very standard fonts. Like Arial. I asked if she could locate the original Word document that produced the garbled text, just for a sanity check. The problem is that her co-worker may have been the only one with that particular word document (there are probably hundreds which compile this PDF...) and IF she has it, she might not be able to locate it on her PC TO check what the original text is. Yikes.
    Google-fu turns up very little. I tried the guidance in this document - https://answers.acrobatusers.com/We-combine-PDF-document-ends-corrupt-What-problem-q197619 .aspx[2] and a Save-As but no avail.
    This also turns up but is not applicable to Acrobat 9 I believe:  http://blogs.adobe.com/acrobatineducation/2010/02/get_rid_of_that_bloat_in_your.html[3]
    She states that she can manually fix the document but after a while it gets corrupted again? But I haven't observed that and she might have just fed me that to amplify the problem.
    I will be able to post screenshots when she turns on her computer tomorrow.

    Here are the two instances of corruption we have come across.
    http://imgur.com/nPztMYm
    http://imgur.com/wHM12e2
    Edit:  A LITTLE MORE INFO.  I am able to select the corrupted text, paste it into Notepad with all the characters intact.  So the characters are THERE.  they are just not being displayed correctly.
    Edit:  They also do not print correctly.  The page prints with characters missing, and she wants to print this document, so that is going to be an issue.

  • How do I copy, paste Word document into Adobe Reader PDF?

    A client is not using Microsoft Word, but typing text for my edits into Adobe PDF. Too many edits, too cumbersome for me. After converting PDF to Word, I edit using various ink colors. How can I copy, cut, paste edited WORD document into her PDF? Other than by using "paper clip" or "attachment" features?

    Thanks, graffiti...So, can't copy, paste Word document into PDF?
    What is the "full version" of Adobe vs my Adobe Reader? Adobe Acrobat?
    I do have a cloud, but doesn't help with my editing problem.

  • Inserting a MS Word document into database

    Hello friends at www.oracle.com,
    we need to insert contents from our Microsoft Word documents into an Oracle database. That is, we need to create a Forms program where we can open and select a MS Word file, and insert its contents into a table; for example, MS_DOCUMENTS.
    Thanks, and best regards,
    Franklin Gonçalves Jr.

    Hello Duncan,
    If this is on the web then WebUtil provides
    everything you need. If it's on Client Server you
    can use the OLE Container item type. no, it's not on the Web.
    I want to insert Word documents that are in my directories into database, and I've read that it can be done via BLOB table columns.
    I'd like to insert these documents and retrieve them later. Could you please tell me something about it?
    Sincere thanks for your help.
    Best regards,
    Franklin Goncalves Jr.

  • How to convert a Word document to text or html in an ABAP program

    Hi,
    At my client's site, for the recruitment system, they have the word processing system set to RTF, instead of SAP Script. This means that all the correspondence is in Word format. A standard SAP program takes the word letter, loads word, does the mail merge with the applicant's info and then sends the document to a printer.
    The program name is RPAPRT05. The program creates a document proxy (interface I_OI_DOCUMENT_PROXY) and manipulates the document using the methods of the interface.
    Now what we want to do is to instead of sending the document to a printer, we want to email the document contents to the applicant. But I don't know how to get the content from the Word document into text or html format so that I can make an email from it.
    I know I can send an email with the word document as an attachment, but we'd prefer not to do that.
    I would appreciate any help very much.
    Thanks

    Ok, here's what I ended up doing:
    First of, in order to call FM 'CONVERT_RTF_TO_ITF' you need the RTF document in a table with line length 156. The document is returned from FM 'DP_CREATE_URL' in a table with line length 132. So first I convert the table:
        Transform data table from 132 character lines to
        256 character lines
          LOOP AT data_table INTO dataline.
            IF newrow = 'X'.
            Add row to new table
              APPEND INITIAL LINE TO xdatatab ASSIGNING .
              newrow = space.
            ENDIF.
          Convert the raw line of old table to characters
            ASSIGN dataline TO .
          Check line lengths to determine how to add the
          next line of old table
            newlinelen = STRLEN( newline ).
            ADD addspaces TO newlinelen.
            linepos = linemax - newlinelen.
            IF linepos > datalen.
            Enough space available in new table line for all of old table line
              newline+newlinelen = oldline.
              oldlinelen = STRLEN( oldline ).
              addspaces = datalen - oldlinelen.
              CONTINUE.
            ELSE.
            Fill up new table line
              newline+newlinelen(linepos) = oldline(linepos).
              ASSIGN newline TO .
              newrow = 'X'.
            Save the remainder of old table to the new table line
              IF linepos < datalen.
                oldlinelen = STRLEN( oldline ).
                addspaces = datalen - oldlinelen.
                CLEAR newline.
                newline = oldline+linepos.
              ELSE.
                CLEAR newline.
              ENDIF.
            ENDIF.
          ENDLOOP.
        Write the last line to the table
          IF newrow = 'X'.
            APPEND INITIAL LINE TO xdatatab ASSIGNING .
    Next I call FM 'CONVERT_RTF_TO_ITF' to get the document in SAPScript format:
        Convert the RTF format to SAPScript
          CALL FUNCTION 'CONVERT_RTF_TO_ITF'
            EXPORTING
              header            = dochead
              x_datatab         = xdatatab
              x_size            = xsize
            IMPORTING
              with_tab_e        = withtab
            TABLES
              itf_lines         = itf_table
            EXCEPTIONS
              invalid_tabletype = 1
              missing_size      = 2
              OTHERS            = 4.
    This returns the document still containing the mail merge fields which needs to be filled in:
          LOOP AT itf_table INTO itf_line.
            WHILE itf_line CS '«'.
              startpos = sy-fdpos + 1.
              IF itf_line CS '»'.
                tokenlength = sy-fdpos - startpos.
              ENDIF.
              token = itf_line+startpos(tokenlength).
              REPLACE '_' IN token WITH '-'.
              ASSIGN (token) TO .
              ENDIF.
              MODIFY itf_table FROM itf_line.
            ENDWHILE.
          ENDLOOP.
    And finally I use FM 'CONVERT_ITF_TO_ASCII' to convert the SAPScript to text. I set the line lengths to 60, since that's a good length to format emails to.
        Convert document to 60 char wide ascii document for emailing
          CALL FUNCTION 'CONVERT_ITF_TO_ASCII'
            EXPORTING
              formatwidth       = 60
            IMPORTING
              c_datatab         = asciidoctab
              x_size            = documentsize
            TABLES
              itf_lines         = itf_table
            EXCEPTIONS
              invalid_tabletype = 1
              OTHERS            = 2.
    And then the text document gets passed to FM 'SO_NEW_DOCUMENT_ATT_SEND_API1' as the email body.

Maybe you are looking for

  • Accordion widget - put a button to go to next panel

    Hi, There is any way to put a button that, if some form's requestes are respected, go to next panel? I understood this make the next panel appear Spry.Widget.Accordion.prototype.openNextPanel = function() return this.openPanel(this.getCurrentPanelInd

  • Connect 2 routers to cable modem

    Hey guys i'm struggling here any help will be greatly appreciated. i have 2 routers with a switch and pc connected to the switch. i  am working on RIP and i enabled it on both routers. my current set up is this: PC---Switch(3550)---Router2(2610)---Ro

  • Invoking enterprise services

    Hi, We have a scenario for an  ECC webservice - > PI - > File. We are planning to use a pre delivered enterprise service . How is the webservice invoked by a transaction change? Is it similar to proxy invoking by writing an ABAP code and do the execu

  • Nokia N97 RSS Feeds

    Hi peeps! how do you go about getting RSS feeds?? i've tried getting them like the Gadget Show website feed from the UK and can't get it on mobile...

  • Multiple Port Mapping

    Hey all, I've bounced around here and the knowledge base a bit and couldnt find my answer. I have a range of 120 ports that I need to forward to my computer. I've already got everything with static IP and a couple ports working like a top. Basiclly I