Converting word documents to HTML

We are using aspose to convert word documents to HTML in java.It is working fine.
but we have very large documents, so we wanted to give the first ‘n’ pages of preview to the user.
Example: If we have document with 100 pages and we want to give preview of this document with the first 3 pages.
How can I do this using aspose in java.

Thanks for the help.

Hi Ruby,

Thanks for your inquiry. In your case, I suggest you please use the methods of HtmlFixedSaveOptions class (setPageIndex and setPageCount) to achieve your requirements. Hope this helps you. Please let us know if you have any more queries.

Document doc = new Document(MyDir + "in.docx");
HtmlFixedSaveOptions options = new HtmlFixedSaveOptions();
options.setPageIndex(0);
options.setPageCount(3);
doc.save(MyDir + "out.html", options);

Hi Tahir,
Thanks for your quick response and great help.
Sorry to asking you this, I couldn’t find HtmlFixedSaveOptions class in com.aspose.words package :frowning: Where can I get that class?
Presently we are using com.aspose.words.HtmlSaveOptions class.

Hi Ruby,

Thanks for your inquiry. I would suggest you please upgrade to the latest version (v13.3.0) from here:
https://releases.aspose.com/words/java

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

Hi Tahir,

Thanks for your help
It’s working but it is creating a html file with folder contains references for the the pages which are get created in html file. We want it to be a single file and for the format
we used

htmlOptions.setExportHeadersFootersMode(ExportHeadersFootersMode.NONE);
htmlOptions.setTableWidthOutputMode(HtmlElementSizeOutputMode.NONE);
htmlOptions.setExportXhtmlTransitional(true)
htmlOptions.setExportImagesAsBase64(true);

these options but I didn’t find any similar options with the HtmlFixedSaveOptions class.

Is that possible with HtmlFixedSaveOptions class?

Hi Ruby,

Thanks for your inquiry. The HtmlFixedSaveOptions class does not contain the requested methods. However, you may remove header/footer from Aspose.Words.Document and save document into html.

Pelase use HtmlFixedSaveOptions.setExportEmbeddedImages method to specify whether images should be embedded into Html document in Base64 format or not.

ruby123:
but we have very large documents, so we wanted to give the first ‘n’ pages of preview to the user.

You may convert your document to SWF or images to preview your document. Please read following documentation links for your knid reference.
https://reference.aspose.com/words/java/com.aspose.words/FixedPageSaveOptions
https://reference.aspose.com/words/java/com.aspose.words/imagesaveoptions

Hope this answers your query. Please let us know if you have any more queries.

Hi Ruby,

Further to my last post, The ExportHeadersFootersMode and ExportXhtmlTransitional properties are not available in HtmlFixedSaveOptions. I have logged this feature request as WORDSNET-8138 and WORDSNET-8139 in our issue tracking system. You will be notified via this forum thread once this feature is available. The TableWidthOutputMode doesn’t have a place in a fixed layout as the width will always be the same.

We apologize for your inconvenience.

Hi Ruby,

Thanks for your patience. It is to update you that our development team has completed the
analysis of WORDSNET-8139 (Add property ExportXhtmlTransitional in HtmlFixedSaveOptions) and has come to a conclusion that they won’t be
able to implement the fix to your issue. Most likely, your issue will be
closed with ‘‘Won’t Fix’’ resolution. I am quoting developer’s comments here for your reference.

In fixed html we use html5 doctype declaration: . All other doctype declarations are deprecated in html5.