To convert documents to HTML with advanced options using GroupDocs.Conversion for Java, you can utilize the WebConvertOptions class. This class provides various properties to customize the HTML output according to your requirements:
Specifies the zoom level in percentage. Default: 100.
The following code snippet shows how to convert to HTML with advanced options:
importcom.groupdocs.conversion.Converter;importcom.groupdocs.conversion.options.convert.WebConvertOptions;importcom.groupdocs.conversion.options.load.WordProcessingLoadOptions;publicclassConvertToHtmlWithAdvancedOptions{publicstaticvoidconvert(){// Instantiate the WordProcessingLoadOptions
WordProcessingLoadOptionsloadOptions=newWordProcessingLoadOptions();loadOptions.setPassword("12345");// Initialize the converter with the source document
try(Converterconverter=newConverter("password_protected.docx",()->loadOptions)){// Instantiate the WebConvertOptions
WebConvertOptionsoptions=newWebConvertOptions();options.setUsePdf(true);// Convert via PDF to maintain layout
options.setFixedLayout(true);// Use fixed layout
options.setFixedLayoutShowBorders(true);// Show borders in fixed layout
options.setZoom(100);// Set zoom level to 100%
// Convert to HTML with the specified options
converter.convert("converted_with_options.html",options);}}publicstaticvoidmain(String[]args){convert();}}
password_protected.docx is sample file used in this example. Click here to download it.
converted_with_options.html is converted HTML document. Click here to download it.
In this example, the Converter class is initialized with the source document. The WebConvertOptions are then configured to convert the document via PDF, use a fixed layout with borders, and set the zoom level to 100%. Finally, the convert method is called to perform the conversion with the specified options.
By utilizing these options, you can effectively control the HTML conversion process to meet your specific needs.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.