Free Support Forum - aspose.com

Saving word document as html file give a string output instead of a web page


#1

Hi Team,
I am trying to save the a word document as html file
but the reult is giving me a file that opens up as a string not as a html web page

I have used this code snippet:
OutputStream output = new ByteArrayOutputStream();
HtmlSaveOptions options = new HtmlSaveOptions();
options.setSaveFormat( SaveFormat.HTML );
options.setExportRoundtripInformation( true );
options.setEncoding( Charset.forName( “UTF-8” ) );
options.setExportPageSetup( true );
options.setExportHeadersFootersMode( ExportHeadersFootersMode.PER_SECTION );
options.setExportImagesAsBase64( true );
options.setExportFontsAsBase64( true );
template.save( output, options );

can you please help me with this ASAP

Documents.zip (101.1 KB)

word doc is the document
file named 15024383131416 should be a web page
the same i have tried with saveformat.pdf for which the file named 28584402286903 is created which is a pdf type


#2

@khushboomehta,

Please ZIP and upload your input Word document and Aspose.Words generated HTML file showing the undesired behavior here for testing. We will then investigate the issue on our end and provide you more information.


#3

Please see the attachment above


#4

@khushboomehta,

I am afraid, there is no Word document included in your ‘Documents.zip’ archive. Is ‘input_word_document.html’ your input file? We notice that this file was generated by using Aspose.Words for Java 18.7. Can you please also upgrade to the latest version i.e. 18.12 and see how it goes on your end?
Upgrade to the latest version of Aspose.Words for Java i.e. 18.12

Also, you provided a “generated_html_file”. This file does not have any extension. How did you produce it? Please provide simplified but complete source code here for testing. Also, please list complete steps here for our reference which will be helpful in reproducing the same issue on our end. Thanks for your cooperation.


#5

Please see those attachments now


#6

@khushboomehta,

When using the latest version of Aspose.Words for Java i.e. 18.12, there is no problem when running the following code on our end:

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

HtmlSaveOptions options = new HtmlSaveOptions();
options.setSaveFormat( SaveFormat.HTML );
options.setExportRoundtripInformation( true );
options.setEncoding(Charset.forName( "UTF-8" ));
options.setExportPageSetup( true );
options.setExportHeadersFootersMode( ExportHeadersFootersMode.PER_SECTION );
options.setExportImagesAsBase64( true );
options.setExportFontsAsBase64( true );

doc.save("E:\\Documents\\awjava-18.12.html", options);
doc.save("E:\\Documents\\awjava-18.12.pdf");

Output HTML and PDF files are attached: see awjava-18.12-outputs.zip (12.1 KB)