Please let us know, If you have any more queries. You can achieve the required output by using following code sample. In your case, It seems that you want to insert a text at the position of Bookmark e.g bookmark1 and replace bookmark with some other bookmark node e.g ]. You can not achieve the above scenario by concatenating the string with bookmark Node and insert that string into to document. Output of tempValue is : The potato price is String tempValue = "The potato price is ~priceValue~" If you still have any complications in understanding the requirement please tell. If you open and see the document(Test.docx) there should be The potato price is (here ms word bookmark symbol). After that, Now i am going to write the tempValue in the document near (“bookmark1”). Please note here very carefully, i am replacing the ~priceValue~ with the bookmark node in the string itself. For ex: the replaced value of the string should be Next, I have to replace(~priceValue~) in the tempValue string with the bookmark notation. String tempValue = “The potato price is ~priceValue~” After that, i will fetch some value from the database column and i will store it in a java string variable. Through the application, intially i will open this document(Test.docx). Please, help me how to acheive this.Ĭonsider, i am having a document (“Test.docx”)in that there is a bookmark created by me namely bookmark1. In that i have to neglect the new line i.e ( I have to avoid the empty lines.). I have to replace all keyword with the container of ~ symbol with the bookmark for the whole document. Likewise, i have parse each line and rewrie the ~price 1~ with the bookmark in the position where ~price 1~ is placed in the document. so that i can get the bookmark name as price 1. Now, i have to read the above lines one by one from the document and got the index position of symbol ~ and i have to take the next immediate index pos of ~. for example: The price of tomato is ~price1~. In that some of the line is having ~price1~, ~price2~ like this. Please tell me the below scenario can be achievable or not.Ĭonsider that i have a document with a multiple line. What I feel is replace a string with bookmark is not possible? If possible please advise. Then only we can able to use the code what you have sent. But the code you instructed will replace the ~price Value~ with the bookmark when we already wrote the line “The potato price is ~priceValue~” in a document and we have to aware/get the bookmarks in the document the bookmark from db. In that string i have to replace the ~price Value~ with the bookmark and i have write the replaced string with the bookmark in the document. The line “The potato price is ~priceValue~” will come from a db table column. May be I have to explain my requirement very clearly. Run.setText(run.getText().substring((0), (0) (position))) Private Run splitRun(Run run, int position) throws ExceptionĪtText(run.getText().substring(position)) Signal to the replace engine to do nothing because we have already done all what we wanted. SplitRun((Run)currentNode, remainingLength) ĭocument doc = (Document)e.getMatchNode().getParentNode().getDocument() ĭocumentBuilder builder = new DocumentBuilder(doc) īuilder.write("Text inside a bookmark.") While ((remainingLength > 0)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |