2015-01-21 3 views
2

Я пытался сохранить мою html-страницу в формате pdf. Я использую ephtmltopdf. Его хранение моего файла Pdf, но таблица упускается. Теперь у меня нет такой идеи о том, как это исправить. Мой C# код как:Преобразование html в pdf с использованием ephtmltopdf

  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 помочь мне исправить это. Надежды на предложение

ответ

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