0

当我按下按钮时,我想打开一个 pdf 文件并显示特定页面

我在 onclick 监听器中尝试的是:

$("body").prepend("<object id='largePdf' data= '" + sourceFolder + "MyNews/2013/08/16/0/0/A/Content/1/A_ALL.pdf#page=1' type='application/pdf' width='1861' height='3061'>alt : <a href= '" + sourceFolder + "MyNews/2013/08/16/0/0/A/Content/1/A_ALL.pdf#page=1'>pg001.pdf</a></object>")

问题是,它似乎无法引用并仅显示第 1 页,而且 pdf 的大小也没有按预期缩放。例如, div 是确切的大小,但内容不是。例如,如果我具体尺寸 = w:1000, h:2000,背景:w:1000,h:2000,但内容可能是 w:800,h:1500。

我该如何解决这些问题?谢谢

4

1 回答 1

2

如果您知道要访问的页码,并且您的 PDF 插件是 Adob​​e Acrobat Reader 附带的插件,您可以这样做:

largePdf.setCurrentPage(n);

此处描述了 API

下面是在 AcroPdf.dll 上使用OleView获得的 API 的简短列表(我的 PC 上的插件“C:\Program Files (x86)\Common Files\Adobe\Acrobat\ActiveX\AcroPDF.dll”)。看起来好像没有办法找到总页数。

interface IAcroAXDocShim : IDispatch {
    [id(0x00000001), propget, helpstring("property src")]
    HRESULT src([out, retval] BSTR* pVal);
    [id(0x00000001), propput, helpstring("property src")]
    HRESULT src([in] BSTR pVal);
    [id(0x00000002), helpstring("method LoadFile")]
    HRESULT LoadFile(
                    [in] BSTR fileName, 
                    [out, retval] VARIANT_BOOL* ret);
    [id(0x00000003), helpstring("method setShowToolbar")]
    HRESULT setShowToolbar([in] VARIANT_BOOL On);
    [id(0x00000004), helpstring("method gotoFirstPage")]
    HRESULT gotoFirstPage();
    [id(0x00000005), helpstring("method gotoLastPage")]
    HRESULT gotoLastPage();
    [id(0x00000006), helpstring("method gotoNextPage")]
    HRESULT gotoNextPage();
    [id(0x00000007), helpstring("method gotoPreviousPage")]
    HRESULT gotoPreviousPage();
    [id(0x00000008), helpstring("method setCurrentPage")]
    HRESULT setCurrentPage([in] long n);
    [id(0x00000009), helpstring("method goForwardStack")]
    HRESULT goForwardStack();
    [id(0x0000000a), helpstring("method goBackwardStack")]
    HRESULT goBackwardStack();
    [id(0x0000000b), helpstring("method setPageMode")]
    HRESULT setPageMode([in] BSTR pageMode);
    [id(0x0000000c), helpstring("method setLayoutMode")]
    HRESULT setLayoutMode([in] BSTR layoutMode);
    [id(0x0000000d), helpstring("method setNamedDest")]
    HRESULT setNamedDest([in] BSTR namedDest);
    [id(0x0000000e), helpstring("method Print")]
    HRESULT Print();
    [id(0x0000000f), helpstring("method printWithDialog")]
    HRESULT printWithDialog();
    [id(0x00000010), helpstring("method setZoom")]
    HRESULT setZoom([in] single percent);
    [id(0x00000011), helpstring("method setZoomScroll")]
    HRESULT setZoomScroll(
                    [in] single percent, 
                    [in] single left, 
                    [in] single top);
    [id(0x00000012), helpstring("method setView")]
    HRESULT setView([in] BSTR viewMode);
    [id(0x00000013), helpstring("method setViewScroll")]
    HRESULT setViewScroll(
                    [in] BSTR viewMode, 
                    [in] single offset);
    [id(0x00000014), helpstring("method setViewRect")]
    HRESULT setViewRect(
                    [in] single left, 
                    [in] single top, 
                    [in] single width, 
                    [in] single height);
    [id(0x00000015), helpstring("method printPages")]
    HRESULT printPages(
                    [in] long from, 
                    [in] long to);
    [id(0x00000016), helpstring("method printPagesFit")]
    HRESULT printPagesFit(
                    [in] long from, 
                    [in] long to, 
                    [in] VARIANT_BOOL shrinkToFit);
    [id(0x00000017), helpstring("method printAll")]
    HRESULT printAll();
    [id(0x00000018), helpstring("method printAllFit")]
    HRESULT printAllFit([in] VARIANT_BOOL shrinkToFit);
    [id(0x00000019), helpstring("method setShowScrollbars")]
    HRESULT setShowScrollbars([in] VARIANT_BOOL On);
    [id(0x0000001a), helpstring("method GetVersions")]
    HRESULT GetVersions([out, retval] VARIANT* ret);
    [id(0x0000001b), helpstring("method setCurrentHightlight")]
    HRESULT setCurrentHightlight(
                    [in] long a, 
                    [in] long b, 
                    [in] long c, 
                    [in] long d);
    [id(0x0000001c), helpstring("method setCurrentHighlight")]
    HRESULT setCurrentHighlight(
                    [in] long a, 
                    [in] long b, 
                    [in] long c, 
                    [in] long d);
    [id(0x0000001d), helpstring("method postMesage")]
    HRESULT postMessage([in] VARIANT strArray);
    [id(0x0000001e), propget, helpstring("property messageHandler")]
    HRESULT messageHandler([out, retval] VARIANT* pVarOut);
    [id(0x0000001e), propput, helpstring("property messageHandler")]
    HRESULT messageHandler([in] VARIANT pVarOut);
    [id(0x0000001f), helpstring("method execCommand")]
    HRESULT execCommand([in] VARIANT strArray);
};
于 2013-08-19T04:59:12.003 回答