forked from Marak/pdf.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ugh all done, worst project evar lol
- Loading branch information
Showing
2 changed files
with
6,365 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
|
||
<html> | ||
<head> | ||
<title>pdf.js - create basic pdf files in the browser and node.js</title> | ||
<style type="text/css"> | ||
* { padding: 0; margin: 0; } | ||
body { | ||
padding: 30px; | ||
font-family: Arial, Helvetica, sans-serif; | ||
} | ||
h1 { | ||
margin-bottom: 1em; | ||
border-bottom: 1px solid #ccc; | ||
} | ||
|
||
h2 { | ||
margin-bottom: 1em; | ||
border-bottom: 1px solid #ccc; | ||
} | ||
|
||
pre { | ||
border: 1px dotted #ccc; | ||
background: #f7f7f7; | ||
padding: 10px; | ||
margin-bottom: 1em; | ||
} | ||
|
||
h1 { | ||
margin-bottom: 0.7em; | ||
} | ||
|
||
h2 { | ||
margin-top: 1em; | ||
} | ||
.box{ width:100%; height:500px;} | ||
#theCode{} | ||
#theFrame{ display:none;} | ||
</style> | ||
<script type="text/javascript" src="./lib/pdf.js"></script> | ||
<!-- jquery not required, just use this this demo page --> | ||
<script type="text/javascript" src="./lib/jquery.js"></script> | ||
|
||
|
||
<script type="text/javascript"> | ||
|
||
$(document).ready(function(){ | ||
|
||
$('#run').click(function(e){ | ||
// do an eval | ||
eval($('#theCode').val()); | ||
}); | ||
|
||
}); | ||
|
||
</script> | ||
|
||
</head> | ||
|
||
<body> | ||
|
||
<h1>pdf.js - create basic pdf files in the browser and node.js</h1> | ||
|
||
|
||
<h3>demo | ||
this uses <a href = "http://en.wikipedia.org/wiki/Data_URI_scheme" target = "_blank">dataURIs</a> and they kinda suck. the <a href = "https://github.com/marak/pdf.js"> | ||
node.js</a> version is better.</h3><br/> | ||
<form> | ||
<input type = "button" id = "run" name = "run" value = "click here to create example pdf" /> | ||
<span id = "pdfLink"></span> | ||
<br/> | ||
<textarea id = "theCode" class = "box"> | ||
|
||
/* create the PDF document */ | ||
|
||
var doc = new pdf(); | ||
doc.text(20, 20, 'hello, I am PDF.'); | ||
doc.text(20, 30, 'i was created in the browser using javascript.'); | ||
doc.text(20, 40, 'i can also be created from node.js'); | ||
|
||
/* optional - set properties on the document */ | ||
doc.setProperties({ | ||
title: 'A sample document created by pdf.js', | ||
subject: 'PDFs are kinda cool, i guess', | ||
author: 'Marak Squires', | ||
keywords: 'pdf.js, javascript, Marak, Marak Squires', | ||
creator: 'pdf.js' | ||
}); | ||
doc.addPage(); | ||
|
||
doc.setFontSize(22); | ||
doc.text(20, 20, 'This is a title'); | ||
|
||
doc.setFontSize(16); | ||
doc.text(20, 30, 'This is some normal sized text underneath.'); | ||
|
||
var fileName = "testFile"+new Date().getSeconds()+".pdf"; | ||
var pdfAsDataURI = doc.output('datauri', {"fileName":fileName}); | ||
|
||
/* inject the pdf into the browser */ | ||
|
||
// inject using an iframe | ||
// this seems to work in FF but not Chrome? try testing some more on your own >.< | ||
//$('#theFrame').attr('src',pdfAsDataURI); | ||
|
||
// inject using an object tag | ||
// doesnt really work but it does something interesting | ||
//$('body').append('<object data="'+pdfAsDataURI+'" type="application/pdf"></object>'); | ||
|
||
// inject changing document.location | ||
// doesn't work in FF, kinda works in Chrome. this method is a bit brutal as the user sees a huge URL | ||
// document.location = pdfAsDataURI; | ||
|
||
// create a link | ||
// this seems to always work, except clicking the link destroys my FF instantly | ||
$('#pdfLink').html('<a href = "'+pdfAsDataURI+'">'+fileName+'</a> <span class = "helper">right click and save file as pdf</span'); | ||
|
||
</textarea> | ||
</form> | ||
<iframe id = "theFrame"></iframe> | ||
|
||
<a href = "https://github.com/marak/pdf.js/"> | ||
<img alt="Fork me on GitHub" src="http://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png" style="position: absolute; z-index: 10; top: 0pt; right: 0pt; border: 0pt none;"> | ||
</a> | ||
</body> | ||
</html> |
Oops, something went wrong.