I use the Winnovative.WnvHtmlConvert;
You can find it and download the wnvhtmlconvert.dll.
Make reference to the dll.
It is not free but it has demo version with a license. Get it from the site:
http://www.winnovative-software.com/[
^]
Use the following function:
private void ConvertURLToPDF()
{
PdfConverter pdfConverter = new PdfConverter();
pdfConverter.LicenseKey = "you license here";
pdfConverter.PdfDocumentOptions.PdfPageSize = PdfPageSize.A4;
pdfConverter.PdfDocumentOptions.PdfCompressionLevel = PdfCompressionLevel.Normal;
pdfConverter.PdfDocumentOptions.PdfPageOrientation = PDFPageOrientation.Portrait;
pdfConverter.PdfDocumentOptions.ShowHeader = false;
pdfConverter.PdfDocumentOptions.ShowFooter = false;
pdfConverter.PdfDocumentOptions.GenerateSelectablePdf = true;
pdfConverter.PdfDocumentOptions.FitWidth = true;
pdfConverter.PdfDocumentOptions.EmbedFonts = false;
pdfConverter.PdfDocumentOptions.LiveUrlsEnabled = true;
if (true)
{
pdfConverter.ScriptsEnabled = false;
pdfConverter.ActiveXEnabled = false;
}
else
{
pdfConverter.ScriptsEnabledInImage = true;
pdfConverter.ActiveXEnabledInImage = true;
}
pdfConverter.PdfDocumentOptions.JpegCompressionEnabled = true;
if (false)
{
pdfConverter.PdfBookmarkOptions.TagNames = new string[] { "H1", "H2" };
}
byte[] pdfBytes = pdfConverter.GetPdfBytesFromUrl(urlToConvert);
System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
response.Clear();
response.AddHeader("Content-Type", "binary/octet-stream");
response.AddHeader("Content-Disposition",
"attachment; filename=ConversionResult.pdf; size=" + pdfBytes.Length.ToString());
response.Flush();
response.BinaryWrite(pdfBytes);
response.Flush();
response.End();
}
Good luck.