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目录下

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
[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");
}

  

 

 

posted @   牛腩  阅读(44)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
点击右上角即可分享
微信分享提示