2017-11-27 21 views
1

나는 흥미로운 문제에 직면 해있다. Syncfusion Essential Studio + Web Kit를 사용하여 HTML을 PDF로 변환합니다. 때로는 잘 작동하지만 때로는 완전히 쓸모가 없습니다.Syncfusion HTML을 PDF로 변환

완전히 쓸모가 없다는 것을 의미합니까? HtmlToPdfConverter의 Convert 메서드를 호출 할 때마다 UnauthorizedException이 throw됩니다. 그러나 매번 발생하지는 않으며 무작위로 나타납니다.

 string htmlString = ""; 

     try 
     { // Open the text file using a stream reader. 
      using (StreamReader sr = new StreamReader("PdfTemplates\\template.html")) 
      { 
       // Read the stream to a string, and write the string to the console. 
       htmlString = sr.ReadToEnd(); 
      } 
     } 
     catch (Exception e) 
     { 
      _logger.Error(e,"read the template html"); 
      throw e; 
     } 

     StringBuilder sb = new StringBuilder(htmlString); 

     sb.Replace("%SOMETHING%", something); 
     htmlString = sb.ToString(); 

     _logger.Information("htmltemplate with new data created"); 

     PdfDocumentBase mergedPdf; 
     try 
     { 
      var pdfDocFromHtml = _htmlConverter.Convert(htmlString, ""); // THE Problematic line 
      var pdfLoadedDocument = new PdfLoadedDocument(uploadedPdfStream); 

      //template generation 
      _logger.Information("pdf created from html"); 

      //merge the generated pdf with the uploaded document 
      mergedPdf = MergePdf(pdfDocFromHtml, pdfLoadedDocument); 

      _logger.Information("pdf merged"); 

      var resultStream = PdfDocumentToStream(mergedPdf); 

      pdfDocFromHtml.Close(true); 
      pdfLoadedDocument.Close(true); 

        return resultStream; 
     } 
     catch (Exception ex) 
     { 
      Type typeOfE = ex.GetType(); 
      _logger.Error(ex, "pdfLoadedDocument from byteArray"); 
      throw; 
     } 

내가 팀에서 작업하고, 팀 동료 중 아무도 나를 단지 문제가 없습니다 : 다음은 내 코드입니다. 나는 Windows 10 Pro를 사용 중입니다. 우리는 ASP.NET MVC 애플리케이션을 개발 중입니다.

누군가가 문제가 될 수있는 아이디어가 있습니까?

답변

0

Windows 10 환경에서 MVC 응용 프로그램을 사용하여 HTML 문자열을 PDF로 변환하는 중에 권한없는 예외를 재현하려고 시도했지만 정상적으로 작동합니다. 이전에 비슷한 예외가 없었습니다. Syncfusion Direct-Trac 지원 시스템을 통해 새로운 세부 정보를 생성 할 수 있습니까?

  1. 문제를 재현하기위한 코드 또는 샘플.
  2. HTML 파일 또는 URL을 입력하십시오.
  3. 운영 체제 및 언어 사양에 대한 환경 세부 정보.

한편, 동일한 프로젝트를 사용하여 다른 URL (http://www.google.com)을 PDF로 변환 해보고 결과를 알려주십시오.

참고 : 내가 Syncfusion

내가 http://www.google.com을 변환하려고
+0

을 위해 일하지만,이 역시 실패했습니다. 나는 그 지원에 대해서도 연락 할 것이다. –