We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Getting text whilst retaining it's formatting

Hi

I was trying to retrieve formatted text from a document (in order to pass into another document, keeping it's text formatting) using the following article:

http://www.aspose.com/documentation/file-format-components/aspose.words-for-.net-and-java/extracting-document-elements.html

I created the DocToTxtWriter Class and tried to copy formatted text using the code below.

Unfortunately the resulting text that is printed (docToTxtWriter.GetText) seems to be blank. The document definitely has text in it. Is there something else I have to do or am I missing something?

Many thanks,

public void ToText(String documentDir, String documentName) throws Exception

{

// Open the document we want to convert.

Document doc = openDocument(documentDir,documentName);

// Create an object that inherits from the DocumentVisitor class.

DocToTxtWriter docToTxtWriter = new DocToTxtWriter();

doc.accept(docToTxtWriter);

System.out.println(docToTxtWriter.GetText());

}

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. Actually, this code gets plain text from the document. But you mentioned that you need to insert formatted text.

I think the following articles could be more useful for you.

http://www.aspose.com/documentation/file-format-components/aspose.words-for-.net-and-java/insert-a-document-into-another-document.html

http://www.aspose.com/documentation/file-format-components/aspose.words-for-.net-and-java/append-one-document-to-another.html

Best regards.

Thanks again Alexey,

very much appreciated.