2016-06-07 49 views
0

我試圖從某些輸入數據生成pdf。 所以我創造了我的pdfGenerator(),並創建了一些文本的PDF:Aspose.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,任何想法爲什麼我做錯了?

回答

0

的問題是不是Net代碼,這是我的客戶,我需要添加:

{responseType:'arraybuffer'} 

我的http請求(JavaScript)的