问个PDF在线浏览问题
是这样的
现在客户要一个功能
PDF在线浏览
用的技术是pdf2swf.exe
PDF转成SWF的这种方法,已经成功,
但是出现有的中文乱码例如黑体,经过网上查找也找到解决方法,
加入这俩gkai00mp.ttf,gbsn00lp.ttf字体,通过字体转换,具体转换看不到,
问题来了,本地成功,网上不成功,路径都正确,不知道有没有大虾用过,或者遇到这种情况,请指教啊。
public void ConvertToSwf(string pdfPath, string swfPath, int page)
{
try
{
string exe =@"C:\SWFTools\pdf2swf.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(" -s simpleviewer");
//sb.Append(" -p " + "1" + "-" + page);//page range
sb.Append(" -j 100");
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;
Response.Write(ex.ToString());
}
}
ConvertToSwf(@"C:\Documents and Settings\Administrator\桌面\xnew123123.swf", 2);
/// <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 sb = new StringBuilder();
sb.Append(" "" + pdfPath + """);
sb.Append(" -o "" + swfPath + """);
sb.Append(" -s flashversion=9");
if (endpage > GetPageCount(pdfPath)) endpage = GetPageCount(pdfPath);
sb.Append(" -p " + """ + beginpage + "" + "-" + endpage + """);
sb.Append(" -j " + photoQuality);
string Command = sb.ToString();
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = exe;
p.StartInfo.Arguments = Command;
p.StartInfo.WorkingDirectory = HttpContext.Current.Server.MapPath("~/Bin/");
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = false;
p.Start();
p.BeginErrorReadLine();
p.WaitForExit();
p.Close();
p.Dispose();
return true;
}