asp.net 或者C#.net 中用flashprinter将pdf转换成SWF的问题
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 WindowsFormsApplication1{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { ConvertPdfToSwf(@"pdf\2010xrss.pdf", @"swf\temp.swf"); convertPDFToSwf(@"pdf\2010xrss.pdf", @"swf\temp.swf"); ConvertPdfToSwf(@"pdf\2010xrss.pdf", @"swf\temp.swf"); } public void ConvertPdfToSwf(string inFilename, string swfFilename) { try { string flashPrinter = string.Concat(AppDomain.CurrentDomain.BaseDirectory, @"FlashPaper2.2\FlashPrinter.exe"); ProcessStartInfo startInfo = new ProcessStartInfo(flashPrinter); startInfo.Arguments = string.Concat(AppDomain.CurrentDomain.BaseDirectory + inFilename, " -o ", AppDomain.CurrentDomain.BaseDirectory+swfFilename); Process process = new Process(); process.StartInfo = startInfo; bool isStart = process.Start(); process.WaitForExit(); process.Close(); } catch (Exception ex) { } } public static void convertPDFToSwf(string PDFPath, string SWFPath) { string exe = string.Concat(AppDomain.CurrentDomain.BaseDirectory, @"FlashPaper2.2\FlashPrinter.exe"); if (!File.Exists(exe)) { throw new ApplicationException("Can not find: " + exe); } System.Diagnostics.Process proc = new System.Diagnostics.Process(); proc.StartInfo.FileName = exe; proc.StartInfo.Arguments = " -o "" + SWFPath + """ + " -z" + " -s flashversion=9" + " -s disablelinks" + " -j 100" + " "" + PDFPath + """; proc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; proc.Start(); proc.WaitForExit(); proc.Close(); } public static void ConvertToSwf(string pdfPath, string swfPath) { try { //string exe = HttpContext.Current.Server.MapPath("PDF2SWF/pdf2swf.exe"); //string exe = @"d:\SWFTools\pdf2swf.exe "; string exe = string.Concat(AppDomain.CurrentDomain.BaseDirectory, @"FlashPaper2.2\FlashPrinter.exe"); if (!File.Exists(exe)) { throw new ApplicationException("Can not find: " + exe); } StringBuilder sb = new StringBuilder(); sb.Append(" -o "" + swfPath + """);//output sb.Append(" -z"); sb.Append(" -s flashversion=9");//flash version sb.Append(" -s disablelinks");//禁止PDF里面的链接 //sb.Append(" -p " + "1" + "-" + page);//page range //sb.Append();//Set quality of embedded jpeg pictures to quality. 0 is worst (small), 100 is best (big). (default:85) sb.Append(" "" + pdfPath + """);//input System.Diagnostics.Process proc = new System.Diagnostics.Process(); proc.StartInfo.FileName = exe; proc.StartInfo.Arguments = sb.ToString(); proc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; proc.Start(); proc.WaitForExit(); proc.Close(); } catch (Exception ex) { throw ex; } } }}
asp.net swf pdf
[解决办法]
C#中使用FlashPrinter将WORD文档转成PDF或者SWF
WORD文档转成PDF或者SWF也可以PDF转SWF,可以实现在线浏览。
public void ConvertPdfToSwf(string inFilename, string swfFilename)
{
try
{
string flashPrinter = string.Concat(AppDomain.CurrentDomain.BaseDirectory, @"FlashPaper2.2\FlashPrinter.exe");
ProcessStartInfo startInfo = new ProcessStartInfo(flashPrinter);
startInfo.Arguments = string.Concat(Server.MapPath(inFilename), " -o ", Server.MapPath(swfFilename));
Process process = new Process();
process.StartInfo = startInfo;
bool isStart = process.Start();
process.WaitForExit();
process.Close();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
调用:
ConvertPdfToSwf("test.doc", "test.swf");
NOTE:
F5可以测试成功,在IIS里面不能转换成功的解决方案:
由于调用EXE文件,所以涉及到权限不足的问题,在IIS的应用程序池中的标识
预定义帐户修改成本地系统,也就是说拥有了全部权限。再测试就可以成功转换了