pdf2swf组件转pdf文件成swf文件的代码
2015-02-24 08:04:21 访问(1751) 赞(0) 踩(0)
相关下载:pdf2swf.exe(百度云网盘下载)
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btn_OK_Click(object sender, EventArgs e)
{
try
{
string savePath = @"C:\MyProgram\pdf2swf\";
string fileName = "test";
string fileExtention = ".pdf";
//切记,使用pdf2swf.exe 打开的文件名之间不能有空格,否则会失败
string cmdStr = @"C:\MyProgram\pdf2swf\pdf2swf.exe";
string sourcePath = @"""" + savePath + fileName + fileExtention + @"""";
string targetPath = @"""" + savePath + fileName + ".swf" + @"""";
//@"""" 四个双引号得到一个双引号,如果你所存放的文件所在文件夹名有空格的话,要在文件名的路径前后加上双引号,才能够成功
// -t 源文件的路径
// -s 参数化(也就是为pdf2swf.exe 执行添加一些窗外的参数(可省略))
string argsStr = " -t " + sourcePath + " -s flashversion=9 -o " + targetPath;
ExcutedCmd(cmdStr, argsStr);
Response.Write("OK");
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
private static void ExcutedCmd(string cmd, string args)
{
using (Process p = new Process())
{
ProcessStartInfo psi = new ProcessStartInfo(cmd, args);
psi.WindowStyle = ProcessWindowStyle.Hidden;
p.StartInfo = psi;
p.Start();
p.WaitForExit();
}
}
上一条:
下一条:
相关评论
发表评论