我有一个应该生成pdf的网站。 图像的URL由Web服务提供。 网址包含https,不上传我的pdf。
我该如何解决这个问题?
iTextSharp.text.Document doc = new iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 0, 0, 0, 0);
var html = string.Format(@"{0}", htmlToConvert);
StringReader strReader = new StringReader(html);
System.IO.MemoryStream m = new System.IO.MemoryStream();
var pdfWriter = PdfWriter.GetInstance(doc, m);
doc.Open();
iTextSharp.tool.xml.XMLWorkerHelper.GetInstance().ParseXHtml(pdfWriter, doc, strReader);
doc.Close();
pdfWriter.Flush();
pdfWriter.Close();
HttpResponseBase response = context.HttpContext.Response;
response.Clear();
// add the Content-Type and Content-Disposition HTTP headers
response.AddHeader("Content-Type", "application/pdf");
response.AddHeader("Content-Disposition", String.Format("attachment; filename=file.pdf; size={0}", m.GetBuffer().Length.ToString()));
response.OutputStream.Write(m.GetBuffer(), 0, m.GetBuffer().Length);
response.OutputStream.Flush();
response.OutputStream.Close();
response.End();