有些时候我们要在IE上显示一个PDF, 例如服务器上生成的PDF. 但是不想让用户保存下来.
本质上来说这是实现不了的, 因为显示PDF用的是客户端的acrobat的ActiveX控件.
既然数据已经到了客户端, 想要找到数据的内容总是可以找到的.
下面提供一种方法, 可以把acrobat控件的工具栏隐藏起来.让用户不那么容易把PDF保存下来.
<html>
<head>
<title>viewpdf</title>
<script language="vbscript">
<!--
Sub window_onload()
acro.setShowToolbar(False)
end sub
Sub printAll()
acro.printAll()
end sub
-->
</script>
</head>
<body onload="window_onload()">
<button onclick="printAll()">印刷</button></br>
<OBJECT id="acro" classid="clsid:CA8A9780-280D-11CF-A24D-444553540000" WIDTH="1000" HEIGHT="800">
<PARAM name="src" value="./304100621001JY01802-0-01.pdf"/>
</OBJECT>
</body>
</html>
原理就是直接调用ActiveX控件中的方法把工具栏隐藏起来, 打印也是调用ActiveX的方法.
那么具体的AcrobatReader的ActiveX中还有哪些其他的方法吗?
由于没有文档, 只能用OleView看一下. 具体怎么我用也不清楚.
[
uuid(3B813CE7-7C10-4F84-AD06-9DF76D97A9AA),
helpstring("IAcroAXDocShim Interface"),
dual,
nonextensible
]
dispinterface IAcroAXDocShim {
properties:
methods:
[id(0x00000001), propget, helpstring("property src")]
BSTR src();
[id(0x00000001), propput, helpstring("property src")]
void src([in] BSTR rhs);
[id(0x00000002), helpstring("method LoadFile")]
VARIANT_BOOL LoadFile([in] BSTR fileName);
[id(0x00000003), helpstring("method setShowToolbar")]
void setShowToolbar([in] VARIANT_BOOL On);
[id(0x00000004), helpstring("method gotoFirstPage")]
void gotoFirstPage();
[id(0x00000005), helpstring("method gotoLastPage")]
void gotoLastPage();
[id(0x00000006), helpstring("method gotoNextPage")]
void gotoNextPage();
[id(0x00000007), helpstring("method gotoPreviousPage")]
void gotoPreviousPage();
[id(0x00000008), helpstring("method setCurrentPage")]
void setCurrentPage([in] long n);
[id(0x00000009), helpstring("method goForwardStack")]
void goForwardStack();
[id(0x0000000a), helpstring("method goBackwardStack")]
void goBackwardStack();
[id(0x0000000b), helpstring("method setPageMode")]
void setPageMode([in] BSTR pageMode);
[id(0x0000000c), helpstring("method setLayoutMode")]
void setLayoutMode([in] BSTR layoutMode);
[id(0x0000000d), helpstring("method setNamedDest")]
void setNamedDest([in] BSTR namedDest);
[id(0x0000000e), helpstring("method Print")]
void Print();
[id(0x0000000f), helpstring("method printWithDialog")]
void printWithDialog();
[id(0x00000010), helpstring("method setZoom")]
void setZoom([in] single percent);
[id(0x00000011), helpstring("method setZoomScroll")]
void setZoomScroll(
[in] single percent,
[in] single left,
[in] single top);
[id(0x00000012), helpstring("method setView")]
void setView([in] BSTR viewMode);
[id(0x00000013), helpstring("method setViewScroll")]
void setViewScroll(
[in] BSTR viewMode,
[in] single offset);
[id(0x00000014), helpstring("method setViewRect")]
void setViewRect(
[in] single left,
[in] single top,
[in] single width,
[in] single height);
[id(0x00000015), helpstring("method printPages")]
void printPages(
[in] long from,
[in] long to);
[id(0x00000016), helpstring("method printPagesFit")]
void printPagesFit(
[in] long from,
[in] long to,
[in] VARIANT_BOOL shrinkToFit);
[id(0x00000017), helpstring("method printAll")]
void printAll();
[id(0x00000018), helpstring("method printAllFit")]
void printAllFit([in] VARIANT_BOOL shrinkToFit);
[id(0x00000019), helpstring("method setShowScrollbars")]
void setShowScrollbars([in] VARIANT_BOOL On);
[id(0x0000001a), helpstring("method GetVersions")]
VARIANT GetVersions();
[id(0x0000001b), helpstring("method setCurrentHightlight")]
void setCurrentHightlight(
[in] long a,
[in] long b,
[in] long c,
[in] long d);
[id(0x0000001c), helpstring("method setCurrentHighlight")]
void setCurrentHighlight(
[in] long a,
[in] long b,
[in] long c,
[in] long d);
[id(0x0000001d), helpstring("method postMesage")]
void postMessage([in] VARIANT strArray);
[id(0x0000001e), propget, helpstring("property messageHandler")]
VARIANT messageHandler();
[id(0x0000001e), propput, helpstring("property messageHandler")]
void messageHandler([in] VARIANT rhs);
[id(0x0000001f), helpstring("method execCommand")]
void execCommand([in] VARIANT strArray);
};