基本信息
源码名称:Word,PPT,Word,execl转PDF
源码大小:0.15M
文件格式:.rar
开发语言:C#
更新时间:2018-06-06
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 1 元×
微信扫码支付:1 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
Word,PPT,Word,execl转PDF
Word,PPT,Word,execl转PDF
excel原文如下:
转换后pdf如下:
using GxNetExtend;
using System;
using System.IO;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ConvertPDF
{
public partial class Form1 : Form
{
public string path;
public string trapath;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog dialog = new OpenFileDialog();
dialog.Multiselect = false;//该值确定是否可以选择多个文件
dialog.Title = "请选择文件夹";
dialog.Filter = "所有文件(*.*)|*.*";
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
string file = dialog.FileName;
//MessageBox.Show(file);
// label1.Text = file;
path = file;
}
}
private void label1_Click(object sender, EventArgs e)
{
}
private async void button2_Click(object sender, EventArgs e)
{
System.DateTime currentTime = new System.DateTime();
// 取当前年月日时分秒
currentTime = System.DateTime.Now;
//取当前年
int 年 = currentTime.Year;
//取当前月
int 月 = currentTime.Month;
// 取当前日
int 日 = currentTime.Day;
//取当前时
int 时 = currentTime.Hour;
// 取当前分
int 分 = currentTime.Minute;
//取当前秒
int 秒 = currentTime.Second;
// 取当前毫秒
int 毫秒 = currentTime.Millisecond;
string 时间 = 年.ToString() 月.ToString() 日.ToString() 时.ToString() 分.ToString() 秒.ToString() 毫秒.ToString();
FileStream fs = new FileStream(trapath 时间 .Trim() ".PDF", FileMode.CreateNew);
StreamWriter sw = new StreamWriter(fs);
// sw.Write("你好啊"); //这里是写入的内容
sw.Close();
PdfUtil getPdfUtil = new PdfUtil();
label1.Text = "正在转换....";
bool a = await Task.Run<bool>(() => getPdfUtil.convert2PDF(path, trapath 时间.Trim() ".PDF"));
label1.Text = "转换成功!";
}
private async void label2_Click(object sender, EventArgs e)
{
System.DateTime currentTime = new System.DateTime();
// 取当前年月日时分秒
currentTime = System.DateTime.Now;
//取当前年
int 年 = currentTime.Year;
//取当前月
int 月 = currentTime.Month;
// 取当前日
int 日 = currentTime.Day;
//取当前时
int 时 = currentTime.Hour;
// 取当前分
int 分 = currentTime.Minute;
//取当前秒
int 秒 = currentTime.Second;
// 取当前毫秒
int 毫秒 = currentTime.Millisecond;
string 时间 = 年.ToString() 月.ToString() 日.ToString() 时.ToString() 分.ToString() 秒.ToString() 毫秒.ToString();
FileStream fs = new FileStream(trapath textBox1.Text.Trim() ".PDF", FileMode.CreateNew);
StreamWriter sw = new StreamWriter(fs);
// sw.Write("你好啊"); //这里是写入的内容
sw.Close();
PdfUtil getPdfUtil = new PdfUtil();
label1.Text = "正在转换....";
bool a = await Task.Run<bool>(() => getPdfUtil.convert2PDF(path, trapath textBox1.Text.Trim() ".PDF"));
label1.Text = "转换成功!";
}
private void button3_Click(object sender, EventArgs e)
{
System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog();
dialog.Description = "请选择Txt所在文件夹";
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
if (string.IsNullOrEmpty(dialog.SelectedPath))
{
MessageBox.Show(this, "文件夹路径不能为空", "提示");
}
else
{
trapath = dialog.SelectedPath.ToString() @"\";
// MessageBox.Show(this, dialog.SelectedPath.ToString(), "提示");
}
}
}
}
}