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

Free Support Forum - aspose.com

Word Text Box is not convert into html

I am trying to convert .docx to.HTML. But the text box is showing as an image. I need it as text.

My input and out file is given below…test.zip (17.8 KB)

I need output like it will be text not image. My expected output is given below…
expected Output.zip (17.5 KB)
i nedd text box will treat as text in html file.

CODE:–>

Document document = new Document(“D:\test\Aspose\problemDocx\test\” + file.getName());
String fileNameWithoutExtension = FilenameUtils.removeExtension(file.getName());
document.save(“D:\test\Aspose\problemDocx\html\” + fileNameWithoutExtension + “.html”);

@rabin.samanta

In your case, we suggest you please use the HtmlSaveOptions.ExportTextBoxAsSvg property to export the textbox as SVG. Please check the following code example. Hope this helps you.

Document doc = new Document("input.docx");
HtmlSaveOptions options = new HtmlSaveOptions();
options.setExportTextBoxAsSvg(true);
doc.save("output.html", options);

@tahir.manzoor
thanks …

@tahir.manzoor

hi,
If i wants to store .docx file as HTMl txt.
file store will be in .txt format.
then how i am use TxtSaveOptions and HtmlSaveOptions for save file .

code :–>

Document document = new Document(filePath);
TxtSaveOptions options = new TxtSaveOptions();
options.setSaveFormat(com.aspose.words.SaveFormat.TEXT);
options.setEncoding(java.nio.charset.Charset.forName(“UTF-8”));

	HtmlSaveOptions saveOptions = new HtmlSaveOptions();
	saveOptions.setExportTextBoxAsSvg(true);
	saveOptions.getSaveFormat();

	options.setExportHeadersFooters(false);
	options.setParagraphBreak("\n");
	options.setPreserveTableLayout(false);
	options.setPrettyFormat(true);
	document.save(name, saveOptions);

How I will remove header and footer for docx file.
And also read textbox.
test.zip (14.9 KB)
My expaction is ,
conevrt docx to html and sote in .txt formate.

@rabin.samanta

Please use HeaderFooterCollection.clear method to remove all nodes from this collection and from the document.

Following code example shows how to remove the header and footer of document and export the shape’s text in output HTML. You can change the extension of output file name to TXT as shown below. Hope this helps you.

Document doc = new Document(MyDir + "test.docx");
//Remove header and footers from document.
for (Section section : doc.getSections())
{
    section.getHeadersFooters().clear();
}

DocumentBuilder builder = new DocumentBuilder(doc);
NodeCollection shapes = doc.getChildNodes(NodeType.SHAPE, true);
for (Shape shape : (Iterable<Shape>) shapes) {
    if(!shape.hasImage())
    {
        builder.moveTo(shape);
        builder.write(shape.toString(SaveFormat.TEXT));
        shape.remove();
    }
}

HtmlSaveOptions options = new HtmlSaveOptions();
options.setExportTextBoxAsSvg(true);
doc.save(MyDir + "19.3.txt", options);

@tahir.manzoor
thanks…
It’s working fine

@rabin.samanta

Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.