我正在尝试从一些输入数据生成 pdf。所以我创建了我的 PdfGenerator() 并创建了一个带有一些文本的 pdf:
public class PdfGenerator {
public PdfGenerator() {
//Instantiate License class and call its SetLicense method to use the license
var license = new Aspose.Pdf.License();
license.SetLicense("Aspose.Total.lic");
}
public void Generate(Generation input) {
//Create pdf document
var pdf1 = new Pdf();
//Add a section into the pdf document
var sec1 = pdf1.Sections.Add();
//Add a text paragraph into the section
sec1.Paragraphs.Add(new Text("Hello World"));
//Save the document
pdf1.Save(input.Reference + ".pdf", SaveType.OpenInBrowser, HttpContext.Current.Response);
}
}
这是从我的 HttpPost 方法调用的:
// POST api/values
[System.Web.Http.HttpPost]
public void Post([FromBody]Generation value) {
_pdfGenerator.Generate(value);
}
但我只得到一个白页pdf,知道为什么我做错了吗?