ner7下的html导出为pdf
ner7下的html导出为pdf
nuget引入dinktopdf,按github上的示例来弄即可:https://github.com/rdvojmoc/DinkToPdf/
mac下vs2022,net7测试,需要把https://github.com/rdvojmoc/DinkToPdf/blob/master/v0.12.4/64%20bit/下的几个文件都下载下来复制到bin/debug/net7.0目录下
[HttpPost]
public IActionResult Test(string t) {
var converter = new BasicConverter(new PdfTools());
var doc = new HtmlToPdfDocument()
{
GlobalSettings = {
ColorMode = ColorMode.Color,
Orientation = Orientation.Landscape,
PaperSize = PaperKind.A4Plus,
},
Objects = {
new ObjectSettings() {
PagesCount = true,
HtmlContent = @"<h1>ddddhello niukwg kwg 哈哈</h1",
WebSettings = { DefaultEncoding = "utf-8" },
HeaderSettings = { FontSize = 9, Right = "Page [page] of [toPage]", Line = true, Spacing = 2.812 }
}
}
};
byte[] pdf = converter.Convert(doc);
return File(pdf, "application/pdf","aaa.pdf");
}
撸码:复制、粘贴,拿起键盘就是“干”!!!

浙公网安备 33010602011771号