return pages;
},
+ createThumbnail: function(num) {
+ if (PDFViewer.sidebarContentView) {
+ var anchor = document.createElement('a');
+ anchor.href = '#' + num;
+
+ var containerDiv = document.createElement('div');
+ containerDiv.id = 'thumbnailContainer' + num;
+ containerDiv.className = 'thumbnail';
+
+ var pageNumberDiv = document.createElement('div');
+ pageNumberDiv.className = 'thumbnailPageNumber';
+ pageNumberDiv.innerHTML = '' + num;
+
+ anchor.appendChild(containerDiv);
+ PDFViewer.sidebarContentView.appendChild(anchor);
+ PDFViewer.sidebarContentView.appendChild(pageNumberDiv);
+ }
+ },
+
+ removeThumbnail: function(num) {
+ var div = document.getElementById('thumbnailContainer' + num);
+
+ if (div) {
+ while (div.hasChildNodes()) {
+ div.removeChild(div.firstChild);
+ }
+ }
+ },
+
+ drawThumbnail: function(num) {
+ if (!PDFViewer.pdf)
+ return;
+
+ var div = document.getElementById('thumbnailContainer' + num);
+
+ if (div && !div.hasChildNodes()) {
+ var page = PDFViewer.pdf.getPage(num);
+ var canvas = document.createElement('canvas');
+
+ canvas.id = 'thumbnail' + num;
+ canvas.mozOpaque = true;
+
+ // Canvas dimensions must be specified in CSS pixels. CSS pixels
+ // are always 96 dpi. These dimensions are 8.5in x 11in at 96dpi.
+ canvas.width = 104;
+ canvas.height = 134;
+ div.appendChild(canvas);
+
+ var ctx = canvas.getContext('2d');
+ ctx.save();
+ ctx.fillStyle = 'rgb(255, 255, 255)';
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
+ ctx.restore();
+
+ var gfx = new CanvasGraphics(ctx);
+
+ // page.compile will collect all fonts for us, once we have loaded them
+ // we can trigger the actual page rendering with page.display
+ var fonts = [];
+ page.compile(gfx, fonts);
+
+ var loadFont = function() {
+ if (!FontLoader.bind(fonts)) {
+ pageTimeout = window.setTimeout(loadFont, 10);
+ return;
+ }
+ page.display(gfx);
+ }
+ loadFont();
+ }
+ },
+
createPage: function(num) {
+ var page = PDFViewer.pdf.getPage(num);
+
var anchor = document.createElement('a');
anchor.name = '' + num;