PDFizer 可以将html转换成pdf格式文档的工具

  • 软件大小:420KB
  • 软件语言:英文软件
  • 软件类型:国外软件
  • 软件授权:免费软件
  • 软件类别:浏览阅读
  • 应用平台:windows平台
  • 软件官网:
  • 更新时间:2009-03-01
  • 网友评分:
360通过 腾讯通过 金山通过


First, set a reference in your project to the 3 DLL's that Pdfizer uses. Here are the 3 dll names to set a reference to:

ICSharpCode.SharpZipLib.dll (This component is used to parse the HTML)

itextsharp.dll (This component is used by Pdfizer to create the PDF document)

Pdfizer.dll (This is the main component with the HtmlToPdf object that executes the conversion operations).

Now we can add some code to use this component. Here is the code to generate a PDF from some HTML specified:

// set a path to where you want to write the PDF to.string sPathToWritePdfTo = @"C:\new_pdf_name.pdf"; // build some HTML text to write as a PDF. You could also // read this HTML from a file or other means.// NOTE: This component doesn't understand CSS or other // newer style HTML so you will need to use depricated // HTML formatting such as the <font> tag to make it look correct.System.Text.StringBuilder sbHtml = new System.Text.StringBuilder();sbHtml.Append("<html>");sbHtml.Append("<body>");sbHtml.Append("<font size='14'>My Document Title Line</font>");sbHtml.Append("<br />");sbHtml.Append("This is my document text");sbHtml.Append("</body>");sbHtml.Append("</html>"); // create file stream to PDF file to write tousing (System.IO.Stream stream = new System.IO.FileStream

(sPathToWritePdfTo, System.IO.FileMode.OpenOrCreate)){ // create new instance of Pdfizer Pdfizer.HtmlToPdfConverter htmlToPdf = new Pdfizer.HtmlToPdfConverter(); // open stream to write Pdf to to htmlToPdf.Open(stream); // write the HTML to the component htmlToPdf.Run(sbHtml.ToString()); // close the write operation and complete the PDF file htmlToPdf.Close();}This component also supports PDF Chapters. You could add a single line of code right before the Run() method to make the HTML specified a single chapter like this:

// open stream to write Pdf to tohtmlToPdf.Open(stream); // add a chapter for this HTMLhtmlToPdf.AddChapter("My Chapter Title 1"); // write the HTML to the componenthtmlToPdf.Run(sbHtml.ToString());Repeat the AddChapter() and Run() methods for each chapter you want to add and then Close() to commit it to the PDF.



PDFizer 可以将html转换成pdf格式文档的工具




      ☉ 解压密码:www.jb51.net 就是本站主域名,希望大家看清楚,[ 分享码的获取方法 ]可以参考这篇文章
      ☉ 推荐使用 [ 迅雷 ] 下载,使用 [ WinRAR v5 ] 以上版本解压本站软件。
      ☉ 如果这个软件总是不能下载的请在评论中留言,我们会尽快修复,谢谢!
      ☉ 下载本站资源,如果服务器暂不能下载请过一段时间重试!或者多试试几个下载地址
      ☉ 如果遇到什么问题,请评论留言,我们定会解决问题,谢谢大家支持!
      ☉ 本站提供的一些商业软件是供学习研究之用,如用于商业用途,请购买正版。
      ☉ 本站提供的PDFizer 可以将html转换成pdf格式文档的工具资源来源互联网,版权归该下载资源的合法拥有者所有。