【JAVA】java代码实现print2Flash转swf文件,百度文库一样。

以前用的flashpapger但是很 遗憾不支持64位机子。

改用print2Flash。

java代码如下:

import java.io.*;

import com.jacob.activeX.*;
import com.jacob.com.*;

public class TestPrint2Flash {

	public static void main(String[] args) throws java.io.IOException {
		getswf("D:\\aa.doc");
	}

	public static void getswf(String args) throws IOException {
		if (args.length() > 0) {
			try {
				ComThread.InitSTA();
				// Create Server object
				ActiveXComponent p2f = new ActiveXComponent(
						"Print2Flash3.Server");

				// Setup interface and protection options
				ActiveXComponent defProfile = new ActiveXComponent(p2f
						.getProperty("DefaultProfile").toDispatch());

				defProfile.setProperty("InterfaceOptions", P2FConst.INTDRAG
						| P2FConst.INTSELTEXT | P2FConst.INTZOOMSLIDER
						| P2FConst.INTZOOMBOX | P2FConst.INTFITWIDTH
						| P2FConst.INTFITPAGE | P2FConst.INTPREVPAGE
						| P2FConst.INTGOTOPAGE | P2FConst.INTNEXTPAGE
						| P2FConst.INTSEARCHBOX | P2FConst.INTSEARCHBUT
						| P2FConst.INTPRINT | P2FConst.INTNEWWIND
						| P2FConst.INTFULLSCREEN | P2FConst.INTFULLSCREENAUTO);
				// defProfile.setProperty("ProtectionOptions",
				// P2FConst.PROTDISPRINT | P2FConst.PROTENAPI);

				// Convert document
				System.out.println(args);

				//p2f.invoke("ConvertFile", new String(args));

				System.out.println("swf转换成功...");
			} catch (Exception e) {
				System.out.println("swf转换失败: " + e.toString());
			} finally {
				ComThread.Release();
			}
		} else
			System.out.println("转swf出错。。。。");
	}
}

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;		//系统logo
	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;//如果它可以检测Flash播放器不支持或允许使用全屏幕模式,隐藏的全屏按钮。否则,显示“全屏”按钮。


	// 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;//启用Print2Flash文件API支持(从Flash使用Print2Flash文件API的是只有部分禁用)

	// 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;

	// COMPRESSION_METHOD enumeration constants
	public static final int COMPRESSION_METHOD_ZLIB = 0;
	public static final int COMPRESSION_METHOD_LZMA = 1;
}

例子完整路径下载: http://download.csdn.net/detail/hateson/5844699

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值