How to optimize output HTML for printing

If you need to optimize HTML output for printing you should use setForPrinting(…) option of HtmlViewOptions. This option implemented for:

  • Presentation documents: PPT, PPS, PPTX, PPSX, ODP, FODP, OTP, POT, POTX, POTM, PPTM, PPSM
  • Diagram documents: VSD, VSDX, VSS, VST, VSX, VTX, VDW, VDX, VSSX, VSTX, VSDM, VSSM, VSTM
  • Meta file formats: WMF, WMZ, EMF, EMZ
    try (Viewer viewer = new Viewer("some-document.doc")) {
        HtmlViewOptions options = HtmlViewOptions.forEmbeddedResources("result.html");
        //HtmlViewOptions options = HtmlViewOptions.forExternalResources("p_{0}.html", "p_{0}_{1}", "p_{0}_{1}");

        options.setForPrinting(true);

        viewer.view(options);
    }

If ForPrinting option is enabled output HTML pages will be converted to vector SVG format for better quality for print and page layout.

More resources

GitHub Examples

You may easily run the code above and see the feature in action in our GitHub examples:

Free Online App

Along with full-featured Java library we provide simple but powerful free Apps. You are welcome to view Word, PDF, Excel, PowerPoint documents with free to use online GroupDocs Viewer App.