using SelectPdf; /// <summary> /// 网页生成PDF /// </summary> /// <param name="dirPath">保存路径</param> private string CreatePdfByUrl(string dirPath) { var url = Request.Url.Scheme + "://" + Request.Url.Authority; url += "/Study/PrintWebPages/PrintPublic?Id=" + 1; string pageUrl = (new Uri(Request.Url, url)).AbsoluteUri; SelectPdf.HtmlToPdf converter = new SelectPdf.HtmlToPdf(); SelectPdf.PdfDocument doc = converter.ConvertUrl(pageUrl); string fileName = @dirPath+"HtmlToPdf.pdf" ; doc.Save(@fileName); doc.Close(); return fileName; }