2016-11-24 27 views
1

我目前正在使用Azure服務結構(將替換網絡和輔助角色的新產品的種類)託管打印服務。我使用wkhtmltopdf和NReco.PDFGenerator.LT作爲它的包裝,它在本地開發集羣中工作正常,但在聯機時失敗。NReco PDFGenerator在Azure服務結構上失敗

我得到的唯一例外是Exception thrown: 'System.Exception' in NReco.PdfGenerator.LT.dll,我覺得它很難調試,因爲它沒有告訴什麼是失敗。

閱讀this我在想,也許有些東西不見了集羣上,但當地環境suposed是一個在線的翻版。而且我是用在同一個集羣NReco包裝phantomjs切換到前wkhtmltopdf,它在線和本地工作,我相信他們都使用相同的核心引擎(雖然不同的叉)?

這是我的代碼,而在遠程調試中,我檢查了許可證,.exe路徑和文件的值是否正確。

[HttpGet] 
    public ActionResult Get(string target) 
    { 
     var wktohtmlPath = Path.Combine(_hostingEnvironment.WebRootPath, "lib"); 
     var htmlToPdf = new HtmlToPdfConverter() { 
      Quiet = false, 
      CustomWkHtmlArgs = "--print-media-type", 
      PdfToolPath = wktohtmlPath, 
      Margins = new PageMargins() { Left = 17, Right = 17, Top = 17, Bottom = 17 } 
     }; 
     htmlToPdf.License.SetLicenseKey(
      _optionsAccessor.Value.LicenceOwner, 
      _optionsAccessor.Value.LicenceKey 
     ); 

     try 
     { 
      var fileBytes = htmlToPdf.GeneratePdfFromFile(target, null); 
      var fileStream = new MemoryStream(fileBytes); 
      return new FileStreamResult(fileStream, "application/pdf"); 
     } 
     catch 
     { 
      return BadRequest(); 
     } 
    } 

謝謝您的回答

回答

1

對於記錄:有兩個問題

  • 缺少C++在線羣集上運行時庫(msvcp120.dll & msvcr120.dll)(謝謝NReco爲了這);
  • 看來,服務結構只能運行x86版本,而我正在使用x64版本。