我正在使用 ABCpdf 第 5 版将一些 html 页面呈现为 PDF。
我基本上使用HttpServerUtility.Execute()
- 方法来检索 pdf 的 html:
System.IO.StringWriter writer = new System.IO.StringWriter();
server.Execute(requestUrl, writer);
string pageResult = writer.ToString();
WebSupergoo.ABCpdf5.Doc pdfDoc = new WebSupergoo.ABCpdf5.Doc();
pdfDoc.AddImageHtml(pageResult);
response.Buffer = false;
response.ContentType = "application/pdf";
response.AddHeader("Content-Disposition", "attachment;filename=MyPdf_" +
FormatDate(DateTime.Now, "yyyy-MM-dd") + ".pdf");
response.BinaryWrite(pdfDoc.GetData());
现在一些特殊字符,如元音变音 (äöü) 被替换为空格。有趣的是,并非所有人。我发现了什么:在我拥有的 html 页面中。
`<meta http-equiv="content-type" content="text/xhtml; charset=utf-8" />`
如果我将其解析,所有特殊字符都会正确呈现。但这在我看来就像一个丑陋的黑客。
早些时候我没有使用HttpServerUtility.Execute()
,但我让 ABCpdf 调用 URL 本身:pdfDoc.AddImageUrl("someUrl");
. 我没有这样的编码问题。
我还能尝试什么?