您的位置:首页 > 理论基础 > 计算机网络

https方式使用git@osc设置密码的方式

2014-05-05 20:05 267 查看
使用swftools的pdf2swf.exe命令行来完成这项操作,转换效果理想,支持as3,swftools官网:http://www.swftools.org/
下面是根据使用需要设计的2个方法:
/// <summary>
/// 获取pdf文件的页数
/// </summary>
public static int GetPageCount(string pdfPath)
{
try
{
byte[] buffer = File.ReadAllBytes(pdfPath);
int length = buffer.Length;
if (buffer == null)
return -1;
if (buffer.Length <= 0)
return -1;
string pdfText = Encoding.Default.GetString(buffer);
System.Text.RegularExpressions.Regex rx1 = new System.Text.RegularExpressions.Regex(@"/Type/s*/Page[^s]");
System.Text.RegularExpressions.MatchCollection matches = rx1.Matches(pdfText);
return matches.Count;
}
catch (Exception ex)
{
Util.WriteLog(ex);
}
return -1;
}
/// <summary>
/// 把指定的pdf页面转换成swf
/// </summary>
public static void ConvertToSwf(string pdfPath, string swfPath, int page)
{
try
{
string exe = Path.Combine(Application.StartupPath, "Tools//pdf2swf.exe");
if (!File.Exists(exe))
{
throw new ApplicationException("Can not find: " + exe);
}
//参考:http://www.swftools.org/pdf2swf.html
StringBuilder sb = new StringBuilder();
sb.Append(" -p " + page + "-" + page);//page range
sb.Append(" -j 100");//Set quality of embedded jpeg pictures to quality. 0 is worst (small), 100 is best (big). (default:85)
sb.Append(" -t");//The resulting SWF file will not turn pages automatically.
sb.Append(" -T 9");//flash version
sb.Append(" /"" + pdfPath + "/"");//input
sb.Append(" -o /"" + swfPath + "/"");//output
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)
{
Util.WriteLog(ex);
}
}

效果图



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: