0

我正在尝试从一些输入数据生成 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,知道为什么我做错了吗?

4

1 回答 1

0

问题不是 .Net 代码,而是在我的客户端上,我需要添加:

{responseType:'arraybuffer'}

在我的 http 请求上(javascript)

于 2016-06-07T12:48:05.827 回答