Skip to end of metadata
Go to start of metadata
Contents Summary
  

The recipe and code use some of the objects defined in Working with Common Operations

Rendering Document as Printable HTML

GroupDocs.Viewer also provides the feature to get printable HTML of the documents for print. Following steps are to be followed to achieve this functionality. 

  • Create and populate the object of ViewerConfig
  • Instantiate the object of ViewerHtmlHandler by passing the ViewerConfig object into its constructor
  • Create PrintableHtmlOptions object
  • Call GetPrintableHtml method using ViewerHtmlHandler object by passing document GUID and object of PrintableHtmlOptions class

The following code sample shows how to get the printable HTML of a document.

Getting Printable HTML with Custom CSS

When rendering the document to HTML, you can also define custom CSS to be applied in generated HTML pages. Follow below steps to apply custom CSS to HTML pages. 

  • Create and populate the object of ViewerConfig
  • Instantiate the object of ViewerHtmlHandler by passing the ViewerConfig object into its constructor
  • Write a custom CSS in a string object
  • Create PrintableHtmlOptions object
  • Assign the CSS object value to PrintableHtmlOptions.Css property
  • Call GetPrintableHtml of ViewerHtmlHandler class by passing GUID and the object of PrintableHtmlOptions class

The following code sample shows how to set the custom CSS.

 

Getting Printable HTML with Watermark

Following are the steps to get printable HTML with the watermark. 

  • Create and populate the object of ViewerConfig
  • Instantiate the object of ViewerHtmlHandler by passing the ViewerConfig object into its constructor
  • Create Watermark object and set its properties
  • Assign the Watermark object to PrintableHtmlOptions.Watermark property
  • Call GetPrintableHtml method of ViewerHtmlHandler class by passing document GUID and object of PrintableHtmlOptions class

The following code sample shows how to set the watermark for printable HTML.

 
Labels
  • No labels