日期:2014-05-17  浏览次数:20975 次

asp.net工具类- PSD2swfHelper
asp.net工具类 
using System.Web;
using System.Text;

public static class PSD2swfHelper
{
    /// <summary>
    /// 转换所有的页,图片质量80%
    /// </summary>
    /// <param name="pdfPath">PDF文件地址</param>
    /// <param name="swfPath">生成后的SWF文件地址</param>
    public static bool PDF2SWF(string pdfPath, string swfPath)
    {
        return PDF2SWF(pdfPath, swfPath, 1, GetPageCount(HttpContext.Current.Server.MapPath(pdfPath)), 80);
    }

    /// <summary>
    /// 转换前N页,图片质量80%
    /// </summary>
    /// <param name="pdfPath">PDF文件地址</param>
    /// <param name="swfPath">生成后的SWF文件地址</param>
    /// <param name="page">页数</param>
    public static bool PDF2SWF(string pdfPath, string swfPath, int page)
    {
        return PDF2SWF(pdfPath, swfPath, 1, page, 80);
    }

    /// <summary>
    /// PDF格式转为SWF
    /// </summary>
    /// <param name="pdfPath">PDF文件地址</param>
    /// <param name="swfPath">生成后的SWF文件地址</param>
    /// <param name="beginpage">转换开始页</param>
    /// <param name="endpage">转换结束页</param>
    private static bool PDF2SWF(string pdfPath, string swfPath, int beginpage, int endpage, int photoQuality)
    {
        string exe = HttpContext.Current.Server.MapPath("~/Bin/tools/pdf2swf-0.9.1.exe");
        pdfPath = HttpContext.Current.Server.MapPath(pdfPath);
        swfPath = HttpContext.Current.Server.MapPath(swfPath);
        if (!System.IO.File.Exists(exe) || !System.IO.File.Exists(pdfPath) || System.IO.File.Exists(swfPath))
        {
            return false;
        }
        StringBuilder ** = new StringBuilder();
        **.Append(" \"" + pdfPath + "\"");
        **.Append(" -o \"" + swfPath + "\"");
        **.Append(" -s flashversion=9");
        if (endpage > GetPageCount(pdfPath)) endpage = GetPageCount(pdfPath);
        **.Append(" -p " + "\"" + beginpage + "" + "-" + endpage + "\"");
        **.Append(" -j " + photoQuality);
        string Command = **.ToString();
   &nbs