我有一个 HTML 表单,它接受用户的数据。用户可以是世界各地的任何人,因此需要 UTF-8 支持,以便用户可以使用任何语言输入数据 - 阿拉伯语、中文、日语等。
目前正在用中文输入数据,将数据导出为PDF时,不显示中文。但是,如果是英文,PDF 会正确显示。
我正在使用 SautinSoft.PdfMetamorphosis,它是生成 PDF 输出的第三部分工具。
SautinSoft.PdfMetamorphosis oPdf = new SautinSoft.PdfMetamorphosis();
oPdf.PageStyle.PageSize.A4();
oPdf.PdfOptions.PdfVersion = SautinSoft.PdfMetamorphosis.CPdfOptions.ePdfVersion.PDF_A;
//oPdf.UnicodeOptions.DetectFontsDirectory = SautinSoft.PdfMetamorphosis.CUnicodeOptions.eUnicodeDetectFontsDirectory.Custom;
oPdf.TextStyle.FontFace.Custom("Arial Unicode MS");
//oPdf.TextStyle.FontSize = 20;
byte[] bBytes = oPdf.HtmlToPdfConvertStringToByte(OutputAsTable(fUserAdmin, pTranslation, pReplace, pCustom));
oPdf = null;
if (pCustom)
{
var oCustom = new Custom();
oCustom.DropTable("VW_TR_TBL_Custom_" + fCompanyID + "_" + fEmployeeID);
}
var Response = HttpContext.Current.Response;
Response.Clear();
Response.ClearHeaders();
Response.ClearContent();
//Response.ContentType = "application/pdf";
Response.ContentType = "text/html";
Response.AddHeader("content-disposition", "attachment;filename=" + fFormName + ".pdf");
//Response.Charset = "utf-8";
//Response.ContentEncoding = Encoding.UTF8;
Response.BinaryWrite(bBytes);
Response.Flush();
Response.End();
上面的注释行我也尝试过,但根本不起作用。
所以,代码一切都很好。
据我发现,阿拉伯语运行良好,但中文、日语、韩语不支持,这是由于 PDF Metamorphosis 版本所致。
需要升级版本,成功了。
谢谢大家。