Aspose.PDF 18.11 最新版 绝对可用! 仅用于学习研究. 不得用于商业用处
只需使用几行代码和资源加载回调就可以以非常基本的方式将HTML转换为PDF,以下是使您达到目的的代码段:
1
2
3
4
5
6
7
8
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdf_DocumentConversion();
HtmlLoadOptions options = new HtmlLoadOptions();
options.CustomLoaderOfExternalResources = new LoadOptions.ResourceLoadingStrategy(SamePictureLoader);
Document pdfDocument = new Document(dataDir + "HTMLToPDF.html", options);
pdfDocument.Save("HTMLToPDF_out.pdf");.