方法一:用FlexPaper实现
<head>
<title>FlexPaper</title>
<script src="FP/js/flexpaper_flash.js" type="text/javascript"></script>
</head>
<body>
<div style="position:absolute;left:10px;top:10px;">
<a id="viewerPlaceHolder" style="width:680px;height:480px;display:block"></a>
<script type="text/javascript">
var fp = new FlexPaperViewer(
'FP/FlexPaperViewer',
'viewerPlaceHolder', { config: {
SwfFile: '<%=getSWFFile() %>',
Scale: 0.75,
ZoomTransition: 'easeOut',
ZoomTime: 0.5,
ZoomInterval: 0.05,
FitPageOnLoad: false,
FitWidthOnLoad: false,
FullScreenAsMaxWindow: false,
ProgressiveLoading: true,
MinZoomSize: 0.2,
MaxZoomSize: 5,
SearchMatchAll: false,
InitViewMode: 'Portrait',
ViewModeToolsVisible: true,
ZoomToolsVisible: true,
NavToolsVisible: true,
CursorToolsVisible: false,
SearchToolsVisible: false,
localeChain: 'zh_CN'
}
});
</script>
</div>
</body>
protected string getSWFFile()
{
return "SwfFile/b.swf";
}
/// <summary>
/// 将pdf文件转化成swf文件
/// </summary>
/// <param name="SWFToolsFullPath">SWFTools转换工具路径,具体到文件,如~/FP/SWFTools/pdf2swf.exe</param>
/// <param name="SourceFilePath">pdf源文件路径,如~/SwfFile/</param>
/// <param name="SourcefileName">要转换的pdf文件名,如b.pdf</param>
/// <param name="SaveFilePath">转化成的swf文件保存路径,如~/SwfFile/</param>
private static void ConvertCmd(string SWFToolsFullPath,string SourceFilePath, string SourcefileName,string SaveFilePath)
{
using (System.Diagnostics.Process p = new System.Diagnostics.Process())
{
string cmdStr = HttpContext.Current.Server.MapPath(SWFToolsFullPath);
string sourcePath = HttpContext.Current.Server.MapPath(SourceFilePath);
string savePath = HttpContext.Current.Server.MapPath(SaveFilePath);
// @"""" 相当于一个双引号,之所以要加@"""" 就是为了防止要转换的过程中,文件夹名字带有空格,导致失败
string sourcefullPath = @"""" + sourcePath + SourcefileName + @"""";
string targetfullPath = @"""" + savePath + SourcefileName.Substring(0, SourcefileName.LastIndexOf(".")) + ".swf" + @"""";
string argsStr = " -t " + sourcefullPath + " -s flashversion=9 -o " + targetfullPath;
//调用新进程 进行转换
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(cmdStr, argsStr);
p.StartInfo = psi;
p.Start();
p.WaitForExit();
}
}
涉及到的资源另上传