<?php
$this->load->library('Browser');
$this->load->library('user_agent');
// Example usage of the modified platform method
$platform = $this->agent->platform();
$browser = new Browser();
if( $browser->getBrowser() == Browser::PLATFORM_IPAD OR $browser->getBrowser() == Browser::PLATFORM_IPHONE OR $platform=='Mac OS X' OR $platform=='This iOS Platform' ) {
?>
<script type="module">
// If absolute URL from the remote server is provided, configure the CORS
// header on that server.
var url = '<?php echo base_url();?>File_document/<?php echo $row['Send_file'];?>';
// Loaded via <script> tag, create shortcut to access PDF.js exports.
var { pdfjsLib } = globalThis;
// The workerSrc property shall be specified.
pdfjsLib.GlobalWorkerOptions.workerSrc = '<?php echo base_url();?>assets/js/pdfjs/build/pdf.worker.mjs';
/**
* Get page info from document, resize canvas accordingly, and render page.
* @param num Page number.
*/
function renderPage(num) {
pageRendering = true;
// Using promise to fetch the page
pdfDoc.getPage(num).then(function(page) {
var viewport = page.getViewport({scale: scale});
canvas.height = viewport.height;
canvas.width = viewport.width;
// Render PDF page into canvas context
var renderContext = {
canvasContext: ctx,
viewport: viewport,
background: 'rgba(0,0,0,0)'
};
var renderTask = page.render(renderContext);
// Wait for rendering to finish
renderTask.promise.then(function() {
pageRendering = false;
if (pageNumPending !== null) {
// New page rendering is pending
renderPage(pageNumPending);
pageNumPending = null;
}
});
});
/**
* If another page rendering in progress, waits until the rendering is
* finised. Otherwise, executes rendering immediately.
*/
function queueRenderPage(num) {
if (pageRendering) {
pageNumPending = num;
} else {
renderPage(num);
}
}
function slideToNextPage() {
if (currentPage < pdfDoc.numPages) {
currentPage++;
slidePage(currentPage);
}
}
function slideToPrevPage() {
if (currentPage > 1) {
currentPage--;
slidePage(currentPage);
}
}