EVO HTML to PDF Converter allows you to add watermarks and stamps to generated PDF document. The watermarks and stamps are implemented using EvoPdf.HtmlToPdfClientTemplate objects which are repeated in each page of the generated PDF document. In a template you can add any PDF element that you can normally add in a PDF page, including HtmlToPdfElement objects or HtmlToPdfVariableElement.
Code Sample - Add Watermarks and Stamps to Generated PDF Document
C#
protected void convertToPdf() { // Get the server IP and port String serverIP = textBoxServerIP.Text; uint serverPort = uint.Parse(textBoxServerPort.Text); // Create a HTML to PDF converter object HtmlToPdfConverter htmlToPdfConverter = null; if (radioButtonUseTcpService.Checked) htmlToPdfConverter = new HtmlToPdfConverter(serverIP, serverPort); else htmlToPdfConverter = new HtmlToPdfConverter(true, textBoxWebServiceUrl.Text); // Set optional service password if (textBoxServicePassword.Text.Length > 0) htmlToPdfConverter.ServicePassword = textBoxServicePassword.Text; // Set license key received after purchase to use the converter in licensed mode // Leave it not set to use the converter in demo mode htmlToPdfConverter.LicenseKey = "4W9+bn19bn5ue2B+bn1/YH98YHd3d3c="; // Set an adddional delay in seconds to wait for JavaScript or AJAX calls after page load completed // Set this property to 0 if you don't need to wait for such asynchcronous operations to finish htmlToPdfConverter.ConversionDelay = 2; // Convert a HTML page to a PDF document object Document pdfDocument = htmlToPdfConverter.ConvertUrlToPdfDocumentObject(urlTextBox.Text); // Get the stamp width and height float stampWidth = float.Parse(stampWidthTextBox.Text); float stampHeight = float.Parse(stampHeightTextBox.Text); // Center the stamp at the top of PDF page float stampXLocation = (pdfDocument.GetPage(0).PageSize.Width - stampWidth) / 2; float stampYLocation = 0; // Create the stamp template to be repeated in each PDF page Template stampTemplate = pdfDocument.AddTemplate(stampXLocation, stampYLocation, stampWidth, stampHeight); // Create the HTML element to add in stamp template HtmlToPdfElement stampHtmlElement = new HtmlToPdfElement(htmlStringTextBox.Text, baseUrlTextBox.Text); // Set the HTML viewer width for the HTML added in stamp stampHtmlElement.HtmlViewerWidth = 600; // Fit the HTML content in stamp template stampHtmlElement.FitWidth = true; stampHtmlElement.FitHeight = true; // Add HTML to stamp template stampTemplate.AddElement(stampHtmlElement); // Save the PDF document in a memory buffer byte[] outPdfBuffer = pdfDocument.Save(); }