I would like to open a pdf file and show particular page when I press on a button
What I have tried inside an onclick listener is :
$("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>")
The problem is , it seems it can not ref to and just show the page 1, also , the size of pdf is not zoom as expected. e.g. the div is the exact size but the content is not. e.g. If I specific size = w:1000, h:2000, the background : w:1000,h:2000 , but the content may be w:800,h:1500.
How can
I fix the problems ? thanks
If you know the page number to go to, and your PDF plugin is the one which comes with Adobe Acrobat Reader, you could do this:
largePdf.setCurrentPage(n);
The API is described here.
Below is a short list of APIs obtained with OleView on AcroPdf.dll (the plugin, "C:\Program Files (x86)\Common Files\Adobe\Acrobat\ActiveX\AcroPDF.dll" on my PC). It doesn't look like there is a way to find the total number of pages though.
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);
};