usmanazizgroupdocs
11/9/2016 - 2:34 PM

RenderDocumentAsHtmlWithWatermark.vb

' For complete examples and data files, please go to https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-.NET
' get Configurations
Dim config As ViewerConfig = Utilities.GetConfigurations()

' create html handler
Dim htmlHandler As New ViewerHtmlHandler(config)

' guid implies that unique document name 
Dim guid As String = DocumentName

' instantiate the HtmlOptions object 
Dim options As New HtmlOptions()

options.IsResourcesEmbedded = False

' set password if document is password protected. 
If Not [String].IsNullOrEmpty(DocumentPassword) Then
	options.Password = DocumentPassword
End If

' add watermark
Dim watermark As New Watermark("This is watermark text")
watermark.Color = Color.Red
watermark.Position = WatermarkPosition.Diagonal
watermark.Width = 100
watermark.FontName = """Comic Sans MS"", cursive, sans-serif"

options.Watermark = watermark

' get document pages in html form
Dim pages As List(Of PageHtml) = htmlHandler.GetPages(guid, options)

For Each page As PageHtml In pages
	' save each page at disk
	Utilities.SaveAsHtml(page.PageNumber + "_" + DocumentName, page.HtmlContent)
Next