OK, so just to be clear, if you create a document using LibreOffice, insert a
bookmark and then try to insert some text at the bookmark's position, the
code fails completely? Are you saying that it does not insert the text at
all at the specified location? Or are you saying that because
Thanks for the reply ,
Actually i am working on Libreoffice till now for creating bookmark . It
does'nt allow you to add bookmark to a Selected text , it can add bookmark
only to a position some where in docx file .
Yesterday i tried in MS Word , giving bookmark , and then it worked smoothly
.
I created a document template (docx) , and added bookmark .
my aim to replace the text along the bookmark .
ex :
[ bookmark]Hello World
I am able to replace but , the text Hello World is still there .
When i debug the code , i found out that , the bookmarkEnd tag is
before the
Hi,
If your goal is to manage mail merge (replace field in your docx with Java
value), you can see XDocReport http://code.google.com/p/xdocreport/.
Regards Angelo
2012/12/12 sreejithcools sreejit...@beo.in
I created a document template (docx) , and added bookmark .
my aim to replace the
I suspect that is happening because you did not bookmark the text but simply
inserted the bookmark into the document in front of the Hello world phrase.
To see what I mean, try typing another phrase into the document say /to
replace/ for example. Now select that text as if you were going to
Thanks Hashem.
Never expected this piece of code to be used as it is now. The original was
written as a proof of purpose really. If I have the time, I will try to post
the full chunk again with your modifiication included.
Yours
Mark B
PS I am still convinced there is a better way to crack
I am utilizing this new code, just found that the replace method needs a
small change to keep the node's style. After we make sure nextNode is not a
bookmarkEnd we push it to stack, so push should be done in else stmt not
before if stmt.
while (bookmarkStartID != bookmarkEndID) {
Thanks for letting us know - now we are aware of what to do with bookmarks in
headers/footers if the question ever arises again.
All the best you the project.
Yours
Mark B
--
View this message in context:
Thanks for letting me know and it is good to hear that you have managed to
track the source of the problem down.
One concern I do have however is concerning the .dotm files. I am no expert
but understand that this specific extension indicates to Word that the file
contains macros but that these
Mark
Your answer was very helpful
bookmark changes related to the test proceeds are going to do
Thank you
--
View this message in context:
http://apache-poi.1045710.n5.nabble.com/How-to-read-the-value-of-bookmarks-docx-tp5710184p5710766.html
Sent from the POI - User mailing list archive at
Sorry, I do not. The key to working the problem out should be quite
straightforward though and I think that you need to do this.
Use Word to create a very simple document template file; it need only
contain maybe one sentence of text.
Re-save that same file using Word again but this time as a
The bookmark code works with Paragraph objects and so you need to get at
those paragraphs that constituite the header or footer. Look into the
XWPFHeaderFooterPolicy class; an object of this type exposes methods to
access the headers and footers, then from an XWPFHeader or XWPFFooter yo can
get
hi mark ..
Post your reporting has been a lot of help
Shine in a table format of the header is read in the body of the document's
bookmark bookmarks might not be able to read this.
Help you how to modify the contents of the header.
Thank you.
--
View this message in context:
Mark,
I did what you suggested:
1 - I created a very simple file and saved it as dotx and docx formats.
2- I changed their formats to zip and then unzipped them and compared the
contents.
3- There was a difference in contentType at [Content_Types].xml file (for
this part:
Hi Mark,
Thank you very much for your code. It was very helpful and answered most of
my questions about the docx files.
I am using .dotm templates. I give a .dotm file as input to your code, I
have put some logs in your code and track what's going on in the program, it
shows that the code runs
Mark,
You are right. I did so and your code worked properly. Do you know any
approach to open template files (.dotm and .dotx formats) in java program
modify them and then save them as .docx format?
Regards,
--
View this message in context:
Can I just check a single point with you please? Are you opening a template
file using POI, modifying that file and then saving it back again as a
.docx? If this is the case, then POI does not support this sort of operation
at all as far as I am aware. There are other features of the xml markup
Hi Mark,
thank you for your code. Your work is awesome. It works well in my tests
except the multiple cells for one bookmark. Eventhough, it's really awesome.
I can really take it to work now. Sorry because I'm not good into working
with XML. But thank you because I can get almost bookmarks
Thanks for letting me know and I hope that it serves you well.
There is already partial support for multiple cells in there; well at least
I have defined a constructor that should allow you to handle them. The
intention was to pass an array of references to the cells to the constructor
and then
This is very much a hack but I hope it will get you working for now. There
are a couple of points to bear in mind, areas that will be fixed shortly I
hope.
The first is that the code dealing with bookmarked table cells only supports
the 'replace' option at the moment. This is to say that any and
Hi Mark,
thank you so much for the detailed information. I was also suprised with the
xml-format of bookmark for table cell. And it reminds me a situation, when
the some cells in a table can be merged and link only to one bookmark. But I
dont think it often happens. Because the Word writer wants
Remember that there is nothing at all stopping you from working on this
problem yourself and adding in the functionality you require. It is easy to
look at the contents of the Word document - it is only zipped xml after all
- and see what it contains and what the results of any changes are.
If
Looking at the xml markup, the good news is that this fix should be possible
but that it might take a day or so. Not wishing to get into too much detail,
bookmarks appear in the xml markup as a matching pair of bookmarkStart and
bookmarkEnd tags. The match between a pair of tags is enforced by the
Hi Mark Breadsley,
thank you for you new updated code. I try it and it work well with the
bookmark inside or outside of table. It's awesome.
But then when I try with another type of bookmark for the table. I got
error. In this scenario, I link a whole cell of table to a bookmark. There
is no
Thanks for this example and I will take a look but no promises re time.
Yours
Mark B
--
View this message in context:
http://apache-poi.1045710.n5.nabble.com/How-to-read-the-value-of-bookmarks-docx-tp5710184p5710303.html
Sent from the POI - User mailing list archive at Nabble.com.
This is the thread I was referring to:
http://apache-poi.1045710.n5.nabble.com/Replacing-the-value-of-the-bookmarks-td5710052.html
semendian posted the HWPF code in - approximately - the third message posted
to the thread. Just copy that and it ought to get you working. Do not like
claiming
Firstly, you were absolutely correct. The code did not get the bookmarks if
they were in table cells, so thank you for spotting it and for the test
file. Anyway, I have corrected the error and all seems well now.
Secondly, I made the necessary changes last night to replace text (sorry).
Try this
Thanks for that! Try as I might, I could not get the call to getNodeValue()
to return anything other than null. Will have a play some time today with
your code to see if I can integrate it into the chunk I posted. Am thinking
about approaching Yegor with the suggestion that the insert and recover
Hi,
Thank to Mark Beardsley and unreal,
I try to run your codes and they run well in case that the bookmarks stay in
paragraphs. But it doesn't work if the tables contain the bookmarks.
Can you guys help me for this situation.
Thank so much,
online2
--
View this message in context:
Firstly, no, this code will not work for .doc files. POI is able to support
both file types - binary (.doc) and OOXML (.docx) - bt it uses two different
code bases to support them. The example code is targeted at the OOXML file
format so you can only use it with .docx files. There is an example on
try my code. I am able to replace the bookmark values.
On Tue, Jun 19, 2012 at 11:26 PM, Mark Beardsley [via Apache POI]
ml-node+s1045710n5710245...@n5.nabble.com wrote:
Firstly, no, this code will not work for .doc files. POI is able to
support both file types - binary (.doc) and OOXML
Hi Mark,
Thank you very much for this informations ! :)
With your instructions i could read out the bookmarks and solve my problem.
Thx and goodbye
--
View this message in context:
http://apache-poi.1045710.n5.nabble.com/How-to-read-the-value-of-bookmarks-docx-tp5710184p5710220.html
Sent
btw, i changed a little bit:
unreal wrote
...
public String procParasForBookmarkText(ListXWPFParagraph paraList,
String bookmarkName) throws XmlException, IOException {
IteratorXWPFParagraph paraIter = null;
XWPFParagraph para = null;
This gets part of the way but is rather ugly I am afraid.
Take a look at the main method to see how to use the code.
import java.io.*;
import org.apache.poi.xwpf.usermodel.*;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBookmark;
import
There is no easy way to do this as far as I can see. What I did was to get at
the list of CTBookmark objects from the list of Paragraphs. From each
CTBookmark object, it is possible to get at the docoument node it relates to
and to then step through the xml markup by calling the getNextSibling()
35 matches
Mail list logo