0
這是我爲hiqpdf下載的C#,但我不確定如何修改它,以便它能夠與我的html一起工作?我的asp.net c#工作表textBoxUrl出現錯誤,但我不知道我應該使用什麼名稱空間來抓住這個或我是否需要替換這個文本?hiqpdf - asp.net - 如何修改代碼以捕獲div
C#代碼:
using HiQPdf;
protected void Print_Button_Click(object sender, EventArgs e)
{
// create the HTML to PDF converter
HtmlToPdf htmlToPdfConverter = new HtmlToPdf();
// select the HTML element to be converted to PDF
htmlToPdfConverter.ConvertedHtmlElementSelector =
textBoxConvertedHtmlElementSelector.Text;
// convert URL to a PDF memory buffer
string url = textBoxUrl.Text;
byte[] pdfBuffer = htmlToPdfConverter.ConvertUrlToMemory(url);
// inform the browser about the binary data format
HttpContext.Current.Response.AddHeader("Content-Type",application/pdf");
// let the browser know how to open the PDF document
HttpContext.Current.Response.AddHeader("Content-Disposition",
String.Format("attachment; filename=ConvertHtmlPart.pdf;
size ={ 0}
",
pdfBuffer.Length.ToString()));
// write the PDF buffer to HTTP response
HttpContext.Current.Response.BinaryWrite(pdfBuffer);
// call End() method of HTTP response
// to stop ASP.NET page processing
HttpContext.Current.Response.End();
}