Once PDF.JS has completed rendered each page, I want to then do a find/replace on the contents of that page.
I invoke PDF.JS by putting the following in a document in an iFrame:
<script>
fileId=0;
function getURLParameter(name) {
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null
}
var fileId = getURLParameter("fileId");
var DEFAULT_URL = '/viewer/fetchpdf.php?fileId='+fileId;
</script>
and then setting the URL from the parent frame:
url = '/_third_party/pdfjs/web/viewer.html?fileId='+$(this).attr('href');
$("#iframeViewPdf").attr('src', url);
I've noticed when using PDF.JS to render a PDF, it initialises each page with a loading placeholder:
<div id="pageContainer3" class="page" style="width: 991px; height: 1319px;">
<div class="loadingIcon"></div>
</div>
<div id="pageContainer4...
It then renders the PDF as html, e.g.
<div id="pageContainer3" class="page" style="width: 991px; height: 1319px;">
<div class="canvasWrapper" style="width: 991px; height: 1319px;">
<canvas id="page46" width="991" height="1319" style="width: 991px; height: 1319px;">
</canvas>
</div>
<div class="textLayer" style="width: 991px; height: 1319px;">
...
</div>
</div>
<div id="pageContainer4...
Aucun commentaire:
Enregistrer un commentaire