// <summary>
/// Convert the HTML code from the specified URL to a PDF document
and send the document to the browser
/// </summary>
private void ConvertURLToPDF()
{
string urlToConvert = [Link]();
// Create the PDF converter. Optionally the HTML viewer width can
be specified as parameter
// The default HTML viewer width is 1024 pixels.
PdfConverter pdfConverter = new PdfConverter();
// set the license key - required
[Link] = "ORIJGQoKGQkZCxcJGQoIFwgLFwAAAAA=";
// set the converter options - optional
[Link] = PdfPageSize.A4;
[Link] = PdfCompressionLeve
[Link];
[Link] = PdfPageOrientation.
Portrait;
// set if header and footer are shown in the PDF - optional - default
is false
[Link] = [Link];
[Link] = [Link];
// set if the HTML content is resized if necessary to fit the PDF
page width - default is true
[Link] = [Link];
// set the embedded fonts option - optional - default is false
[Link] = [Link];
// set the live HTTP links option - optional - default is true
[Link] = [Link];
// set if the JavaScript is enabled during conversion to a PDF - default
is true
[Link] = [Link];
// set if the images in PDF are compressed with JPEG to reduce the
PDF document size - default is true
[Link] = cbJpegCompressi
[Link];
// enable auto-generated bookmarks for a specified list of HTML selector
s
(e.g. H1 and H2)
if ([Link])
{
[Link] = new string[]
{ "H1", "H2" };
}
// add HTML header
if ([Link])
AddHeader(pdfConverter);
// add HTML footer
if ([Link])
AddFooter(pdfConverter);
// Performs the conversion and get the pdf document bytes that can
// be saved to a file or sent as a browser response
byte[] pdfBytes = [Link](urlToConvert);
// send the PDF document as a response to the browser for download
[Link] response = [Link]
se;
[Link]();
[Link]("Content-Type", "application/pdf");
if ([Link])
[Link]("Content-Disposition", [Link]("attachment;
filename=[Link]; size={0}",
[Link]()));
else
[Link]("Content-Disposition", [Link]("inline; fil
ename=[Link]; size={0}",
[Link]()));
[Link](pdfBytes);
// Note: it is important to end the response, otherwise the [Link]
// web page will render its content to PDF document stream
[Link]();
}