Created
October 12, 2011 07:33
-
-
Save deanhume/1280538 to your computer and use it in GitHub Desktop.
PDF.js Hello World
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ | |
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ | |
// | |
// See README for overview | |
// | |
'use strict'; | |
getPdf('your-file-name.pdf', function getPdfHelloWorld(data) { | |
// | |
// Instantiate PDFDoc with PDF data | |
// | |
var pdf = new PDFDoc(data); | |
var page = pdf.getPage(1); | |
var scale = 1.5; | |
// | |
// Prepare canvas using PDF page dimensions | |
// | |
var canvas = document.getElementById('the-canvas'); | |
var context = canvas.getContext('2d'); | |
canvas.height = page.height * scale; | |
canvas.width = page.width * scale; | |
// | |
// Render PDF page into canvas context | |
// | |
page.startRendering(context); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment