是这样的
现在客户要一个功能
PDF在线浏览
用的技术是pdf2swf.exe
PDF转成SWF的这种方法,已经成功,
但是出现有的中文乱码例如黑体,经过网上查找也找到解决方法,
加入这俩gkai00mp.ttf,gbsn00lp.ttf字体,通过字体转换,具体转换看不到,问题来了,本地成功,网上不成功,路径都正确,不知道有没有大虾用过,或者遇到这种情况,请指教啊。
sb.Append(" -o \"" + swfFile + "\" -t -s languagedir=D:\\vhostroot\\LocalUser\\xydl6\\www\\xpdf\\xpdf-chinese-simplified -s flashversion=9");//swf路径
现在客户要一个功能
PDF在线浏览
用的技术是pdf2swf.exe
PDF转成SWF的这种方法,已经成功,
但是出现有的中文乱码例如黑体,经过网上查找也找到解决方法,
加入这俩gkai00mp.ttf,gbsn00lp.ttf字体,通过字体转换,具体转换看不到,问题来了,本地成功,网上不成功,路径都正确,不知道有没有大虾用过,或者遇到这种情况,请指教啊。
sb.Append(" -o \"" + swfFile + "\" -t -s languagedir=D:\\vhostroot\\LocalUser\\xydl6\\www\\xpdf\\xpdf-chinese-simplified -s flashversion=9");//swf路径
装xpdf语言包,解决中文无法显示问题对于未安装xpdf的用户pdf2swf在将pdf文件转换成swf文件时,如果pdf中有中文,那么pdf2swf就可能处理不了,这时就需要在pdf2swf生成时添加xpdf支持,接下来我们就来看看如何安装xpdf。
首先到xpdf网站:http://foolabs.com/xpdf/download.html上下载xpdf-chinese-simplified.tar.gz文件(ftp://ftp.foolabs.com/pub/xpdf/xpdf-chinese-simplified.tar.gz),windows与linux皆适用,下载下来后,解压到某一特定目录,然后将本文附件当中名为stsong.tar.gz文件下载下来,解压后将其中的STSONG.TTF字体文件放在xpdf-chinese-simplified所在目录下的CMap目录下,然后打开xpdf-chinese-simplified所在目录下add-to-xpdfrc文件,源文件内容如下:从原文件中可以看到,其中关于字体路径信息是基于linux的,所以如果要根据你的xpdf-chinese-simplified目录实际存放位置进行修改,如linux下修改后的内容为:
可以看到这里除了修改标准信息名,还添加了名为displayCIDFontTT的了行信息,在该行信息中,我们指定了之前下载的STSONG.TTF文件的位置。
如果系统为windows,那么修改后的内容可能是下面的样子:
可以看到,该文件同样指定了STSONG.TTF文件位置信息。参考 pdf转换swf格式出现的乱码问题
http://blog.csdn.net/yali1990515/article/details/7790716
public void ConvertToSWF(string oldFile, string swfFile)
{
//System.Diagnostics.Process pc = new System.Diagnostics.Process();
//pc.StartInfo.FileName = @"C:\Program Files\SWFTools\pdf2swf.exe";
////pc.StartInfo.FileName = @"C:\Program Files\Macromedia\FlashPaper 2\FlashPrinter.exe";
//pc.StartInfo.Arguments = string.Format("{0} -o {1}", oldFile, swfFile);
//pc.StartInfo.CreateNoWindow = true;
//pc.StartInfo.UseShellExecute = false;
//pc.StartInfo.RedirectStandardInput = false;
//pc.StartInfo.RedirectStandardOutput = false;
//pc.StartInfo.RedirectStandardError = true;
//pc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
//bool falg = pc.Start();
//pc.WaitForExit();
//pc.Close();
//pc.Dispose();
//if (falg)
//this.BindFiles();
// Usage: C:\Program Files\SWFTools\pdf2swf.exe [-options] file.pdf -o file.swf //-h , --help Print short help message and exit
//-V , --version Print version info and exit
//-o , --output file.swf Direct output to file.swf. If file.swf contains '%' (file%.swf), then each page goes to a seperate file.
//-p , --pages range Convert only pages in range with range e.g. 1-20 or 1,4,6,9-11 or
//-P , --password password Use password for deciphering the pdf.
//-v , --verbose Be verbose. Use more than one -v for greater effect.
//-z , --zlib Use Flash 6 (MX) zlib compression.
//-i , --ignore Allows pdf2swf to change the draw order of the pdf. This may make the generated
//-j , --jpegquality quality Set quality of embedded jpeg pictures to quality. 0 is worst (small), 100 is best (big). (default:85)
//-s , --set param=value Set a SWF encoder specific parameter. See pdf2swf -s help for more information.
//-w , --samewindow When converting pdf hyperlinks, don't make the links open a new window.
//-t , --stop Insert a stop() command in each page.
//-T , --flashversion num Set Flash Version in the SWF header to num.
//-F , --fontdir directory Add directory to the font search path.
//-b , --defaultviewer Link a standard viewer to the swf file.
//-l , --defaultloader Link a standard preloader to the swf file which will be displayed while the main swf is loading.
//-B , --viewer filename Link viewer filename to the swf file.
//-L , --preloader filename Link preloader filename to the swf file.
//-q , --quiet Suppress normal messages. Use -qq to suppress warnings, also.
//-S , --shapes Don't use SWF Fonts, but store everything as shape.
//-f , --fonts Store full fonts in SWF. (Don't reduce to used characters).
//-G , --flatten Remove as many clip layers from file as possible.
//-I , --info Don't do actual conversion, just display a list of all pages in the PDF.
//-Q , --maxtime n Abort conversion after n seconds. Only available on Unix.
try
{
string exe = Server.MapPath("pdf2swf.exe");//@"C:\Program Files\SWFTools\pdf2swf.exe"; //SWFTools程序路径 if (!File.Exists(exe))
{
throw new ApplicationException("Can not find: " + exe); }
StringBuilder sb = new StringBuilder();
//pdf.pdf -o swf.swf -t -s flashversion=9
sb.Append(" \"" + oldFile + "\"");//pdf路径
sb.Append(" -o \"" + swfFile + "\" -t -s languagedir=D:\\vhostroot\\LocalUser\\xydl6\\www\\xpdf\\xpdf-chinese-simplified -s flashversion=9");//swf路径
// sb.Append(" -z");D:\vhostroot\LocalUser\xydl6\www\
// sb.Append(" -b,defaultviewer"); // sb.Append(" -s disablelinks ");//禁止PDF里面的链接
// sb.Append(" -j 100"); 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();
bool falg = proc.Start();
proc.Close();
if (falg)
Page.RegisterStartupScript("back", AccessDAL.MessageBox.FN_Alert("消息提示", "添加成功!"));
// lblMessage.Text = "success"; } catch (Exception ex)
{ // lblMessage.Text = ex.ToString(); Page.RegisterStartupScript("back", AccessDAL.MessageBox.FN_Alert("消息提示", ex.Message.ToString()));
} }核心代码
#----- begin Chinese Simplified support package (2011-10.27)
cidToUnicode Adobe-GB1 D:\vhostroot\LocalUser\xydl6\www\xpdf\xpdf-chinese-simplified\Adobe-GB1.cidToUnicode
unicodeMap ISO-2022-CN D:\vhostroot\LocalUser\xydl6\www\xpdf\xpdf-chinese-simplified\ISO-2022-CN.unicodeMap
unicodeMap EUC-CN D:\vhostroot\LocalUser\xydl6\www\xpdf\xpdf-chinese-simplified\EUC-CN.unicodeMap
unicodeMap GBK D:\vhostroot\LocalUser\xydl6\www\xpdf\xpdf-chinese-simplified\GBK.unicodeMap
cMapDir Adobe-GB1 D:\vhostroot\LocalUser\xydl6\www\xpdf\xpdf-chinese-simplified\CMap
toUnicodeDir D:\vhostroot\LocalUser\xydl6\www\xpdf\xpdf-chinese-simplified\CMap
displayCIDFontTT Adobe-GB1 D:\vhostroot\LocalUser\xydl6\www\xpdf\xpdf-chinese-simplified\CMap\gbsn00lp.ttf
displayCIDFontTT Adobe-GB1 D:\vhostroot\LocalUser\xydl6\www\xpdf\xpdf-chinese-simplified\CMap\gkai00mp.ttf
displayCIDFontTT Adobe-GB1 D:\vhostroot\LocalUser\xydl6\www\xpdf\xpdf-chinese-simplified\CMap\STSONG.TTF
#----- end Chinese Simplified support package
哪位大虾看看啊
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);
以前做的 也是用pdf2swf做的
/// <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;
}
http://www.cnblogs.com/58top/archive/2012/11/26/a-list-of-jquery-pdf-viewers-available-at-the-moment.html