Skip to main content
  1. Home
  2. Singapore
  3. Singapore

Jquery — Pdf Viewer

$('#next-page').click(function() if (currentPage < totalPages) currentPage++; renderPage(currentPage); );

<!DOCTYPE html> <html> <head> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.16.105/pdf.min.js"></script> <style> .pdf-toolbar background: #f0f0f0; padding: 10px; margin-bottom: 10px; border-radius: 5px; .pdf-toolbar button, .pdf-toolbar input margin: 0 5px; padding: 5px 10px; #pdf-canvas box-shadow: 0 0 10px rgba(0,0,0,0.1); margin: 20px auto; display: block; .page-info display: inline-block; margin: 0 15px; </style> </head> <body> <div class="pdf-toolbar"> <button id="zoom-in">Zoom In</button> <button id="zoom-out">Zoom Out</button> <span>Scale: <span id="scale-value">100</span>%</span> <button id="rotate-left">Rotate Left</button> <button id="rotate-right">Rotate Right</button> <button id="prev-page">◀ Prev</button> <span class="page-info"> Page <input type="number" id="page-input" min="1" style="width: 50px;"> of <span id="total-pages">0</span> </span> <button id="next-page">Next ▶</button> <input type="file" id="pdf-upload" accept=".pdf"> </div> <canvas id="pdf-canvas"></canvas> <script> $(document).ready(function() let pdfDoc = null; let currentPage = 1; let totalPages = 0; let scale = 1.5; let rotation = 0; const canvas = $('#pdf-canvas')[0]; let ctx = canvas.getContext('2d'); jquery pdf viewer

// Zoom controls $('#zoom-in').click(function() if (scale < 3) scale += 0.25; renderPage(); ); $('#zoom-out').click(function() if (scale > 0.5) scale -= 0.25; renderPage(); ); // Rotation controls $('#rotate-left').click(function() rotation = (rotation - 90) % 360; renderPage(); ); $('#rotate-right').click(function() rotation = (rotation + 90) % 360; renderPage(); ); // Page navigation $('#prev-page').click(function() if (currentPage > 1) currentPage--; renderPage(); ); $('#next-page').click(function() if (currentPage < totalPages) currentPage++; renderPage(); ); $('#page-input').change(function() let page = parseInt($(this).val()); if (page >= 1 && page <= totalPages) currentPage = page; renderPage(); else $(this).val(currentPage); ); // File upload $('#pdf-upload').change(function(e) const file = e.target.files[0]; if (file && file.type === 'application/pdf') const reader = new FileReader(); reader.onload = function(e) const typedarray = new Uint8Array(e.target.result); pdfjsLib.getDocument(typedarray).promise.then(function(pdf) pdfDoc = pdf; totalPages = pdf.numPages; currentPage = 1; scale = 1.5; rotation = 0; renderPage(); ); ; reader.readAsArrayBuffer(file); ); // Load default PDF if exists if ($('#default-pdf').length) loadPDF('default.pdf'); ); </script> </body> </html> Free but requires internet and has limitations. $('#next-page')

<script> $(document).ready(function() $('.pdf-viewer').media( width: '800px', height: '600px', src: 'document.pdf', type: 'pdf' ); ); </script> Enhanced PDF.js implementation with more features. $('#next-page').click(function() if (currentPage &lt

const renderContext = canvasContext: ctx, viewport: viewport ; page.render(renderContext); $('#page-num').text(pageNum); );

Discover
OpenTable
  • About Us
  • Blog
  • Careers
  • Press
More
Businesses
  • OpenTable For Restaurants
  • OpenTable Pricing & Plans
  • OpenTable Support
Join us on
  • Privacy policy
  • Terms of Use
  • Cookies and Interest-Based Ads
  • Accessibility Statement
  • Cookie Preferences
Copyright © 2025 OpenTable Australia Level 22, 357 Collins Street, Melbourne, Victoria
OpenTable is part of Booking Holdings, the world leader in online travel and related services.
Booking Logo
Priceline Logo
KAYAK Logo
Agoda Logo
OpenTable Logo