资源简介
用Aspose.Pdf来实现HTML转PDF
代码片段和文件信息
using System;
using System.Drawing.Printing;
using System.IO;
using System.Web;
using System.Diagnostics;
using Aspose.Pdf;
namespace HTML_PDF
{
public partial class ConvertPDF : System.Web.UI.Page
{
protected void Page_Load(object sender EventArgs e)
{
}
public void ConverttoPDF(string htmlFile)
{
string html = htmlFile;
string guid = Guid.NewGuid().ToString();
string pdfFileName = Request.PhysicalApplicationPath + “\\files\\“ + guid + “GenerateHTMLTOPDF.pdf“;
HtmlLoadOptions htmlLoadOptions = new HtmlLoadOptions();
htmlLoadOptions.PageInfo.Margin.Bottom = 10;
htmlLoadOptions.PageInfo.Margin.Top = 20;
Document doc = new Document(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(html)) htmlLoadOptions);
doc.Save(pdfFileName);
Process myProcess = new Process();
myProcess.StartInfo.FileName = pdfFileName;
myProcess.Start();
}
public void btnClick_Click(object sender EventArgs e)
{
string htmlFile = @“
yle type=‘text/css‘>body {
width: 1024px;
color:red;
background: #ffffff;
padding-left:10px;padding-right:10px;padding-top:10px;
}
.table0 {
//table-layout: fixed;
width: 100%;
border-collapse: collapse;
background: #f0f5fb;
}
.table1 {
border-collapse: collapse;
background: #f0f5fb;
}
.table0 td {
border-width:1px 1px 1px 1px;
border-style:solid;
border-color:#ffffff;
background-color: #f0f5fb;
border: 1px solid #ffffff;
padding: 3px 0px 3px 10px;
font-size:13px;
font-family: ‘Microsoft Yahei‘ ‘Arial‘ !important;
}
.table1 td {
border-width:1px 1px 1px 1px;
border-style:solid;
border-color:#ffffff;
background-color: #f0f5fb;
border: 1px solid #ffffff;
padding: 3px 0px 3px 10px;
font-size:13px;
font-family: ‘Microsoft Yahei‘ ‘Arial‘ !important;
}
.td-name
{
color: #0069af;
}
.td-value
{
color: #000000;
}
.th-name
{
color: #0069af;
text-align:center;
}
.panel-header {
font-size: 14px;
font-weight: bolder;
color: #3d5880;
text-shadow: 1px 1px rgba(000.3);
font-family: ‘Microsoft Yahei‘ ‘Arial‘ !important;
text-align: left;
padding:5px 0px 10px 5px;
} yle>yle=‘font-size:16px;font-weight:bolder; color: #3d5880;text-shadow: 1px 1px rgba(000.3); font-family: Microsoft Yahei Arial !important;‘>活动申请单信息概览
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 32767488 2015-12-09 17:39 HTML-PDF-A\HTMLtoPDF\bin\Aspose.Pdf.dll
文件 1581591 2015-12-09 17:39 HTML-PDF-A\HTMLtoPDF\bin\Aspose.Pdf.xml
文件 28160 2016-02-29 11:02 HTML-PDF-A\HTMLtoPDF\bin\HTMLtoPDF.dll
文件 17920 2016-02-29 11:02 HTML-PDF-A\HTMLtoPDF\bin\HTMLtoPDF.pdb
文件 596 2016-02-24 14:30 HTML-PDF-A\HTMLtoPDF\ConvertPDF.aspx
文件 13895 2016-02-29 11:02 HTML-PDF-A\HTMLtoPDF\ConvertPDF.aspx.cs
文件 1148 2016-02-24 14:30 HTML-PDF-A\HTMLtoPDF\ConvertPDF.aspx.designer.cs
文件 260507 2016-02-29 11:01 HTML-PDF-A\HTMLtoPDF\files\16507c10-82bf-4ed7-8418-883206965104GenerateHTMLTOPDF.pdf
文件 260507 2016-02-24 15:10 HTML-PDF-A\HTMLtoPDF\files\214effc4-379f-4467-ae4d-794cf6a6bfccGenerateHTMLTOPDF.pdf
文件 260507 2016-02-24 15:10 HTML-PDF-A\HTMLtoPDF\files\40ccf1d9-0a65-436c-a6cc-031300bca305GenerateHTMLTOPDF.pdf
文件 266917 2016-02-29 11:03 HTML-PDF-A\HTMLtoPDF\files\4a1429af-b950-4829-bd22-88b981196dcbGenerateHTMLTOPDF.pdf
文件 260507 2016-02-24 15:10 HTML-PDF-A\HTMLtoPDF\files\5b6fe64d-df7d-4cb0-a4b4-ba33f6fd6209GenerateHTMLTOPDF.pdf
文件 260507 2016-02-24 15:12 HTML-PDF-A\HTMLtoPDF\files\bca24b77-df36-44c5-a2e1-f40aed39ad03GenerateHTMLTOPDF.pdf
文件 1506 2016-02-23 09:14 HTML-PDF-A\HTMLtoPDF\files\css.txt
文件 260507 2016-02-24 17:21 HTML-PDF-A\HTMLtoPDF\files\d4d54e80-c8ba-4c8f-87e0-471c81b2ece2GenerateHTMLTOPDF.pdf
文件 260507 2016-02-24 15:09 HTML-PDF-A\HTMLtoPDF\files\e72f4bb5-9b3a-4611-8046-775c20af7c11GenerateHTMLTOPDF.pdf
文件 93 2016-02-24 14:29 HTML-PDF-A\HTMLtoPDF\Global.asax
文件 1202 2016-02-24 14:29 HTML-PDF-A\HTMLtoPDF\Global.asax.cs
文件 4602 2016-02-24 14:34 HTML-PDF-A\HTMLtoPDF\HTMLtoPDF.csproj
文件 1086 2016-02-24 14:34 HTML-PDF-A\HTMLtoPDF\HTMLtoPDF.csproj.user
文件 7065 2016-02-29 11:02 HTML-PDF-A\HTMLtoPDF\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 884 2016-02-29 11:00 HTML-PDF-A\HTMLtoPDF\obj\Debug\HTMLtoPDF.csproj.FileListAbsolute.txt
文件 18139 2016-02-29 11:00 HTML-PDF-A\HTMLtoPDF\obj\Debug\HTMLtoPDF.csprojResolveAssemblyReference.cache
文件 28160 2016-02-29 11:02 HTML-PDF-A\HTMLtoPDF\obj\Debug\HTMLtoPDF.dll
文件 17920 2016-02-29 11:02 HTML-PDF-A\HTMLtoPDF\obj\Debug\HTMLtoPDF.pdb
文件 1319 2016-02-24 14:29 HTML-PDF-A\HTMLtoPDF\Properties\AssemblyInfo.cs
文件 1989 2016-02-24 14:29 HTML-PDF-A\HTMLtoPDF\Web.config
文件 1223 2016-02-24 14:29 HTML-PDF-A\HTMLtoPDF\Web.Debug.config
文件 1284 2016-02-24 14:29 HTML-PDF-A\HTMLtoPDF\Web.Release.config
文件 917 2016-02-24 14:29 HTML-PDF-A\HTMLtoPDF.sln
............此处省略13个文件信息
- 上一篇:新鲜出炉dhtmlx5.0.2专业版
- 下一篇:代理商管理系统_原型+需求分析
相关资源
- scratch3.0文件打包工具-htmlifier
- bootstrap3.0带源代码
- uploadifive1.2.2 uploadify HTML5
- 管理系统HTML模板
- 非常漂亮的导航菜单(html)
- 网页文件HTML
-
html中获取xm
l数据 - HTML AJAX(手写ajax)显示数据库数据
- HTML5 CSS3 :canvas 模拟实现电子彩票刮
- 仿Win10 UI界面(前端html模板)
- 永劫无间主题 html+css
- 登录html
- 游戏商城html模板(首页)
- 生日祝福html代码(带背景音乐)
- 基础html小米商城
- W3C html5 参考手册(教学资源免费)
- html5 2048小游戏
- oa html模板(基于Vue开发)
- 个人网站备案的HTML模板
- html旅游静态网站
- 简易京东网页HTML代码(HTMLamp;JS;)
- 有问必答项目 html源码
- html 塔防游戏runner
- html 二十一点
- 生日祝福html网页源码(特效很多)
- 时时彩网站 html模板(手机端 )
- HTML可视化面板
- 印象烘培 首页html源码
- H5彩票网站html代码
- 教育类网站html代码
川公网安备 51152502000135号
评论
共有 条评论