Click or drag to resize
Pdf Library for .NET

Partial Page Conversion with Html to Pdf Converter

Select.Pdf Html to Pdf Converter for .NET can be used to convert only a specific section of a web page to pdf.

The section that will be converted to pdf is specified by the html element ID. The element can be anything (image, table, table row, div, text, etc). To set the element id in Select.Pdf Library, the VisibleWebElementId property of the HtmlToPdfOptions object must be used.

Note  Note

For HTML to PDF conversion, partial web page rendering is supported only by the WebKit and WebKit Restricted rendering engines. It is not currently applied when rendering HTML to PDF with the Blink or Chromium engines. For HTML to image conversion, the equivalent VisibleWebElementId property on HtmlToImage is supported by all four rendering engines.

Sample Code

This sample code shows how the html to pdf converter can be used to convert only a section of a web page using Select.Pdf Pdf Library for .NET.

// instantiate a html to pdf converter object
HtmlToPdf converter = new HtmlToPdf();

// specify the id of the section that will be converted to pdf
converter.Options.VisibleWebElementId = elementId;

// create a new pdf document converting an url
PdfDocument doc = converter.ConvertUrl(url);

// save pdf document
doc.Save(Response, false, "Sample.pdf");

// close pdf document
doc.Close();
See Also