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
posted
0
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
posted
0
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.
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
posted
0
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
posted
0
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
posted
0
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
posted
0
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.
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.
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
posted
0
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