File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Open Source Projects and the fly likes Could not able to add properties to the pargraph in doc file using apache poi HWPF Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Reply Bookmark "Could not able to add properties to the pargraph in doc file using apache poi HWPF" Watch "Could not able to add properties to the pargraph in doc file using apache poi HWPF" New topic
Author

Could not able to add properties to the pargraph in doc file using apache poi HWPF

varun narisetty
Greenhorn

Joined: Oct 14, 2009
Posts: 8
hi frds i am new to the coderanch
i am using this code


the problem I am facing here is I am able to generate the doc file but the properties are not assigned to the paragraphs.
one more issue is that the doc file generated contains these paragraphs in every page and the number of pages also increasing continuously.
if any one know the solution please help me.
thanks in advance.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 32767
Welcome to JavaRanch.

the problem I am facing here is I am able to generate the doc file but the properties are not assigned to the paragraphs.

What do you mean by "properties" - bold, font size and such?

one more issue is that the doc file generated contains these paragraphs in every page and the number of pages also increasing continuously.

This code only creates a single page, so what do you mean by "in every page"? Under which circumstances are you getting more than one page?

Which version of POI are you using? If it's anything but 3.5, get the latest one.


Android appsImageJ pluginsJava web charts
varun narisetty
Greenhorn

Joined: Oct 14, 2009
Posts: 8
I am using the POI 3.5 what you said is correct here properties I mean are bold italic e.t.c
here the doc file generated contains more than one page and the page numbers are increasing continuously.

thanks for your reply
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 32767
Please post replies once, not 5 times.

Just to make sure I understand: The file "empty.doc" contains absolutely nothing at the beginning, the file "new-hwpf-file.doc" does not exist, then you run the above code once and end up with a file "new-hwpf-file.doc" that contains multiple pages? That doesn't sound right. And what do you mean by "continuously"?
varun narisetty
Greenhorn

Joined: Oct 14, 2009
Posts: 8
I have generated a document using above code in Java , and when ever I try to open this document , number of pages are getting added automatically with the same content that I have given to the first page and subsequently the pc is hanging , You are right that this code should generate only one page, but its not happening here , it is generating multiple pages and its halting nowhere!!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 32767
You shouldn't open the document until the code has finished running. Are you saying opening the document somehow causes the code to run again?
varun narisetty
Greenhorn

Joined: Oct 14, 2009
Posts: 8
I am not opening the document before its running.
even i try to open the document in another system also I am getting the same result.
Ashok Sarathy
Greenhorn

Joined: Apr 13, 2010
Posts: 2
Hi,

I used the program and when i compile i get

Exception in thread "main" java.lang.NullPointerException
at action.CreateWordDoc.main(CreateWordDoc.java:47)


I believe line 47 is CustomProperties cp = dsi.getCustomProperties(); i tried to debug and the object dsi is null. I did create empty.doc and gave the path correctly. I know this for sure because at first i was getting file not found exception and after i created the file and specified the path this exception went away.


I also tried commenting the entire setting custom document property part. When i did this, the program runs but nothing was getting written into new-hwpf-file.doc.

Any pointers on why this is happening? I am using poi 3.5, i also tried with poi 3.6.


Thanks,
Ashok
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3206

Hi Ashok and welcome to Javaranch! You may be best off starting a new thread with your specific question and the code you are using.


Cheers, Martijn - Blog, Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!
Ashok Sarathy
Greenhorn

Joined: Apr 13, 2010
Posts: 2
Hi,

The code i am using is



when i compile i get

Exception in thread "main" java.lang.NullPointerException
at action.CreateWordDoc.main(CreateWordDoc.java:47)


I believe line 47 is CustomProperties cp = dsi.getCustomProperties(); i tried to debug and the object dsi is null. I did create empty.doc and gave the path correctly. I know this for sure because at first i was getting file not found exception and after i created the file and specified the path this exception went away.


I also tried commenting the entire setting custom document property part. When i did this, the program runs but nothing was getting written into new-hwpf-file.doc.

Any pointers on why this is happening? I am using poi 3.5, i also tried with poi 3.6.


Thanks,
Ashok
Johns Abraham
Greenhorn

Joined: Dec 03, 2007
Posts: 1
Hi varun narisetty, did you got any solution for your problem?
I am facing the same !!
I there any sample sites for this(word creation using apache poi)?
Please help me, Thanks, Johns

 
 
subject: Could not able to add properties to the pargraph in doc file using apache poi HWPF
 
Threads others viewed
HWPF POI
How to Create word document with Check box form fields using POI API ?
insert header and footer with POI HWPF?
creating word document
How to create MS Word Doc using HWPF POI
jQuery in Action, 2nd edition