一个支持将Html页面转为PDF的.Net开源项目
当前位置:点晴教程→知识管理交流
→『 技术文档交流 』
推荐一个可以将Html页面转为PDF的开源项目。
这是一个基于.Net开发的开源项目,本质是用 Webkit 引擎将 HTML 页面转换为 PDF,可以用在控制台、 Web 应用程序和 Web API中。
1、创建转化器
var doc = new HtmlToPdfDocument() { GlobalSettings = { ColorMode = ColorMode.Color, Orientation = Orientation.Landscape, PaperSize = PaperKind.A4Plus, }, Objects = { new ObjectSettings() { PagesCount = true, HtmlContent = @"<h1>标题1</h1> 内容内容内容内容内容内容内容内容内容内容", WebSettings = { DefaultEncoding = "utf-8" }, HeaderSettings = { FontSize = 9, Right = "Page [page] of [toPage]", Line = true, Spacing = 2.812} } } }
![]() 该文章在 2024/1/23 12:33:46 编辑过 |