Free Support Forum - aspose.com

Extract Content Controls Data from RTF & Convert to Word (DOCX DOC) Document using Java | Custom Bookmarks

Hi

This is Mahesh from Vitech Systems Inc , we are looking for a Aspose product which can convert RTF documents to MS word format .

We have a special requirement, which we have a customized book marks in our RTF documents , so need to convert these book marks from RTF to word documents .

Could you please let us know if Aspose tools able to convert this Bookmarks from RTF to Word format ? if you need we will discuss further on this and will share the sample documents .

Thanks
Mahesh Palagani
+201-554-5682

@maheshpalagani,

Thanks for your interest in Aspose APIs.

Yes, you can meet this requirement by using Aspose.Words for .NET API. Please refer to the following sections of documentation:

Please let me know if I can be of any further assistance.

Hi,

Can you please suggest java examples for same , also the required jars to fix this issue.

Thanks
Mahesh Palagani

@maheshpalagani,

Please refer to the following pages:

@awais.hafeez
Here is the attached word document, customized bookmark has been missing after conversion.
we are unable to retrieve it while conversion.

Bookmark bookmark = doc.getRange().getBookmarks().get(“Bookmark1”);

Book MarkSample.PNG (87.8 KB)

could You please help me to convert customized bookmark.

@Sudha_Mylapalli,

Please ZIP and upload your simplified input Word document and your expected Word file showing the desired output here for testing. We will then investigate the issue on our end and provide you more information.

@awais.hafeez

hi Hafeez,

here is the attachment for sample docs.
sampleDocs.zip (31.1 KB)

@Sudha_Mylapalli,

You have attached only the input.docx file. Can you please also ZIP and attach your expected Word file showing the desired output here for testing? You can create expected document by using MS Word. We will then investigate the scenario further on our end and provide you more information.

As far as bookmarks are concerned, we found only one bookmark named “Bookmark1” in “input.docx” and its content is “External Attachment”. The following code returns it correctly:

Document doc = new Document("E:\\temp\\SampleDocs\\input.docx");
Bookmark bookmark = doc.getRange().getBookmarks().get("Bookmark1");
System.out.println(bookmark.getText());

@awais.hafeez

Here is the attached Zip file. Input File has customized bookmark. V3:B symbol indicates customized bookmark.

Documents.zip (72.1 KB)

@Sudha_Mylapalli,

These customized bookmarks that you are referring to are actually Content Controls (represented by StructuredDocumentTag class). You can get the string representation of such Content Controls in Word document by using the following Java code:

Document doc = new Document("E:\\Temp\\Documents\\InputDoc.docx");

for (StructuredDocumentTag sdt :
        (Iterable<StructuredDocumentTag>) doc.getChildNodes(NodeType.STRUCTURED_DOCUMENT_TAG,
                true)) {
    if (sdt.getTitle().equals("V3:B")) {
        System.out.println(sdt.toString(SaveFormat.TEXT));
    }
}

You can also extract the Nodes from inside such Content Controls and place them into a new Document.

Hope, this helps in achieving what you are looking for.

@awais.hafeez
Thanks a lot, but it did not search for whole document file. I mean in Table, bookmark is available. Could you suggest how to get bookmark in table too.

please find the zip fileBookmarkSampleFile.zip (141.0 KB)

And I want to read RTF Bookmark and convert it to Word doc from java.
please find the rtf file ,symbol for Bookmark in file is BK .

@awais.hafeez

Hi Hafeez,

We need a program in such a way that, the input customized Bookmark should be available in the same alignment(as it is in the same place) after retrieval from .rtf to the .doc file.
Sample documents ( BookmarkSampleFile.zip (141.0 KB))are available in my last comment.

@Sudha_Mylapalli

We are checking this scenario and will get back to you soon.

@awais.hafeez
Hi Hafeez,

I want Java program to convert open office document(ODT) to word document for Aspose .

@Sudha_Mylapalli,

You can use the following simple Java code to convert open office document (ODT) into DOCX, DOC, RTF, WordML or other file formats (see Supported Document Formats).

Document doc = new Document("input.odt");
// Save the ODT document in DOCX format.
doc.save("output.docx");

Hope, this helps.

@awais.hafeez
Document doc = new Document(“input.odt”);
// Save the ODT document in DOCX format.
doc.save(“output.docx”);

with this code im able to convert the file but its not coming expected output file .please find the attached zip file odt_ToDoc.zip (300.9 KB)

@Sudha_Mylapalli,

The problem occurs because “outputFile.docx” was generated by using a very old (15.12) version of Aspose.Words for Java on your end (in evaluation mode i.e. without applying license).

After an initial test with the licensed latest (20.5) version of Aspose.Words for Java, we were unable to reproduce this issue during converting ODT to DOCX on our end. Please see the output DOCX document generated on our end by using the following simple Java code:

Java Code:

Document doc = new Document("E:\\Temp\\odt_ToDoc\\inputFile.odt");
doc.save("E:\\Temp\\odt_ToDoc\\awjava-20.5.docx");

So, we suggest you please upgrade to the latest version. Hope, this helps.

@awais.hafeez

Any Updates on this.

Thanks @awais.hafeez,

now odt to docx is converting.After taking licence for Aspose,watermark and licensed String Aspose will remove Right.

@awais.hafeez
suggest me on how to fetch bar code, when converting from open office to Doc .