2016-11-20 4 views
0

次のコードを使用して、iTextSharp SelectPDFを使用して大きなHTMLコンテンツをPDFに変換しています。いずれのHTMLページも正しく変換されません。データは6ページ後にPDFには消えます。すべてのHTMLページがSelectPdfでPDFに変換されない

public static void CreatePDFFromHTMLFile(string HtmlStream, string FileName) 
    { 
     try 
     { 
      // read parameters from the webpage 
      string htmlString = HtmlStream; 
      string baseUrl = ""; 
      string pdf_page_size = "A4"; 
      PdfPageSize pageSize = (PdfPageSize)Enum.Parse(typeof(PdfPageSize), 
       pdf_page_size, true); 
      string pdf_orientation = "Portrait"; 
      PdfPageOrientation pdfOrientation = 
       (PdfPageOrientation)Enum.Parse(typeof(PdfPageOrientation), 
       pdf_orientation, true); 
      int webPageWidth = 1024; 
      int webPageHeight = 0; 
      HtmlToPdf converter = new HtmlToPdf(); 
      // set converter options 
      converter.Options.PdfPageSize = pageSize; 
      converter.Options.PdfPageOrientation = pdfOrientation; 
      converter.Options.WebPageWidth = webPageWidth; 
      converter.Options.WebPageHeight = webPageHeight; 
      // create a new pdf document converting an url 
      PdfDocument doc = converter.ConvertHtmlString(htmlString, baseUrl); 
      doc.Save(FileName); 
      doc.Close(); 
     } 
     catch (Exception ex) 
     { 
      Tracing.HandleException(ex); 
     } 
    } 
+1

は、したがって、あなたの質問には、iTextの質問として表示すべきではない、iTextSharpには 'HtmlToPdf'クラスはありません。私は 'HtmlToPdf'が何であるか分かりません(iTextSharpにそのようなクラスが存在するなら、私はiTextの元の開発者です)。また、あなたがHTMLを共有していない場合、答えを期待しないでください。 –

+1

私にSelectPDFのように見えます:http://selectpdf.com/html-to-pdf/demo/convert-html-code-to-pdf.aspxタグを更新します。私の編集Brunoを承認できますか? –

+1

OPはSelectPDFの現在のユーザーですが、それに満足していないのでしょうか?たぶん、彼らはiTextに切り替えたいと思ってテクニカルサポートをプロービングしていますか? –

答えて

0

問題は、SelectPdfコミュニティエディションを使用していることです。 SelectPdf(http://selectpdf.com/community-edition/)によれば、無料版は5ページに制限されています。

長いページを変換する場合は、商用版を使用する必要がありますが、それは無料ではありません。

0

これはあなたのために役立つでしょうJsPdfを使用してください。 の下のこのリンクを参照してソースコードと完全なドキュメントを取得してください。

https://parall.ax/products/jspdf

関連する問題