通过url 或者本地文件夹 将每个HTML 页面转换成相应PDF格式
小工具 bin下直接打开。
C# 源码,VS直接运行。
代码片段和文件信息
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 187 2019-03-19 15:42 HtmlToPDFHtmlToPDFApp.config
文件 12800 2019-03-19 17:45 HtmlToPDFHtmlToPDFinDebugHtmlToPDF.exe
文件 187 2019-03-19 15:42 HtmlToPDFHtmlToPDFinDebugHtmlToPDF.exe.config
文件 28160 2019-03-19 17:45 HtmlToPDFHtmlToPDFinDebugHtmlToPDF.pdb
文件 22984 2019-03-19 17:46 HtmlToPDFHtmlToPDFinDebugHtmlToPDF.vshost.exe
文件 187 2019-03-19 15:42 HtmlToPDFHtmlToPDFinDebugHtmlToPDF.vshost.exe.config
文件 490 2012-06-06 02:06 HtmlToPDFHtmlToPDFinDebugHtmlToPDF.vshost.exe.manifest
文件 29786112 2018-06-12 15:30 HtmlToPDFHtmlToPDFinDebugwkhtmltoimage.exe
文件 29837312 2018-06-12 15:29 HtmlToPDFHtmlToPDFinDebugwkhtmltopdf.exe
文件 29702144 2018-06-12 15:29 HtmlToPDFHtmlToPDFinDebugwkhtmltox.dll
文件 4774 2019-03-19 17:45 HtmlToPDFHtmlToPDFForm1.cs
文件 7166 2019-03-19 17:38 HtmlToPDFHtmlToPDFForm1.Designer.cs
文件 6025 2019-03-19 17:38 HtmlToPDFHtmlToPDFForm1.resx
文件 3797 2019-03-19 15:42 HtmlToPDFHtmlToPDFHtmlToPDF.csproj
文件 863 2019-03-19 15:42 HtmlToPDFHtmlToPDFobjDebugDesignTimeResolveAssemblyReferences.cache
文件 6975 2019-03-19 15:42 HtmlToPDFHtmlToPDFobjDebugDesignTimeResolveAssemblyReferencesInput.cache
文件 717 2019-03-19 17:46 HtmlToPDFHtmlToPDFobjDebugHtmlToPDF.csproj.FileListAbsolute.txt
文件 975 2019-03-19 17:38 HtmlToPDFHtmlToPDFobjDebugHtmlToPDF.csproj.GenerateResource.Cache
文件 2209 2019-03-19 15:42 HtmlToPDFHtmlToPDFobjDebugHtmlToPDF.csprojResolveAssemblyReference.cache
文件 12800 2019-03-19 17:45 HtmlToPDFHtmlToPDFobjDebugHtmlToPDF.exe
文件 180 2019-03-19 17:38 HtmlToPDFHtmlToPDFobjDebugHtmlToPDF.Form1.resources
文件 28160 2019-03-19 17:45 HtmlToPDFHtmlToPDFobjDebugHtmlToPDF.pdb
文件 180 2019-03-19 15:42 HtmlToPDFHtmlToPDFobjDebugHtmlToPDF.Properties.Resources.resources
文件 0 2019-03-19 15:42 HtmlToPDFHtmlToPDFobjDebugTemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
文件 0 2019-03-19 15:42 HtmlToPDFHtmlToPDFobjDebugTemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
文件 0 2019-03-19 15:42 HtmlToPDFHtmlToPDFobjDebugTemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
文件 521 2019-03-19 15:42 HtmlToPDFHtmlToPDFProgram.cs
文件 1356 2019-03-19 15:42 HtmlToPDFHtmlToPDFPropertiesAssemblyInfo.cs
文件 2870 2019-03-19 15:42 HtmlToPDFHtmlToPDFPropertiesResources.Designer.cs
文件 5612 2019-03-19 15:42 HtmlToPDFHtmlToPDFPropertiesResources.resx
............此处省略15个文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace HtmlToPDF
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
string pdf = System.Environment.CurrentDirectory + “\wkhtmltopdf.exe“;
private void button1_Click(object sender EventArgs e)
{
string url = textBox1.Text;
pdf = System.Environment.CurrentDirectory+“\wkhtmltopdf.exe“;
if (textBox2 .Text.Trim().Length==0)
{
MessageBox.Show(“PDF文件名不能为空“);
return;
}
string filename = textBox2.Text.Trim();
string pdfpath = filename + “.pdf“;
Process p = System.Diagnostics.Process.Start(pdf url + “ ““ + pdfpath+“““);
p.WaitForExit();
}
private void button2_Click(object sender EventArgs e)
{
string v_OpenFolderPath = System.Environment.CurrentDirectory;
System.Diagnostics.Process.Start(v_OpenFolderPath);
}
///
/// 批量生成目标文件夹
///
string PDFPath = ““;
private void button3_Click(object sender EventArgs e)
{
if (textBox3.Text.Trim().Length == 0)
{
MessageBox.Show(“根目录路径不能为空“);
return;
}
if (this.folderBrowserDialog1.ShowDialog() == DialogResult.OK)
{
if (this.folderBrowserDialog1.SelectedPath.Trim() != ““)
PDFPath = this.folderBrowserDialog1.SelectedPath.Trim();
folder = 0;
file = 0;
string path = textBox3.Text;
FindFile(new DirectoryInfo(path));
MessageBox.Show(“文件夹“ + folder + “个,HTML文件“ + file + “个“);
}
}
public int folder = 0;
public int file = 0;
void FindFile(DirectoryInfo di)
{
FileInfo[] fis = di.GetFiles();
for (int i = 0; i < fis.Length; i++)
{
WriteLog(fis[i].FullName “1“);
}
DirectoryInfo[] dis = di.GetDirectories();
for (int j = 0; j < dis.Length; j++)
{
WriteLog(dis[j].FullName “2“);
FindFile(dis[j]);
}
}
public void WriteLog(string msg string type)
{
if (type == “1“)
{//文件
try
{
string logFileName = Application.StartupPath.ToString() + “\file.log“;
if (
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 187 2019-03-19 15:42 HtmlToPDFHtmlToPDFApp.config
文件 12800 2019-03-19 17:45 HtmlToPDFHtmlToPDFinDebugHtmlToPDF.exe
文件 187 2019-03-19 15:42 HtmlToPDFHtmlToPDFinDebugHtmlToPDF.exe.config
文件 28160 2019-03-19 17:45 HtmlToPDFHtmlToPDFinDebugHtmlToPDF.pdb
文件 22984 2019-03-19 17:46 HtmlToPDFHtmlToPDFinDebugHtmlToPDF.vshost.exe
文件 187 2019-03-19 15:42 HtmlToPDFHtmlToPDFinDebugHtmlToPDF.vshost.exe.config
文件 490 2012-06-06 02:06 HtmlToPDFHtmlToPDFinDebugHtmlToPDF.vshost.exe.manifest
文件 29786112 2018-06-12 15:30 HtmlToPDFHtmlToPDFinDebugwkhtmltoimage.exe
文件 29837312 2018-06-12 15:29 HtmlToPDFHtmlToPDFinDebugwkhtmltopdf.exe
文件 29702144 2018-06-12 15:29 HtmlToPDFHtmlToPDFinDebugwkhtmltox.dll
文件 4774 2019-03-19 17:45 HtmlToPDFHtmlToPDFForm1.cs
文件 7166 2019-03-19 17:38 HtmlToPDFHtmlToPDFForm1.Designer.cs
文件 6025 2019-03-19 17:38 HtmlToPDFHtmlToPDFForm1.resx
文件 3797 2019-03-19 15:42 HtmlToPDFHtmlToPDFHtmlToPDF.csproj
文件 863 2019-03-19 15:42 HtmlToPDFHtmlToPDFobjDebugDesignTimeResolveAssemblyReferences.cache
文件 6975 2019-03-19 15:42 HtmlToPDFHtmlToPDFobjDebugDesignTimeResolveAssemblyReferencesInput.cache
文件 717 2019-03-19 17:46 HtmlToPDFHtmlToPDFobjDebugHtmlToPDF.csproj.FileListAbsolute.txt
文件 975 2019-03-19 17:38 HtmlToPDFHtmlToPDFobjDebugHtmlToPDF.csproj.GenerateResource.Cache
文件 2209 2019-03-19 15:42 HtmlToPDFHtmlToPDFobjDebugHtmlToPDF.csprojResolveAssemblyReference.cache
文件 12800 2019-03-19 17:45 HtmlToPDFHtmlToPDFobjDebugHtmlToPDF.exe
文件 180 2019-03-19 17:38 HtmlToPDFHtmlToPDFobjDebugHtmlToPDF.Form1.resources
文件 28160 2019-03-19 17:45 HtmlToPDFHtmlToPDFobjDebugHtmlToPDF.pdb
文件 180 2019-03-19 15:42 HtmlToPDFHtmlToPDFobjDebugHtmlToPDF.Properties.Resources.resources
文件 0 2019-03-19 15:42 HtmlToPDFHtmlToPDFobjDebugTemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
文件 0 2019-03-19 15:42 HtmlToPDFHtmlToPDFobjDebugTemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
文件 0 2019-03-19 15:42 HtmlToPDFHtmlToPDFobjDebugTemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
文件 521 2019-03-19 15:42 HtmlToPDFHtmlToPDFProgram.cs
文件 1356 2019-03-19 15:42 HtmlToPDFHtmlToPDFPropertiesAssemblyInfo.cs
文件 2870 2019-03-19 15:42 HtmlToPDFHtmlToPDFPropertiesResources.Designer.cs
文件 5612 2019-03-19 15:42 HtmlToPDFHtmlToPDFPropertiesResources.resx
............此处省略15个文件信息
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)