Generate a Word Document

Hi,
I want to generate a Word document and populate it with some values taken from my JAVA application.
Have you got any ideas on how to do this ?
Thanks a lot.

Yeh, sure!
Here are two methods that create and write a .txt file, or anything for that matter.
call them by using:
writeToFile("Hello World", "file.txt")If the file "file.txt" doesn't exist, it will be created by makeFile();
Hope this is of some help.
public void writeToFile(String text, String fileName) {
          File thisFile = new File(fileName);
          if(!thisFile.exists()) makeFile(fileName);// If the file doesn't exist, makeFile will be called
          try {
               FileOutputStream fos = new FileOutputStream(fileName);
               byte data[] = text.getBytes();
               fos.write(data);
               fos.close();
          } catch (IOException e) {
               System.out.println("Error while writing to File.  ");
     public void makeFile(String fileName) {
          File file = new File(fileName);
          try {
               file.createNewFile();
          catch(IOException e) {
               System.out.println("ERROR while creating file.  ");
     }I'm not being rude or anything, but could I get some Duke Dollars for this - it's just that I'm running a bit low and have just spent quite a bit of time on this. But if you can't, it's cool, I understand.
Thanks
izy_t

Similar Messages

  • RoboHelp 9 Won't Generate a Word Document

    I'm trying to get RoboHelp 9 to generate a Word Document. It won't genterate and throws out the following message in output view:
    Preparing to create Printed Documentation...
    Clearing output folder...
    Preparing files for Print Document...
    Copying files...
    Updating files...
    Finished preparing in 4 seconds.
    Preparing environment...
    Cleaning up temporary files...
    Internal error encountered,  Failed to generate Printed Documentation.
    This is all I have to go on. I really have no idea where to even start trouble shooting this as there isn't a specific error message.
    Thanks!

    Have you tried generating a word file from a different project? Try it on one of the sample projects. If it works, try to generate from your project but with a limited set of topics. If this works, there must be a topic that is causing the issue. If you add further topics a few at a time until you hit the issue you will be able to identify it.

  • Unable to generate a Word document (RH9 and Office 2010)

    Hello Everybody,
    we have an issue with Robohelp 9 (patched to newest version). We are trying to generate a Word document (doc, docx) in the section of "Printed Documentation". If we click on the printed documentation on the left side (in the menübar), 2 popup windows flashing  to the screen with the following complete message: "False Parameter". I can click on "OK" if i do it, both windows will close and the General Printed Document Page is loading.
    The Problem is that all dropdown fields are blank and we cant chose .doc or .docx. I reinstalled both Programms (TCS and Office) it doesnt help me.
    I have screenshoted and uploaded the blank Print Document General window at tinypic.
    http://tinypic.com/r/t6drnn/5
    Peter Grainge was asking me:
    Also try with one of the sample projects. Click Open on the RoboHelp Starter page and then click Samples in the ribbon on the left. Same problem?
    It doesnt work. (same problem)
    Thx for help
    Greetings Andreas B

    This all points to some sort of installation issue. I notice from the screen you posted that a lot of the fields are completely blank. They shouldn't be. They should have default values. Check that you are installing following Peter's advice at http://www.grainge.org/pages/authoring/installing/installing.htm.
    Colum

  • How do I generate a Word document and a PDF from Help files?

    Hi,
    I am new to RoboHelp HTML, and am using version 8.  I updated some Help files, and now I want to generate output.  Here are my questions/ or the process I used:
    To compile the help, I clicked Generate Primary Layout.  Is this correct?  I noticed that the date stamp on the xpj file has not changed.  The date is still from many months ago.  (Why is that?  Should it show a recent update date?)  However, the files that I updated do reflect the dates when I made the updates.  These include art files, an hhp, and htm, js, ldb, pss, cpd files.
    To generate a pdf, I clicked Generate PDF.  I was not able to generate the PDF at first, but then, I enabled macros in Word 2007 (Trust Center Settings > Enable all macros...and clicked the checkbox, Trust access to the VBA project object model), and clicked Generate PDF.  At the end of the generation, I got this error in Word: Microsoft Office Word has encountered a problem and needs to close.  We are sorry for the inconvenience.  The info you were working on might be lost.  Word can try to recover it for you.  I closed the dialog and Word generated several blank documents.  Microsoft Office Diagnostics was run and found one problem and corrected it.  Despite the error message, a pdf was generated.  (If you could give me any insight on why I got the error messages, that could be helpful to know).
    How do I generate a Word document?
    Thank you!
    Erin

    Welcome to our community
    Note that RoboHelp is capable of creating a variety of layouts. WebHelp, FlashHelp, AIR Help, Microsoft HTML Help, JavaHelp, Oracle Help, ePub and more.
    Any of these layouts may be nominated as the Primary layout. So when you generate the Primary layout, you get whatever has been configured as the Primary layout.
    Only certain actions will result in a change to the .XPJ file. The actions are indicative of major changes to the project. So I wouldn't fret the fact that the date time stamp wasn't updated.
    Indeed the Printed Documentation Single Source Layout recipe is what you use to create PDF. Generally what happens is that RoboHelp creates a Microsoft Word document as an intermediate file type, then creates the PDF from that. As you might imagine, there are a host of things that can go wrong during the process. I might suggest that you first get a Word document to generate cleanly. Then once you do that, focus on PDF. I know that I typically gen a Word document and stop there. I just open Word and use Word to create the PDF.
    If you look at the properties for the Printed Documentation Single Source Layout recipe (View > Pods > Single Source Layouts then right-click the Printed Documentation layout and choose Properties) you will see that PDF, Word or both are options at the top of the dialog.
    Hopefully that gives you a nudge in the right direction.
    My fellow Adobe Community Expert Peter Grainge has excellent info on Printed Documentation on his site at Grainge.org. Click the link below for that.
    Click here to visit Peter's site
    Cheers... Rick
    Helpful and Handy Links
    RoboHelp Wish Form/Bug Reporting Form
    Begin learning RoboHelp HTML 7 or 8 moments from now - $24.95!
    Adobe Certified RoboHelp HTML Training
    SorcererStone Blog
    RoboHelp eBooks

  • Generating Excel/Word Document with PHP/MySQL

    Hi all,
    I would like to know the best way I could create a Excel/WORD
    document that can take the name, address, from my mailing list
    table and use mail merge to print envelopes?
    Any ideas? Or is there any software than can help me?
    Thank you in advance

    Luis Godinho Ramos wrote:
    > SELECT *
    > FROM produtos
    > WHERE prod_modelo LIKE %colname% AND prod_funcao LIKE
    %colname% AND
    > prod_descricao LIKE % colname% AND prod_tags LIKE
    %colname%
    > ORDER BY prod_modelo ASC
    The second example you give is closer, but you need to
    enclose the query
    fields in quotes and use OR rather than AND...
    SELECT * FROM produtos WHERE prod_modelo LIKE '%colname%' OR
    prod_funcao
    LIKE '%colname%' OR prod_descricao LIKE '%colname%' OR
    prod_tags LIKE
    '%colname%' ORDER BY prod_modelo ASC
    HTH,
    Pete.
    Peter Connolly
    http://www.kpdirection.com
    Utah

  • Auto-generating word documents from word templates

    How would one go about generating a word document based off of a word template (.dot)? For example, I have a simple JSP form which has a field "Last Name". When submitted, the "Last Name" is plugged into a corresponding bookmark in a .dot file. Then the .dot file is saved as a .doc file and presented to the user for download. So, breaking it down:
    1. User fills out a jsp form with "Last Name" and hits the submit button
    2. The submit button triggers a routine to:
    a. open a .dot file on the server (static location)
    b. find the bookmark where the last name should be plugged in
    c. plugs the value of last name
    d. saves the .dot as a word document
    e. presents to the user for download
    Has anyone done a similar thing before? Any pointers?

    There's a lot of templating projects around that are usable in Java. I'm not aware of any that use closed proprietary technology like Word and I wouldn't base my design on that either. If you're stuck with that idea then I don't have any suggestions.

  • Infopath Multi Textbox and OpenXML to generate word document

     Hi,
    I'm reading multiple InfoPath Textbox (set to display multiple lines) using OpenXML and generating a word document based on a template collecting data from InfoPath. I'm using following code,  the code gives error in
    AddMultiLineText at Paragraph p = sdt.GetFirstChild<SdtContentBlock>().GetFirstChild<Paragraph>(); 
    The code actually works when I use only one Multi Textbox but fails if its more than one. I'm quite new to Infopath and OpenXML, I would appreciate some help ASAP as its holding me in my project:
    Event Receiver
      public override void ItemAdded(SPItemEventProperties properties)
               try
                   this.EventFiringEnabled = false;
                   string siteUrl = properties.WebUrl;
                   SPListItem item = properties.ListItem;
                   SPWeb web = properties.Web;
                   SPList lib = web.Lists["DocLib"];
                   SPFile file = lib.RootFolder.Files["template.docx"];
                   string generatedDoc = "";
                   if (file != null)
                       byte[] templateBytes = file.OpenBinary();
                       using (MemoryStream ms = new MemoryStream())
                           ms.Write(templateBytes, 0, (int)templateBytes.Length);
                           byte[] convertedDocBytes = ConvertInfoPathToWord(ms, item.File);
                           generatedDoc = item["LinkFilename"].ToString().Replace("xml", "docx");
                           SPFile newFile =
                             lib.RootFolder.Files.Add(generatedDoc, convertedDocBytes, true);
                           ms.Close();
     private byte[] ConvertInfoPathToWord(MemoryStream ms, SPFile file)
               byte[] bytes = file.OpenBinary();
               using (MemoryStream msInternal = new MemoryStream(bytes))
                   XmlDocument doc = new XmlDocument();
                   doc.Load(msInternal);
                   XPathNavigator root = doc.CreateNavigator();
                   root.MoveToFollowing(XPathNodeType.Element);
                   string ns = root.GetNamespace("my");
                   XmlNamespaceManager nsMgr = new XmlNamespaceManager(new NameTable());
                   nsMgr.AddNamespace("my", ns);
                    string multiLineText1 = root.SelectSingleNode(
                     "/my:myFields/my:field1", nsMgr).Value;
                   string multiLineText2 = root.SelectSingleNode(
                     "/my:myFields/my:field2", nsMgr).Value;
                    using (WordprocessingDocument myDoc =
                     WordprocessingDocument.Open(ms, true))
                       MainDocumentPart mainPart = myDoc.MainDocumentPart;
                       List<OpenXmlElement> sdtList = InfoPathToWord.GetContentControl(
                         mainPart.Document, "multilinetext1");
                       InfoPathToWord.AddMultiLineText(multiLineText1, ref sdtList);
                       List<OpenXmlElement> sdtList = InfoPathToWord.GetContentControl(
                         mainPart.Document, "multilinetext2");
                       InfoPathToWord.AddMultiLineText(multiLineText2, ref sdtList);
                        myDoc.Close();
                   msInternal.Close();
               return ms.ToArray();
            public static List<OpenXmlElement> GetContentControl(
              Document doc, string name)
                List<OpenXmlElement> list = new List<OpenXmlElement>();
                List<SdtBlock> sdtList = doc.Descendants<SdtBlock>()
                  .Where(s => name.Contains(s.SdtProperties.GetFirstChild<SdtAlias>()
                  .Val.Value)).ToList();
                if (sdtList.Count == 0)
                    List<SdtRun> sdtRunList = doc.Descendants<SdtRun>()
                      .Where(s => name.Contains(s.SdtProperties.GetFirstChild<SdtAlias>()
                      .Val.Value)).ToList();
                    foreach (SdtRun sdt in sdtRunList)
                        list.Add(sdt);
                else
                    foreach (SdtBlock sdt in sdtList)
                        list.Add(sdt);
                return list;
            public static void AddMultiLineText(
              string multiLineText, ref List<OpenXmlElement> sdtList)
                string[] lines = multiLineText.Split(new char[] { '\n' });
                if (sdtList.Count != 0)
                    foreach (OpenXmlElement sdt in sdtList)
                        for (int i = 0; i < lines.Length; i++)
    Paragraph p =
                              sdt.GetFirstChild<SdtContentBlock>().GetFirstChild<Paragraph>(); //this ERRORS
                            if (i == 0)
                                InfoPathToWord.WriteText(lines[i], ref p);
                            else
                                Paragraph pNext = sdt.AppendChild((Paragraph)p.Clone());
                                InfoPathToWord.WriteText(lines[i], ref pNext);

    Additional Info: multiLineText1 and multiLineText2 are "Plain Text Content Control" in the word template used to create the word document.

  • Regarding "Generate Word document"

    Hi,
    I have one layout of xml publisher. In the layout I have made the page setup as
    Margins:
    Top - 0.3 Bottom - 0.3
    Left - 0.5 Right - 0.5
    and in Layout tab I have
    Header - 0.3 Footer - 0.3
    I have attached this layout in the Templates tab of XML Publisher responsibility.
    But when I am trying to Generate Word Document of my report, The layout and margins gets distorted.
    The Margins change to
    Top - 0.42 Bottom - 0.4
    Left - 0.46 Right - 0.46
    and in Layout tab I have
    Header - 0.5 Footer - 0.5
    Please help me out how can I control the header and footer of my report. Your ideas are welcome at [email protected]
    Thanks.
    Edited by: user5427917 on Nov 7, 2008 12:27 PM

    How are you generating the Word documents, manually? I haven't used it, but it looks like docx4j might be good library for building the documents. General documentation can be found [here|http://dev.plutext.org/trac/docx4j/wiki], description of [Java API|http://dev.plutext.org/docx4j/javadoc-2.2.2/] and here's the [download|http://dev.plutext.org/docx4j/].
    Cheers, harald

  • How to get the number of page by creating OLE microsoft word document

    Hihi Experts,
    I have generated a word document using ole in sap abap report.
    May i know which command can i use to call the word object to get the number of page before closing the word document?
    eg. call method of wordobj 'insertpagefield' ? and i need to require the page number in a variable eg. gv_pagenumber for other filtering purposes.
    Thanks and Regards,
    li Hui
    Edited by: lihui lil on Aug 11, 2009 9:35 AM
    Edited by: lihui lil on Aug 11, 2009 12:36 PM

    hi,
    use the following code:
    CALL METHOD OF gv_selection 'Information' = gv_curpage
        EXPORTING
        #1 = 3. " get current page number
      CALL METHOD OF gv_selection 'TypeText'
        EXPORTING
        #1 = gv_curpage. "show current page number
      CALL METHOD OF gv_selection 'TypeText'
        EXPORTING
        #1 = ' of '.
      CLEAR gv_endpage.
      CALL METHOD OF gv_selection 'Information' = gv_endpage
        EXPORTING
        #1 = 4. "get total page number
      CALL METHOD OF gv_selection 'TypeText'
        EXPORTING
        #1 = gv_endpage. " show total page number
    Edited by: VoonHan on Oct 13, 2009 7:35 AM

  • Space Before Text in Word Document

    Having generated a word document I noticed that thre was
    space before all my paragraphs. Simple to fix, or so I thought.
    When I checked the paragraph setting s in word there was no space
    before the paragraph. Checked the paragraph above, and that did not
    have space after set.

    If the extra spacing is not in your Word output files, then
    it must be in your RH source files.
    There's either something at each of the paragraphs, or in the
    HEAD section of the topic, or in your CSS style sheet assigned to
    the topic. The proximity of styling info to its content is what
    determines its effect.
    Good luck,
    Leon

  • Missing images in Word Document

    I am having a problem with some missing images when I
    generate a Word document from RoboHelp HTML. I have seen similar
    problems in these forums and have tried the solutions without
    success. I have Word 2002 SP3. I have images in my document that
    have conditional tags applied to them. Up until now, I have not had
    any trouble with them generating in Word. I added some more images
    (using RH to import them into my doc) and I set up the conditional
    tags to print those and not the others. In some cases, the images
    are generated and in others they are not. There is no X in its
    place just a blank line. I have tried erasing the .CPD file and
    re-generating. I have tried removing and re-inserting the image.
    Also, if I generate the html web help, the images are all there. No
    problem. I have tried embedding the images and using links and get
    the same result. I have not tried to just generate the PDF because
    I need to tweak the document in Word first before generating the
    PDF to make everything look good.
    I have also uninstalled and reinstalled Robohelp. That didn't
    help either. The image properties all have none (not left or
    right). I am running out of ideas to solve this problem. Everything
    worked great before so I can't figure out what could possibly be
    wrong especially since the webhelp is fine. I also tried moving the
    project to my C drive. No change either. The project usually
    resides on a network drive.
    If anyone can help, I'd really appreciate it since I have a
    document to print for a customer ASAP! Thank you in advance.
    Evelyn

    I have been suffering with this problem of missing graphics for some time, even with RoboHelp 8. However, it now seems that I have found the answer and just in case anyone else is still having this problem I thought I would share what worked for me.
    After doing some Google searching I found the web site: http://www.gmayor.com/mail_merge_graphics.htm where the following solution was offered for problems with Mail Merge graphics:
    "If you find that on merging to a new document the resulting paths have been changed to something like: {INCLUDEPICTURE"../,./../program%20files/My Program/ProductPictures/ImageName.jpg"\*MERGEFORMATINET} and the merge does not work correctly:-
    (In Word 2003) Select Tools > Options > General > Web Options and uncheck "Update links on save""
    Whatever this has to do with anything I do not know, but it magically fixed my problem and all images are now appearing in the RoboHelp Word output.
    Cheers,
    Chris

  • Attaching a word document to the work item

    Hello Everyone,
                              I want to send an attachment with the work item. My requirement is as follows.
    Iam working on CRM.  The Business Object which Iam using is BUS2000116. In this Activity, there is an attacment tab. Here the user will generate a word document which is populated with the values from the Activity.
    I need to send this word document as an attacment through a work item when status gets changed.
    I can send the work item. But in my BO BUS2000116, the attachment is not being shown. So I can't do any binding to the Container element Attach_objects.
    Please let me know how to achieve this.
    Regards
    Hari

    Use SAP_WAPI_ATTACHMENT_ADD function module.
    or  There is also a step type in 4.6 you can use in the workflow -Generate
    Document from a template. You can create doc template (e.g. using
    MS Word) and insert a placeholders in the text which would at
    generation time be substituted with values from corresponding container
    elements.
    <inappropriate content removed by moderator>
    Thanks
    Yogesh Sharma
    Edited by: Mike Pokraka on Jul 1, 2008 1:34 PM

  • Converting HTML into a Word document

    Hi all,
    I have a JSP whose content type is set so that the HTML it produces is opened up in Word. Now this works fine until images come into the equation, as these images must lie somewhere in order to be referenced from the HTML code. As this document must be 'stanalone', booting up the HTML in Word and simply changing the file extension is no good as it is still HTML under the hood.
    What I therefore would like to do it generate a Word document from this HTML that is independent in the fact that it 'holds' these images within itself and does not rely on external resources. Does anyone know how I can achieve this?
    I have looked into Jakarta POI and have written this off as an option because 1) it is still in development and 2) there is no documentation or examples of how to use what is already there. I am assuming someone has come across this problem before and knows of a solution out there that I could use.
    Many thanks in advance!

    HI,
    Thanks all for your replies! Unfortuantely it can't be PDF as the creator will need to edit it before the document is complete. I have actually looked into generating an RTF document instead, but the example I tried seemed to loose the image data. Unfortuantely I know nothing about RTF and so kind of gave up on it :(
    Here is the code I used:
    import java.io.ByteArrayOutputStream;
    import java.io.StringReader;
    import java.io.IOException;
    import javax.swing.text.BadLocationException;
    import javax.swing.text.html.HTMLDocument;
    import javax.swing.text.StyledEditorKit;
    import javax.swing.text.rtf.RTFEditorKit;
    import javax.swing.text.html.HTMLEditorKit;
    public class FormatConverter {
         private HTMLDocument tempHTMLDoc;
         private HTMLEditorKit htmlKit;
         private RTFEditorKit rtfKit;
         public FormatConverter() {
              tempHTMLDoc = new HTMLDocument();
              htmlKit = new HTMLEditorKit();
              rtfKit = new RTFEditorKit();
         private String fudge(String strText) {
              String strResult = "";
              StringReader reader = new StringReader(strText);
              try {
                   tempHTMLDoc.remove(0,tempHTMLDoc.getLength());
                   htmlKit.read(reader,tempHTMLDoc,0);
                   ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
                   rtfKit.write(byteArrayOutputStream,tempHTMLDoc,0,tempHTMLDoc.getLength());
                   strResult = byteArrayOutputStream.toString();
              catch(IOException ie){}
              catch(BadLocationException ble){}
              return strResult;
         public static void main(String args[]) {
              FormatConverter conv = new FormatConverter();
              String strRTF = conv.fudge("<P><IMG src=\"http://intratestgbr/announcements/images/1093429553065.jpg\"></P><P> </P><P>50 <STRONG>pounds</STRONG>, <FONT color=#0000ff>wow</FONT></P>");
              System.out.println("RTF: '"+strRTF+"'");
              strRTF = conv.fudge("<html><head><p class=default><span style=\"color: #000000\">Description </span><span style=\"color: #000000\"><b>with</b> </span><span style=\"color: #000000\"><i>some</i> </span><span style=\"color: #000000\"><u>formatting</u> </span><span style=\"color: #000000\"></span></p></head></html>");
              System.out.println("RTF: '"+strRTF+"'");
              System.exit(0);
    }The output I got from this was:
        \rtf1\ansi
            \fonttbl\f0\fnil Monospaced;
            \colortbl\red0\green0\blue0;\red0\green0\blue255;
        \par
        \~50 pounds, \cf1 wow\par
    }Like I said, when I open the RTF output in Word, everything is fine apart from the missing image. If one of you very nice people could point me in the right direction of a way to convert it to RTF instead while still maintaining the images this would certainly be a very acceptable solution and I would be very grateful :)
    Many thanks again!

  • Can I generate separate Word docs and retain cross-references?

    I've poked around the forum and am seeing an answer to this, so forgive me if it's already been answered.
    I'd like to generate separate Word documents from within RH8 (as opposed to a single Word doc of the entire help system) and yet retain the functional cross-references across documents.
    As it is, if I generate the help as a group of Word docs, only cross-references having destinations within the same Word document are present. That's not hugely surprising, but it would help me a great deal if intra-document cross-references were present in the generated Word docs.
    Any ideas how I can do this?

    I believe that might work if you used the master document method. That said I strongly recommend that you research Word's master document method as everything I have read indicates the Word gurus suggest it has problems.
    Why would you want all these links working? If that is needed, shouldn't the user be accessing the online help?
    See www.grainge.org for RoboHelp and Authoring tips
    Follow me @petergrainge

  • Output word document generation from the properties.

    Hi Everybody,
                   I need to generate a word document from the Substance property values stored. How to generate a word document in a specified format..
    Thanks,
    Rajesh.

    Hi Andeas,
                  My problem is, I want to create the templates as well as i want to see the generated reports.
                   While installing WWI, i got four options called 1.Information system/labelling Workstation, 2.Install generation server, 3.Workstation for editing templates and 4.WWI file server installation. I installed only third one Workstation for editing templates. Should i install other than that as well.
                   I want to confirm the procedure for the release template as well. Before releasing a template you need to add the template through the DMS and next mention the same template in the CG42. After that create the variant (CG2B). Next go to CG02. I think while going through a help i gone through a sentence like first i need to upload file in CG3Z and Import template CGCZ things. I just checking whether they are working properly or not.
             Also while trying to create a template from WWITEMPLATE in the Layout folder, i used <i>WWI -> Insert Symbol</i> is not giving any values. Any idea on this
                  Please give me some advice..
    Thanks,
    Rajesh.
    Message was edited by:
            Rajesh Madala

Maybe you are looking for