我正在尝试从html生成pdf。我正在使用Github Issue。 尝试生成pdf时,出现以下错误:
DllNotFoundException:无法加载DLL'libgdiplus':指定 找不到模块。
我的主要向导是SelectPdf for .Net
This Documentation on their official website SettingsController.cs
[Route ("settings/aaa")]
public IActionResult GeneratePdf () {
return View ();
}
[HttpPost]
[Route ("settings/aaa")]
public IActionResult GeneratePdf (IFormCollection collection) {
// read parameters from the webpage
string htmlString = collection["TxtHtmlCode"];
string baseUrl = collection["TxtBaseUrl"];
int webPageWidth = 1024;
int webPageHeight = 1280;
// instantiate a html to pdf converter object
HtmlToPdf converter = new HtmlToPdf ();
converter.Options.PdfPageOrientation = PdfPageOrientation.Portrait;;
converter.Options.WebPageWidth = webPageWidth;
converter.Options.WebPageHeight = webPageHeight;
// create a new pdf document converting an url
PdfDocument doc = converter.ConvertHtmlString (htmlString, baseUrl);
// save pdf document
byte[] pdf = doc.Save ();
// close pdf document
doc.Close ();
// return resulted pdf document
FileResult fileResult = new FileContentResult (pdf, "application/pdf");
fileResult.FileDownloadName = "Document.pdf";
return fileResult;
}
GeneratePdf.cshtml
<div>
<form method="post" asp-controller="Settings" asp-action="GeneratePdf">
<input value="stuff" name="TxtHtmlCode"/>
<input value="" name="TxtBaseUrl"/>
<input type="submit" value="submit">
</form>
</div>
我的目标是使SelectPdf从“ TxtHtmlCode”输入生成pdf。