我的要求是将 Html 转换为 pdf 转换器,我通过代码做到了这一点。但现在我的要求是如何保存到文件夹中。
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition",
"attachment;filename=Certificate.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
System.Text.StringBuilder ss = new System.Text.StringBuilder(CertificateHtml);
StringWriter sw = new StringWriter(ss);
HtmlTextWriter hw = new HtmlTextWriter(sw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A2, 7f, 7f, 7f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();
请帮忙。