2015-01-21 2 views
2

나는 html 페이지를 pdf 형식으로 저장하려고 노력하고 있습니다. 나는 ephtmltopdf를 사용하고있다. 내 Pdf 파일을 저장하지만 테이블을 놓치고있다. 이제는이 문제를 해결하는 방법에 대한 많은 아이디어가 없습니다.ephtmltopdf를 사용하여 html로 PDF 변환

  string url = "http://localhost:50306/ColumnChart.aspx"; 
      string path = "d:\\"; 
      string downloadName = path + "/" + "Student" + "-Registration_Form.pdf"; 
      SizeF sf = new SizeF(); 
      sf.Height = (float)635;//635;900 
      sf.Width = (float)816;//8161000 

      PdfConverter pdfConverter = new PdfConverter(); 
      pdfConverter.PageWidth = 816; //8161000 
      pdfConverter.PdfDocumentOptions.TopMargin = 50; 
      pdfConverter.PdfDocumentOptions.BottomMargin = 105; 
      pdfConverter.PdfDocumentOptions.GenerateSelectablePdf = true; 
      pdfConverter.PdfDocumentOptions.PdfPageSize = PdfPageSize.Letter; 
      pdfConverter.PdfDocumentOptions.CustomPdfPageSize = sf;//new SizeF(595, 842); 
      pdfConverter.PdfDocumentOptions.PdfCompressionLevel = PdfCompressionLevel.Normal; 
      pdfConverter.PdfDocumentOptions.ShowHeader = false; 
      pdfConverter.PdfDocumentOptions.ShowFooter = false; 
      pdfConverter.PdfDocumentOptions.PdfPageOrientation = PDFPageOrientation.Portrait; 
      pdfConverter.PdfDocumentOptions.FitWidth = false; 
      pdfConverter.PdfDocumentOptions.EmbedFonts = true; 
      pdfConverter.PdfDocumentOptions.ShowFooter = false; 
      pdfConverter.PdfDocumentOptions.ShowHeader = false; 


      pdfConverter.SavePdfFromUrlToFile(url, downloadName); 

      Response.ContentType = "application/pdf"; 
      Response.AppendHeader("Content-Disposition", "attachment; filename=Student-Registration_Form.pdf"); 
      Response.TransmitFile("d:\\Student-Registration_Form.pdf"); 
      Response.End(); 

그리고 내 HTML 코드가 그대로 :

<table > 
     <tr> 
      <td style="vertical-align: text-top;"> 

       <table border="1" id="CompleteTimeline"> 
        <tr> 
         <th> 
          Complete<br />Timeline 
         </th> 
         <th> 
          Time 
         </th> 
        </tr> 
       </table> 
      </td> 
      <td style="vertical-align: text-top;"> 
       <table border="1" id="PlayBackTable"> 
        <tr> 
         <th> 
          Play<br />Back Id 
         </th> 
         <th> 
          Duration 
         </th> 
         <th> 
          Start Time 
         </th> 
         <th> 
          End Time 
         </th> 
        </tr> 
       </table> 
      </td> 
      <asp:Button ID="button" Text="click" runat="server" OnClick="b1_click" /> 
      <td style="vertical-align: text-top;"> 
       <table border="1" id="MissingStartEnd"> 
        <tr> 
         <th> 
          Missing<br />Start 
         </th> 
         <th> 
          Time 
         </th> 
         <th> 
          Missing<br />End 
         </th> 
         <th> 
          Time 
         </th> 
        </tr> 
       </table> 
      </td> 
      <td style="vertical-align: text-top;"> 
       <table border="1" id="UnmatchedRegions"> 
        <tr> 
         <th> 
          Unmatched<br />Time 
         </th> 
         <th> 
          Duration 
         </th> 
        </tr> 
       </table> 
      </td> 
     </tr> 
    </table> 

이 PLZ 나에게이 문제를 해결하는 데 도움 내 C# 코드는 다음과 같이한다. 제안

답변

1

에 대한 희망이

// set the header HTML area 

pdfConverter.PdfHeaderOptions.HtmlToPdfArea = new HtmlToPdfArea("http://localhost:50306/ColumnChart.aspx"); 

라이센스 키가 기밀이 부분을 넣어 시도하십시오, 누군가가 그것을 오용 수 있습니다. 이 게시물에서 삭제하십시오. 하지만 코드에 그대로 두십시오.

+0

설명은 확장 토론이 아닙니다. 이 대화는 [채팅으로 이동되었습니다] (http://chat.stackoverflow.com/rooms/69311/discussion-on-answer-by-anand-gangadhara-html-to-pdf-conversion-using-ephtmltopd). – Taryn