GroupDocsGists
10/19/2017 - 11:24 AM

GetDocumentHtmlForPrintWithCustomCss.java

// For complete examples and data files, please go to https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-Java
try {
	// Setup GroupDocs.Viewer config
	ViewerConfig config = Utilities.getConfiguration();

	// Create image handler
	ViewerImageHandler imageHandler = new ViewerImageHandler(config);
	String guid = fileName;

	// Get document html for print with custom css
	String css = "a { color: hotpink; }"; // Some style
	PrintableHtmlOptions options = new PrintableHtmlOptions(guid, css);
	PrintableHtmlContainer container = imageHandler.getPrintableHtml(options);

	// Save as html
	Utilities.saveAsHtml(fileName, container.getHtmlContent());
} catch (Exception exp) {
	System.out.println("Exception: " + exp.getMessage());
	exp.printStackTrace();
}