as we all know pdfium is now part of chrome, and this is a nice pdf render, but i am confronted with some problem.
the code is as follows, the default page is 12 as sepcified by the #page=12 assignment, when this page is opened, i could jump or navigate to other pages, but how to get the page number using javascript? is there any js api i can use to the get the page number?
<head>
<style type="text/css">
.pdf {
width: 100%;
height: 99%;
}
</style>
</head>
<div>
okok
</div>
<iframe class="pdf" src="http://127.0.0.1/test.pdf#page=12" frameborder="0"></iframe>
I was finding the JS API too.
On
http://src.chromium.org/viewvc/chrome/trunk/src/pdf/instance.cc
there are the following methods if someone need it:
object accessibility()
bool documentLoadComplete()
number getHeight()
number getHorizontalScrollbarThickness()
string getPageLocationNormalized()
number getVerticalScrollbarThickness()
number getWidth()
double getZoomLevel()
void goToPage(int arg)
void grayscale(bool arg)
void loadPreviewPage(string arg0, int arg1)
void onload(function arg)
void onPluginSizeChanged(function arg)
void onScroll(function arg)
number pageXOffset()
number pageYOffset()
void printPreviewPageCount(int arg)
void reload()
void removePrintButton()
void resetPrintPreviewUrl(string arg)
void sendKeyEvent(number arg)
void setPageNumbers(string arg)
void setPageXOffset(number arg)
void setPageYOffset(number arg)
void setZoomLevel(double arg)
void fitToHeight()
void fitToWidth()
void zoomIn()
void zoomOut()
void print()
an example to get the current page is like that
<html>
<head>
<script type='text/javascript'>
window.addEventListener('load', function(){
var embed = document.getElementsByName('plugin')[0];
// this method should return the page location (not the page number, i suppose that made some calculation on the portion of PDF that is showed in the embed window)
alert(embed.getPageLocationNormalized());
// we can use other api methods
embed.removePrintButton();
}, false);
</script>
</head>
<body marginwidth='0' marginheight='0' style='background-color: rgb(38,38,38)' width='100%' height='100%'>
<embed width='100%' height='100%' name='plugin' src='path_to_pdf_file' type='application/pdf' />
</body>
</html>