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

Free Support Forum - groupdocs.com

Compile all rendered pages into one html in Java

Hello,

May I know is there a way to compile the rendered pages of a file into one html?

Thank you

@danishPersys

Yes, for some file formats such as Microsoft Word (DOCX, DOC, etc.), Archives (ZIP, RAR, etc.), and Text files rendering to one HMTL file is already supported and can be enabled with HtmlViewOptions.setRenderToSinglePage(true).

HtmlViewOptions viewOptions = HtmlViewOptions.forEmbeddedResources();
viewOptions.setRenderToSinglePage(true);
Viewer viewer = new Viewer("sample.docx");
viewer.view(viewOptions);
viewer.close();

It will be a single HTML file on the output with all document pages.

1 Like

Awesome, thank you !

@danishPersys

You’re welcome!

Hello, I am using Java API. May I know how to change the output name from library because the default is p_1.html. I want to change it to a string that I declared.

@danishPersys

You can change output name by passing filename template string to the options factory method e.g.

HtmlViewOptions viewOptions = HtmlViewOptions.forEmbeddedResources("my-page-name-template-{0}.html");

the {0} placeholder is going to be replaced with page number.

Works great .Thank you!

@danishPersys

You’re welcome!