当前位置: 代码迷 >> ASP >> asp.net 或者C#net 中用flashprinter将pdf转换成SWF的有关问题
  详细解决方案

asp.net 或者C#net 中用flashprinter将pdf转换成SWF的有关问题

热度:242   发布时间:2013-09-28 10:01:20.0
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;            }        }    }}
  相关解决方案