2016-03-03 23 views
0

這裏的渲染過的版本是關於我的開發環境的信息:SelectPdf無法正確生成PDF需要像我們的ASPX頁面

- 微軟的Visual Studio專業2013

-.NET框架4.0

-jquery.min.js(1.11.3)

  • 的jquery-ui.min.js(1.11.2)

-Select.HtmlToPdf(2.0.1.0)

-jQuery數據表(1.10.7)

在我們的申請中,我們有動態填充jquery的數據表,並且使用動態生成的圖表的ASPX頁jquery在運行時。

我們希望使用Select.HtmlToPdf(2.0.1.0)來創建PDF文件,當它在Web瀏覽器中呈現時,它將看起來像上述的ASPX頁面。

在我們的ASPX頁面,我們有一個下載PDF ASPX服務器端的按鈕時,調用ASPX代碼中定義隱藏文件下面的C#方法:

 public void generatePDF() 
     { 


      // instantiate a html to pdf converter object 
      HtmlToPdf converter = new HtmlToPdf(); 

         var url = 
    HttpContext.Current.Server.MapPath("~/hos/pdf/displayTemplate.html"); 
     Console.WriteLine(url.ToString()); 

     SelectPdf.GlobalProperties.HtmlEngineFullPath = 
HttpContext.Current.Server.MapPath("~/hos/pdf/SelectPdfAuxiliaries/Select.Html.dep"); 

     PdfDocument doc = converter.ConvertUrl(url.ToString()); 

     // save pdf document 
     doc.Save(Response, false, "displayContent.pdf"); 

     } 

的displayTemplate.html包含AJAX的jQuery函數將調用一個ASHX處理程序:

function GetHandlerTestJS() { 
     var testHandlerData = new FormData(); 
     testHandlerData.append("handlerTestId", "1"); 
     $.ajax({ 
      type: "Post", 
      contentType: "application/json; charset=utf-8", 
      url: "testHandler.ashx", 
      enctype: 'multipart/form-data', 
      contentType: false, 
      processData: false, 
      data: testHandlerData, 
      dataType: "json", 

      success: function (data) { 
       $('#handlertestDebug').html(data); 
       //getSignatureImage(); 
      }, 
      error: function (Result) { 
       $('#handlertestDebug').html("error in handler test"); $('#handlertestResultDebug').html(Result); 
      } 
      //beforeSend: function() { $('#loader').show() }, //complete: function() { $('#loader').hide(); } 
     }); 
    } 

    $(function() { 
     $(document).ready(function() { 
      console.log("Inside Start"); 
      GetHandlerTestJS(); 
     }); 
    }); 

的問題是,有故障使用Select.HtmlToPdf(2.0.1.0)的調用的API方法ConvertUrl何時調用ASHX處理程序:

PdfDocument doc = converter.ConvertUrl(url.ToString()); 

有人可以告訴我需要對上述代碼做出什麼樣的修改,以便使用Select.HtmlToPdf(2.0.1.0)的API從html調用處理程序嗎?

回答

1

您是否嘗試過使用testHandler.ashx的完整絕對路徑?