Pledgie



if you think this library has been useful, feel free to give any help. Don't be shy.


Click here to lend your support to: Java2word, coding for fun! and make a donation at www.pledgie.com !

Documentation

page moved to:
https://github.com/leonardoanalista/java2word


28 comments:

  1. Hi Leonardo,
    Your API Simple and awesome. Can we able to have a bullet points on Word Document, which is generated by Java2Word API? Look forward to have these facility.

    Thanks!

    With Regards,

    Arun Ganesh. P

    ReplyDelete
    Replies
    1. I gave it a try a while ago and didn't have much luck. I had issues with encoding and didn't display the bullet points correctly. Now we have lot more experience with encoding issues and I will put this task in the to-do list.

      thanks
      Leonardo Correa

      Delete
  2. Great. Thanks for Quick Response.

    ReplyDelete
  3. Hi Leonardo,
    Can we able to align the page number to center position on footer? And also do we have any functionality to add line on header?
    Thanks!
    With Regards,
    Arun Ganesh. P

    ReplyDelete
    Replies
    1. and also I can't able to change the font to Arial.

      Delete
  4. Hi Leonardo, Your API really looks good and helped us for using Document in our product. Also Can you please guide me how to create Table Of Contents in Word Document?
    Thanks In Advance.

    ReplyDelete
    Replies
    1. this is something that hasn't been implemented yet. If you use Heading1, 2 or 3, you can create manually. I haven't had time to figure out how to do it but it is based on those Heading. There must be a way to read the XML content and write code to generate the table of content on the fly just before create the physical file.

      Delete
    2. Thanks Leonardo. I will work using Heading 1,2,3 using the tasks of Table of Contents also I need one more queries that how to make indent and hanging for paragraph? and How to make line space? Thanks In Advance

      Delete
    3. Line space you use:
      myDoc.addEle(BreakLine.times(1).create());

      For Paragraph indentation you do this way:
      myDoc.addEle( Paragraph.with("TableRowV2 with merge").withStyle().indent(Indent.TWO).create() );

      Someone implemented this and I forgot who was it.
      Don't know about hanging paragraph.

      Delete
  5. Hi Leonardo, Your API Looks good and helped us to generate word report in our java project. Also Can you guide me to generate Reference>Table Of Contents from the API. Very urgent requirement for us. So Thanks In Advance.

    ReplyDelete
  6. Hi.... does this library supports all dependencies required by android (2.2) platform.. ?

    By using this can i able to created .doc files for android platform ....

    previously i was using iText library for creating pdf in android but after wasting 3 days of programming effort and googling i came to know that any version of iText doesnt support on android
    (because classes like java.awt.Color doesnt in java doesnt support android 2.2)

    is thr any other suggessions... ?

    ReplyDelete
  7. Hi Leonardo, your API is awesome,greate work.I want to know about how to use the document indentation.

    Thanks in advance...

    ReplyDelete
  8. Hi I want to know about how to use Margin(right,left,top,bottom) of the document

    ReplyDelete
  9. Hi Leonardo, this is arunkumar. I am using your document API everything works fine but In My Application I have to display 1000 of images and display on the word report. So I have the following line this shows OutOfMemory:Heap Space issue,

    String myWord = reportDoc.getContent();
    writer.println(myWord);

    In the reportdoc I have tables with has N No of Images. Look forward your reply and guidance as soon as possible. Thanks In Advance.

    ReplyDelete
    Replies
    1. I have got a post with huge document:
      http://java2word.blogspot.com.au/2012/02/huge-ms-word-documents-with-java2word.html

      Heap memory has nothing to do with java2word. It is your JAVA_OPS. This post has similar issue:
      http://leonardo-pinho.blogspot.com.au/2009/07/javalangoutofmemoryerror-permgen-space.html

      You basically have to set an environment variable JAVA_OPTS with values mentioned on the post above.

      Let me know how you go with your document. I am interested in huge docs with this api.

      cheers
      Leonardo

      Delete
  10. Hi Leonardo,

    I am trying to insert more than 20 PNG images into word document. How do I append them in word doc? Image paths are stored in an array arrImagePath. Is it possible to insert images one by one (ie: open doc, insert image, close doc and continue inserting images). Also I also outofheap memory issue. Please advise.

    Code:

    public static void InsertImage(String[] arrImagePath, String sBrowser) throws Exception {

    PrintWriter writer = null;
    File fileObj = new File(prop.getProperty("strSnapshotDocpath")+ "IE_UITest.doc");
    writer = new PrintWriter(fileObj);

    IDocument myDoc = new Document2004();

    for(int i = 0; i< arrImagePath.length; i++){

    myWord = myDoc.getContent();
    myDoc.addEle(Paragraph.with("paragraph01").create());

    myDoc.addEle(Paragraph.with("Image Path is " + arrImagePath[i] ).create());
    myDoc.addEle(BreakLine.times(2).create());
    myDoc.addEle(Paragraph.with(""+Image.from_FULL_LOCAL_PATHL(arrImagePath[i]).getContent()).withStyle().align(word.w2004.style.ParagraphStyle.Align.CENTER).create());
    myDoc.addEle(PageBreak.create());

    }


    myWord = myDoc.getContent();
    writer.println(myWord);
    writer.close();
    }

    ReplyDelete
  11. Hi Leonardo,

    How are you doing?? It has been long time since my last post and now I am back at working with your api with which I started my career. It is awesome and very helpful for me. Here is my new issue

    I am creating a table with unequal number of columns, for example First row of the table has 2 colums and the second row might have 3, third one might have 1. I guess you must have understood the issue I am talking about. When I am trying to create a table like this The problem is the size of the table is not uniform through out. I mean to say the table is getting adjusted to the size of maximum columns and the rows in which there are lesser columns are leaving a space where there are no columns.

    I want the table to maintain the same size for example if the row has 2 columns and the row below has 3 columns the second column of first row should get streached till the end rather than getting created to the size of second column of second row and leaving space equal to the size of 3rd column of second row

    The table structure is like this by default:
    _ _
    _ _ _
    _ _
    _ _ _

    This is how I want it to be:
    _ ___
    _ _ _
    _ ___
    _ _ _

    Can you kindly suggest me what could be done to achieve the above table structure..

    Thanks in Advance.

    ReplyDelete
    Replies
    1. How are you doing? I ve been very busy and have no time to look after the project right now.
      I remember that last implementation was the TableV2.

      http://code.google.com/p/java2word/issues/detail?id=77

      take a look at the last comment. That is all we have available for now.


      cheers
      Leonardo

      Delete
    2. oh thanks Leonardo... I am doing good...

      Regards
      Phanindra.

      Delete
  12. This comment has been removed by the author.

    ReplyDelete
  13. Bom dia Leonardo,

    Estou com dificuldade em inserir uma imagem. A imagem não é carregada no documento e não percebo porquê...Eu estou a usar o seguinte código,

    myDoc.addEle(Paragraph.with(""+Image.from_FULL_LOCAL_PATHL("C:\\documents\\imagem.png").getContent()).withStyle().align(word.w2004.style.ParagraphStyle.Align.CENTER).create());

    Onde é que estou a errar?

    Outra pergunta, existe possibilidade de criar 2 colunas numa página?

    Obrigado.
    Cumprimentos,
    Patrícia Sousa

    ReplyDelete
    Replies
    1. Oi Patricia,

      Tenta inserir uma imagem da we so para ver se funciona (it doesn't work under proxy I guess):
      from_WEB_URL("http://www.google.com/images/logos/ps_logo2.png")

      Pode ser alguma coisa com essas barras do windows.


      Leonardo

      Delete
  14. Hi Leonardo,

    This is my first post and I'll be working with java2word since just two three days ago.Prior to java2word I tried apache poi and javadocx. But java2word can be used with greater flexibility. I am currently working with java web application.I am using struts2 and Netbeans IDE.I have to generate report based on some dynamic content(content from database). I achieved that using java2word and it is great to have the feature that showing the generated word file with out writing code for download.I want to add header with table which contains some text and an image.The reason for adding table is to place the image nicely.Is there any way to hide table border.Thanks in advance.

    /Sujith

    ReplyDelete
    Replies
    1. I don't think I implemented style for TableV2:
      http://code.google.com/p/java2word/source/browse/trunk/java2word/src/main/java/word/w2004/elements/TableV2.java

      Take a look at the source and see if you can temporarily change the value on line 50 and 54:
      (...) String tableTop = (...)


      Leonardo

      Delete
    2. Hi Leonardo,

      Thank you for your quick response.And I'll be working on this.Thank you again.

      /Sujith

      Delete
  15. Hi Leonardo,

    I am very impress with your blog , i am having one problem in which i spend aprox 10 days. i am fetching data from mail if simple text then it's easily display on document but if mail's contents having image+text then image is not display on document it's very urgent i want your help , please give any simple example for fetching mail with image , here is the url which i am using http://www.rgagnon.com/javadetails/java-receive-email-using-imap.html.... i am waiting for you reply..

    ReplyDelete
  16. i gt only one thing to say
    its awesome

    ReplyDelete
  17. Hi All,

    I am getting the following error when I try to run the above code. Am I missing something?
    Somebody Please guide me ASAP.
    I badly need this thing working.

    java.io.FileNotFoundException: build.properties (The system cannot find the file specified)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.(Unknown Source)
    at java.io.FileInputStream.(Unknown Source)
    at word.utils.TestUtils.createLocalDocument(TestUtils.java:45)
    at word.utils.TestUtils.createLocalDoc(TestUtils.java:30)
    at Demo_package.Java2WordTest.main(Java2WordTest.java:45)
    java.io.FileNotFoundException: null\Java2word_allInOne.doc (The system cannot find the path specified)
    at java.io.FileOutputStream.open(Native Method)
    at java.io.FileOutputStream.(Unknown Source)
    at java.io.FileOutputStream.(Unknown Source)
    at java.io.PrintWriter.(Unknown Source)
    at word.utils.TestUtils.createLocalDocument(TestUtils.java:58)
    at word.utils.TestUtils.createLocalDoc(TestUtils.java:30)
    at Demo_package.Java2WordTest.main(Java2WordTest.java:45)
    Exception in thread "main" java.lang.NullPointerException
    at word.utils.TestUtils.createLocalDocument(TestUtils.java:64)
    at word.utils.TestUtils.createLocalDoc(TestUtils.java:30)
    at Demo_package.Java2WordTest.main(Java2WordTest.java:45)

    ReplyDelete