浅谈print2flash的在线预览转换应用(原创)
print2flash是一种在线预览转换工具,可以将doc、docx、xls、pdf、ppt等格式的文档转换成flash文件进行预览,因为之前使用的flash2paper只支持32为操作系统,不支持64为win7,所以才考虑用print2flash。
在使用过程中遇到了很多问题,下面我将遇到的问题总结一下。
1、安装以后,进行pdf转换出现系统错误,code 1155 没有应用程序与当前的操作的文件相关联,百度以后才发现是注册表的问题,
运行regedit进入注册表,删除注册表中的
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.PDF 项,然后将以下内容保存为 REG 文件双击导入:
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\.pdf]
"Content Type"="application/pdf"
@="AcroExch.Document" [HKEY_CLASSES_ROOT\.pdf\OpenWithList]
@="" [HKEY_CLASSES_ROOT\.pdf\OpenWithList\AcroRd32.exe]
@="" [HKEY_CLASSES_ROOT\.pdf\PersistentHandler]
@="{F6594A6D-D57F-4EFD-B2C3-DCD9779E382E}" [HKEY_CLASSES_ROOT\.pdf\ShellEx] [HKEY_CLASSES_ROOT\.pdf\ShellEx\{8895b1c6-b41f-4c1c-a562-0d564250836f}]
@="{DC6EFB56-9CFA-464D-8880-44885D7DC193}" [HKEY_CLASSES_ROOT\AcroExch.Document.]
"FriendlyTypeName"="PDF 文档"
@="Adobe Acrobat Document"
"EditFlags"=hex:,,,
"BrowseInPlace"="" [HKEY_CLASSES_ROOT\AcroExch.Document.\CLSID]
@="{B801CA65-A1FC-11D0-85AD-444553540000}" [HKEY_CLASSES_ROOT\AcroExch.Document.\DefaultIcon]
@="C:\\Windows\\Installer\\{AC76BA86-7AD7-2052-7B44-A92000000001}\\PDFFile_8.ico,0" [HKEY_CLASSES_ROOT\AcroExch.Document.\Insertable]
@="" [HKEY_CLASSES_ROOT\AcroExch.Document.\protocol] [HKEY_CLASSES_ROOT\AcroExch.Document.\protocol\StdFileEditing] [HKEY_CLASSES_ROOT\AcroExch.Document.\protocol\StdFileEditing\RequestDataFormats]
@="NoteshNote" [HKEY_CLASSES_ROOT\AcroExch.Document.\protocol\StdFileEditing\server]
@="\"C:\\Program Files\\Adobe\\Reader 9.0\\Acrobat\\Acrobat.exe\"" [HKEY_CLASSES_ROOT\AcroExch.Document.\protocol\StdFileEditing\SetDataFormats]
@="NotesDocInfo" [HKEY_CLASSES_ROOT\AcroExch.Document.\protocol\StdFileEditing\verb] [HKEY_CLASSES_ROOT\AcroExch.Document.\protocol\StdFileEditing\verb\]
@="&Open" [HKEY_CLASSES_ROOT\AcroExch.Document.\shell]
@="Read" [HKEY_CLASSES_ROOT\AcroExch.Document.\shell\Open] [HKEY_CLASSES_ROOT\AcroExch.Document.\shell\Open\command]
@="\"C:\\Program Files\\Adobe\\Reader 9.0\\Reader\\AcroRd32.exe\" \"%1\"" [HKEY_CLASSES_ROOT\AcroExch.Document.\shell\Print] [HKEY_CLASSES_ROOT\AcroExch.Document.\shell\Print\command]
@="\"C:\\Program Files\\Adobe\\Reader 9.0\\Reader\\AcroRd32.exe\" /p /h \"%1\"" [HKEY_CLASSES_ROOT\AcroExch.Document.\shell\Printto] [HKEY_CLASSES_ROOT\AcroExch.Document.\shell\Printto\command]
@="\"C:\\Program Files\\Adobe\\Reader 9.0\\Reader\\AcroRd32.exe\" /t \"%1\" \"%2\" \"%3\" \"%4\"" [HKEY_CLASSES_ROOT\AcroExch.Document.\shell\Read]
@="使用 Adobe Reader 9 打开" [HKEY_CLASSES_ROOT\AcroExch.Document.\shell\Read\command]
@="\"C:\\Program Files\\Adobe\\Reader 9.0\\Reader\\AcroRd32.exe\" \"%1\"" [HKEY_CLASSES_ROOT\AcroExch.Document.\Shellex] [HKEY_CLASSES_ROOT\AcroExch.Document.\Shellex\PropertySheetHandlers]
@="InfoPage" [HKEY_CLASSES_ROOT\AcroExch.Document.\Shellex\PropertySheetHandlers\InfoPage]
@="{F9DB5320-233E-11D1-9F84-707F02C10627}" [HKEY_CLASSES_ROOT\AcroExch.Document.\Shellex\{BB2E617C--11d1-9A0B-00C04FC2D6C1}]
@="{F9DB5320-233E-11D1-9F84-707F02C10627}" [HKEY_CLASSES_ROOT\AcroExch.Document]
"FriendlyTypeName"="PDF 文档"
"EditFlags"=hex:,,,
"BrowseInPlace"=""
@="Adobe Acrobat Document" [HKEY_CLASSES_ROOT\AcroExch.Document\CLSID]
@="{B801CA65-A1FC-11D0-85AD-444553540000}" [HKEY_CLASSES_ROOT\AcroExch.Document\CurVer]
@="AcroExch.Document.7" [HKEY_CLASSES_ROOT\AcroExch.Document\DefaultIcon]
@="C:\\Windows\\Installer\\{AC76BA86-7AD7-2052-7B44-A92000000001}\\PDFFile_8.ico,0" [HKEY_CLASSES_ROOT\AcroExch.Document\Shell] [HKEY_CLASSES_ROOT\AcroExch.Document\Shell\open] [HKEY_CLASSES_ROOT\AcroExch.Document\Shell\open\Command]
@="\"C:\\Program Files\\Adobe\\Reader 9.0\\Reader\\AcroRd32.exe\" \"%1\""
问题搞定。
2、关于引用dll的问题
这里要将jawin.dll添加到java.library.path中,至于如何添加请百度我就不详细说了。
3、在工程项目中添加jawin.jar包。
4、写测试类TestPrint2Flash
import java.io.*;
import org.jawin.DispatchPtr;
import org.jawin.win32.Ole32;
public class TestPrint2Flash{ public static void main(String[] args) throws java.io.IOException{
getswf("F:\\自己动手写网络爬虫.pdf");
}
public static void getswf(String args) throws IOException{
if (args.length() > 0){
try{
Ole32.CoInitialize();
// Create Server object
DispatchPtr p2f = new DispatchPtr("Print2Flash3.Server"); // Setup interface and protection options
//DispatchPtr defProfile = (DispatchPtr)p2f.get("DefaultProfile");
DispatchPtr DefBPOpt = (DispatchPtr)p2f.get("DefaultBatchProcessingOptions");
//p2f.invoke("SetP2FPrinterAsDefault");
//defProfile.put("ApplicationType", P2FConst.MSEXCEL|P2FConst.MSPOWERPOINT|P2FConst.MSWORD|P2FConst.ACROBAT);
//defProfile.put("InterfaceOptions",P2FConst.INTLOGO | P2FConst.INTZOOMSLIDER | P2FConst.INTPREVPAGE | P2FConst.INTGOTOPAGE | P2FConst.INTNEXTPAGE);
//DefBPOpt.put("ProtectionOptions", P2FConst.PROTDISPRINT | P2FConst.PROTENAPI);
DefBPOpt.put("BeforePrintingTimeout", 6000);
DefBPOpt.put("PrintingTimeout", 60000);
DefBPOpt.put("KeepAutomationAppRef",P2FConst.MSEXCEL|P2FConst.MSPOWERPOINT|P2FConst.MSWORD|P2FConst.ACROBAT);
DefBPOpt.put("KillAllAutomationProcesses",2 );
DefBPOpt.invoke("ApplyChanges");
// Convert document
p2f.invoke("ConvertFile", new String(args));
System.out.println("Conversion completed successfully");
}catch (Exception e){
System.out.println("An error occurred at conversion: "+e.toString());
}finally{
try {
Ole32.CoUninitialize();
}catch (Exception e){ }
}
}else{
System.out.println("Please provide a document file name as a parameter");
System.out.println("Press Enter to exit...");
System.in.read(); }
}
定义常量
(可能定义的常量与测试代码中的有出入不过不影响使用,这些常量可以查询API帮助文档)
 public class P2FConst {
  // APPLICATIONTYPE enumeration constants
  public static final int MSEXCEL = 0x00000001;
  public static final int MSWORD = 0x00000002;
  public static final int MSPOWERPOINT = 0x00000004;
  public static final int ACROBAT = 0x00000008;
  // IMAGEFORMAT enumeration constants
  public static final int JPEG = 1;
  public static final int PNG = 2;
  // IMGBEHAVIOR enumeration constants
  public static final int STRETCH = 1;
  public static final int TILE = 2;
  // INTERFACE_OPTION enumeration constants
  public static final int INTLOGO = 0x00000001;
  public static final int INTDRAG = 0x00000002;
  public static final int INTSELTEXT = 0x00000004;
  public static final int INTZOOMSLIDER = 0x00000008;
  public static final int INTZOOMBOX = 0x00000010;
  public static final int INTFITWIDTH = 0x00000020;
  public static final int INTFITPAGE = 0x00000040;
  public static final int INTPREVPAGE = 0x00000080;
  public static final int INTGOTOPAGE = 0x00000100;
  public static final int INTNEXTPAGE = 0x00000200;
  public static final int INTSEARCHBOX = 0x00000400;
  public static final int INTSEARCHBUT = 0x00000800;
  public static final int INTROTATE = 0x00001000;
  public static final int INTPRINT = 0x00002000;
  public static final int INTNEWWIND = 0x00004000;
  public static final int INTHELP = 0x00008000;
  public static final int INTBACKBUTTON = 0x00030000;
  public static final int INTBACKBUTTONAUTO = 0x00010000;
  public static final int INTFORWARDBUTTON = 0x000C0000;
  public static final int INTFORWARDBUTTONAUTO = 0x00040000;
  public static final int INTFULLSCREEN = 0x00300000;
  public static final int INTFULLSCREENAUTO = 0x00100000;
  // METADATAPORMAT enumeration constants
  public static final int XML = 1;
  public static final int TEXT = 2;
  // OUTPUTFORMAT enumeration constants
  public static final int SINGLEFILE = 1;
  public static final int SINGLEFILEPERPAGE = 2;
  public static final int EXTVIEWER = 4;
  // PAPER_ORIENTATION enumeration constants
  public static final int ORIENT_PORTRAIT = 1;
  public static final int ORIENT_LANDSCAPE = 2;
  // PROTECTION_OPTION enumeration constants
  public static final int PROTDISPRINT = 0x00000001;
  public static final int PROTDISTEXTCOPY = 0x00000002;
  public static final int PROTENAPI = 0x00000004;
  // ThreeStateFlag enumeration constants
  public static final int TSF_NO = 0;
  public static final int TSF_YES = 1;
  public static final int TSF_AUTO = 2;
  // TOOLBARIMAGE enumeration constants
  public static final int IMGLOGO = 1;
  public static final int IMGDRAG = 2;
  public static final int IMGSELTEXT = 3;
  public static final int IMGZOOMRULER = 4;
  public static final int IMGZOOMFOCUSNADLE = 5;
  public static final int IMGZOOMNADLE = 6;
  public static final int IMGFITWIDTH = 7;
  public static final int IMGFITPAGE = 8;
  public static final int IMGPREVPAGE = 9;
  public static final int IMGNEXTPAGE = 10;
  public static final int IMGSEARCHBUT = 11;
  public static final int IMGROTATE = 12;
  public static final int IMGPRINT = 13;
  public static final int IMGNEWWIND = 14;
  public static final int IMGHELP = 15;
  public static final int IMGMORE = 16;
  public static final int IMGTOOLBARBGR = 17;
  public static final int IMGBACK = 18;
  public static final int IMGFORWARD = 19;
  public static final int IMGFULLSCREEN = 20;
  public static final int IMGEXITFULLSCREEN = 21;
  // TEMPLATETYPE enumeration constants
  public static final int TEMPLATE_CUSTOM = 1;
  public static final int TEMPLATE_ACTIONSCRIPT2 = 2;
  public static final int TEMPLATE_ACTIONSCRIPT3 = 3;
  // WATERMARKANCHOR enumeration constants
  public static final int CENTER = 0;
  public static final int LEFTCENTER = 1;
  public static final int RIGHTCENTER = 2;
  public static final int TOPCENTER = 16;
  public static final int BOTTOMCENTER = 32;
  public static final int LEFTTOP = 17;
  public static final int RIGHTTOP = 18;
  public static final int LEFTBOTTOM = 33;
  public static final int RIGHTBOTTOM = 34;
 }
5、定制自己想要的转换功能
这一点可以查看安装后的帮助文档,虽然是英文的,但是仔细看一看就能弄明白,API写的非常清楚
浅谈print2flash的在线预览转换应用(原创)的更多相关文章
- 浅谈js本地图片预览
		
最近在工作中遇到一个问题,就是实现一个反馈页面,这个反馈页面的元素有反馈主题.反馈类型.反馈内容.反馈人联系电话以及反馈图片.前端将这些反馈的元素POST给后台提供的接口:实现这个工作的步骤就是:页面 ...
 - Print2flash在.NET(C#)中的使用,即文档在线预览
		
office文档(word,excel,ppt)在线预览查看,有很多种方式,比如可以 1.调用weboffice组件,进行word预览,要求客户端安装word,仅适用IE, word2013, IE1 ...
 - Print2flash在.NET(C#)64位中的使用,即文档在线预览
		
转:http://www.cnblogs.com/flowwind/p/3411106.html Print2flash在.NET(C#)中的使用,即文档在线预览 office文档(word,ex ...
 - 在线预览-Java 使用 Print2Flash 实现Office文档在线阅读
		
近期项目上遇到一个需求是用户上传的文档进行在线浏览,之前有过一篇使用 OpenOffice 将 word 转换成 html 页面进行展示的.现在介绍一个新的工具那就是 Print2Flash . ...
 - 实战动态PDF在线预览及带签名的PDF文件转换
		
开篇语: 最近工作需要做一个借款合同,公司以前的合同都是通过app端下载,然后通过本地打开pdf文件,而喜欢创新的我,心想着为什么不能在线H5预览,正是这个想法,说干就干,实践过程总是艰难的,折腾了3 ...
 - Atitit.office word  excel  ppt pdf 的web在线预览方案与html转换方案 attilax 总结
		
Atitit.office word excel ppt pdf 的web在线预览方案与html转换方案 attilax 总结 1. office word excel pdf 的web预览要求 ...
 - 文件在线预览doc,docx转换pdf(一)
		
文件在线预览doc,docx转换pdf(一) 1. 前言 文档转换是一个是一块硬骨头,但是也是必不可少的,我们正好做的知识库产品中,也面临着同样的问题,文档转换,精准的全文搜索,知识的转换率,是知识库 ...
 - [Asp.net]使用flexpaper+swftools大文件分页转换实现在线预览
		
引言 之前总结了在线预览几种常见解决方案,可以戳这里: http://www.cnblogs.com/wolf-sun/p/3569960.html http://www.cnblogs.com/wo ...
 - Office在线预览及PDF在线预览的实现方式史上最全大集合
		
Office在线预览及PDF在线预览的实现方式大集合 一.服务器先转换为PDF,再转换为SWF,最后通过网页加载Flash预览 微软方:利用Office2007以上版本的一个PDF插件SaveAsPD ...
 
随机推荐
- Bootstrap 简洁、直观、强悍、移动设备优先的前端开发框架,让web开发更迅速、简单。
			
http://v3.bootcss.com/ 从2.x升级到3.0版本 Bootstrap 3并不向后兼容Bootstrap v2.x.下面章节列出的内容可以作为从v2.x升级到v3.0的通用指南.如 ...
 - android 中动画
			
详解Android动画之Frame Animation 写出动画效果的xml文件布局基本代码如下: <?xml version="1.0" encoding="ut ...
 - 【巧妙】【3-21个人赛】Problem C 01串
			
Problem C Time Limit : 3000/1000ms (Java/Other) Memory Limit : 65535/32768K (Java/Other) Total Sub ...
 - netty demo
			
Netty 4.0 demo netty是一个异步,事件驱动的网络编程框架&工具,使用netty,可以快速开发从可维护,高性能的协议服务和客户端应用.是一个继mina之后,一个非常受欢迎的 ...
 - C# 用模板生成静态页
			
最近在研究静态页输出的问题,找了一些资料.做了一个简单的模板模式的静态输出 模板代码: <html xmlns="http://www.w3.org/1999/xhtml"& ...
 - JavaScript检测之basevalidate.js
			
上篇文章「JavaScript检测原始值.引用值.属性」中涉及了大量有用的代码范例,为了让大家更方便的使用这些代码,博主特意把这些代码重新整理并托管到 GitHub,项目地址是:https://git ...
 - Knime 使用 初探
			
使用数据挖掘工具 Knime,分析某公司用户使用情况. 首先,打开csv文件数据,看到有以下门类: 时间.track id 歌曲名.用户行为.用户id.日期.snap_id 即歌曲门类 然后,打开Kn ...
 - sqlserver 2008 局域网跨服务器T-SQL操作(一)
			
--查看当前链接情况: select * from sys.servers; --增加链接,参数:服务器别名,为链接服务器的OLE DB数据源的产品名称,与此数据源对应的OLE DB访问接口的唯一编程 ...
 - java接口的理解
			
接口的最主要的作用是达到统一访问,就是在创建对象的时候用接口创建,[接口名] [对象名]=new [实现接口的类],这样你像用哪个类的对象就可以new哪个对象了,不需要改原来的代码,就和你的USB接口 ...
 - laravel的模块化是如何实现的
			
laravel的模块化是如何实现的 在laravel提供的官方文档上,有一个这样的名词 服务提供者,文档中介绍了它在laravel框架中的角色,以及如何使用它,但却没有讲明服务提供者的本质--它是为了 ...