pdf folder commited

This commit is contained in:
gandhimathi 2017-12-19 18:55:22 +05:30
parent 986bdae26c
commit 03798bd8c2
252 changed files with 89825 additions and 0 deletions

View File

@ -0,0 +1,43 @@
{
"name": "angular-save-html-to-pdf",
"description": "Save HTML in pdf format by angularjs . Directives which are using libraries to convert html to html5canvas and save html5canvas as pdf .",
"main": "dist/saveHtmlToPdf.js",
"authors": [
"hearsid"
],
"license": "ISC",
"keywords": [
"html5canvas",
"pdf",
"html",
"html",
"to",
"pdf",
"angular"
],
"moduleType": [],
"homepage": "https://github.com/hearsid/ng-html-to-pdf-save",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"angular": "^1.5.5",
"html2canvas": "git://github.com/niklasvh/html2canvas.git",
"jquery": "^1.12",
"jsPDF": "git://github.com/MrRio/jsPDF.git"
},
"_release": "da9894b508",
"_resolution": {
"type": "branch",
"branch": "master",
"commit": "da9894b5080e0fa9c8d8a46c89cbd2f87b17b6c3"
},
"_source": "https://github.com/hearsid/ng-html-to-pdf-save.git",
"_target": "*",
"_originalSource": "angular-save-html-to-pdf",
"_direct": true
}

View File

@ -0,0 +1,61 @@
## Angularjs save HTML as PDF in your browser
This is an angularjs module to save HTML as PDF <a target="_blank" href="http://hearsid.github.io/angular-html-to-pdf-save/demo/index.html">DEMO</a>, it basically converts the HTML to HTML5 canvas and captures the same and converts it to PDF and saves it in your browser .
<br/>
Here are the steps :
<br/>
1) bower install angular-save-html-to-pdf
<br/>OR<br/>
npm install angular-save-html-to-pdf
2) Link the JS files in your HTML file :
```
<script src="../bower_components/angular/angular.js"></script>
<script src="../bower_components/jquery/dist/jquery.min.js"></script>
<script src="https://cdn.rawgit.com/niklasvh/html2canvas/0.5.0-alpha2/dist/html2canvas.min.js"></script>
<script src="../bower_components/jsPDF/dist/jspdf.debug.js"></script>
<script src="../dist/saveHtmlToPdf.min.js"></script>
```
3) Add this module to your angular app :
```
var app = angular.module('app' , ['htmlToPdfSave']) ;
```
4) Use the directives in your app , here is a code snippet from a working copy in demo folder :
```
<button pdf-save-button="idOne" pdf-name="someone.pdf" class="btn">Hello Someone</button>
<!-- below block will be saved as pdf -->
<div pdf-save-content="idOne" >
Hello Someone
</div>
<button pdf-save-button="idOneGraph" pdf-name="hello.pdf" class="btn">Hello World</button>
<!-- below block will be saved as pdf -->
<div pdf-save-content="idOneGraph" >
Hello World
</div>
```
To allow addition of multiple pdf save button and linking them to the pdf save content block every pdf-save-button and pdf-save-content directive is associated with an ID , the pdf-save-button will match the ID with pdf-save-content block and the matching HTML block will be saved .
<br/>
<br/>
### Developer instructions:
If you would like to run the project locally, you can download the repo and run :<br/>
1)
```
> gulp concat
> gulp compress
```
commands to create the bundled file which is then used in the demo/index.html file.
2) demo/index.html file can be served easily by any static web server to test the project, I use and thus recommend python server which you can start by writing
``` python -m SimpleHTTPServer 9090 ```
9090 can be replaced by your prefered port. <br/>
NOTE : This is a new repository and has been tested with basic HTML and google graphs , please create github issues if you find it is not working with something and consider contributing. Cheers .

View File

@ -0,0 +1,33 @@
{
"name": "angular-save-html-to-pdf",
"description": "Save HTML in pdf format by angularjs . Directives which are using libraries to convert html to html5canvas and save html5canvas as pdf .",
"main": "dist/saveHtmlToPdf.js",
"authors": [
"hearsid"
],
"license": "ISC",
"keywords": [
"html5canvas",
"pdf",
"html",
"html",
"to",
"pdf",
"angular"
],
"moduleType": [],
"homepage": "",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"angular": "^1.5.5" ,
"html2canvas" : "git://github.com/niklasvh/html2canvas.git" ,
"jquery" : "^1.12" ,
"jsPDF" : "git://github.com/MrRio/jsPDF.git"
}
}

View File

@ -0,0 +1,34 @@
<html ng-app="app">
<body ng-controller="DemoController">
<button pdf-save-button="idOne" pdf-name="someone.pdf" class="btn">Hello Someone</button>
<!-- below block will be saved as pdf -->
<div pdf-save-content="idOne" >
<!-- some google graph -->
Hello Someone
</div>
<button pdf-save-button="idOneGraph" pdf-name="hello.pdf" class="btn">Hello World</button>
<!-- below block will be saved as pdf -->
<div pdf-save-content="idOneGraph" >
<!-- some google graph -->
Hello World
</div>
<script src="../bower_components/angular/angular.js"></script>
<script src="../bower_components/jquery/dist/jquery.min.js"></script>
<script src="https://cdn.rawgit.com/niklasvh/html2canvas/0.5.0-alpha2/dist/html2canvas.min.js"></script>
<script src="../bower_components/jsPDF/dist/jspdf.debug.js"></script>
<script src="../dist/saveHtmlToPdf.js"></script>
<script id="tpl.tpl" type="text/ng-template">
Content of ng-template
</script>
<script>
var app = angular.module('app' , ['htmlToPdfSave']) ;
app.controller('DemoController' , function($scope) {
});
</script>
</body>
</html>

View File

@ -0,0 +1,194 @@
angular.module('htmlToPdfSave' , []) ;
angular.module('htmlToPdfSave')
.directive('pdfSaveButton' , ['$rootScope' , '$pdfStorage' , function($rootScope , $pdfStorage) {
return {
restrict: 'A',
link : function(scope , element , attrs ) {
$pdfStorage.pdfSaveButtons.push(element) ;
scope.buttonText = "Button";
element.on('click' , function() {
var activePdfSaveId = attrs.pdfSaveButton ;
var activePdfSaveName = attrs.pdfName;
$rootScope.$broadcast('savePdfEvent' , {activePdfSaveId : activePdfSaveId, activePdfSaveName: activePdfSaveName}) ;
})
}
}
}]) ;
angular.module('htmlToPdfSave')
.directive('pdfSaveContent' , [ '$rootScope' , '$pdfStorage' , function ($rootScope , $pdfStorage) {
return {
link : function(scope , element , attrs ) {
$pdfStorage.pdfSaveContents.push(element) ;
var myListener = scope.$on('savePdfEvent' , function(event , args) {
var currentElement = element ;
var currentElementId = currentElement[0].getAttribute('pdf-save-content') ;
// save a call of query selector because angular loads the element on load by default
// var elem = document.querySelectorAll('[pdf-save]') ;
var elem = $pdfStorage.pdfSaveContents ;
var broadcastedId = args.activePdfSaveId ;
var broadcastedName = args.activePdfSaveName || 'default.pdf';
//iterate through the element array to match the id
for(var i = 0;i < elem.length ; i++) {
// handle the case of elem getting length
// if(i == 'length' || i == 'item')
// continue ;
// if the event is received by other element than for whom it what propogated for continue
if(!matchTheIds(broadcastedId , currentElementId))
continue ;
var single = elem[i] ;
var singleElement = single[0];
//var parent = single[0] ;
var pdfId = singleElement.getAttribute('pdf-save-content') ;
if(matchTheIds(pdfId , broadcastedId)) {
console.log('Id is same');
convertToPdf(elem , pdfId);
break ; // exit the loop once pdf gets printed
}
}
function matchTheIds(elemId , broadcastedId) {
return elemId == broadcastedId ;
}
function convertToPdf(theElement , id) {
//theElement = [theElement];
convert(theElement , id ) ;
}
function convert(theElement , id) {
var quotes = $('div[pdf-save-content='+id+']')[0];
html2canvas(quotes, {
onrendered: function(canvas) {
var pdf = new jsPDF('p', 'pt', 'letter');
for (var i = 0; i <= quotes.clientHeight/980; i++) {
var srcImg = canvas;
var sX = 0;
var sY = 980*i; // start 980 pixels down for every new page
var sWidth = 900;
var sHeight = 980;
var dX = 0;
var dY = 0;
var dWidth = 900;
var dHeight = 980;
window.onePageCanvas = document.createElement("canvas");
onePageCanvas.setAttribute('width', 900);
onePageCanvas.setAttribute('height', 980);
var ctx = onePageCanvas.getContext('2d');
// details on this usage of this function:
// https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Using_images#Slicing
ctx.drawImage(srcImg,sX,sY,sWidth,sHeight,dX,dY,dWidth,dHeight);
// document.body.appendChild(canvas);
var canvasDataURL = onePageCanvas.toDataURL("image/png", 1.0);
var width = onePageCanvas.width;
var height = onePageCanvas.clientHeight;
//! If we're on anything other than the first page,
// add another page
if (i > 0) {
pdf.addPage(612, 791); //8.5" x 11" in pts (in*72)
}
//! now we declare that we're working on that page
pdf.setPage(i+1);
//! now we add content to that page!
pdf.addImage(canvasDataURL, 'PNG', 20, 40, (width*.62), (height*.62));
}
//! after the for loop is finished running, we save the pdf.
pdf.save(broadcastedName);
}
});
/*var element = $('[pdf-save-content='+id+']') ,
cache_width = element.width(),
a4 =[ 595.28, 841.89]; // for a4 size paper width and height
$('body').scrollTop(0);
createPDF();
//create pdf
function createPDF(){
getCanvas().then(function(canvas){
console.log('resolved get canvas');
var img = canvas.toDataURL("image/png"),
doc = new jsPDF({
unit:'px',
format:'a4'
});
doc.addImage(img, 'JPEG', 20, 20);
doc.save(broadcastedName);
element.width(cache_width);
})
}
// create canvas object
function getCanvas(){
element.width((a4[0]*1.33333) -80).css('max-width','none');
return html2canvas(element,{
imageTimeout:2000,
removeContainer:true
});
}*/
}
}) ;
// handle the memory leak
// unbind the event
scope.$on('$destroy', myListener);
}
}
}]) ;
angular.module('htmlToPdfSave')
.service('$pdfStorage' , function() {
this.pdfSaveButtons = [] ;
this.pdfSaveContents = [] ;
})
.service('pdfSaveConfig' , function() {
this.pdfName = "default.pdf";
})

View File

@ -0,0 +1 @@
angular.module("htmlToPdfSave",[]),angular.module("htmlToPdfSave").directive("pdfSaveButton",["$rootScope","$pdfStorage",function(e,t){return{restrict:"A",link:function(a,n,o){t.pdfSaveButtons.push(n),a.buttonText="Button",n.on("click",function(){var t=o.pdfSaveButton,a=o.pdfName;e.$broadcast("savePdfEvent",{activePdfSaveId:t,activePdfSaveName:a})})}}}]),angular.module("htmlToPdfSave").directive("pdfSaveContent",["$rootScope","$pdfStorage",function(e,t){return{link:function(e,a,n){t.pdfSaveContents.push(a);var o=e.$on("savePdfEvent",function(e,n){function o(e,t){return e==t}function d(e,t){v(e,t)}function v(e,t){var a=$("div[pdf-save-content="+t+"]")[0];html2canvas(a,{onrendered:function(e){for(var t=new jsPDF("p","pt","letter"),n=0;n<=a.clientHeight/980;n++){var o=e,d=0,v=980*n,f=900,i=980,r=0,u=0,c=900,g=980;window.onePageCanvas=document.createElement("canvas"),onePageCanvas.setAttribute("width",900),onePageCanvas.setAttribute("height",980);var p=onePageCanvas.getContext("2d");p.drawImage(o,d,v,f,i,r,u,c,g);var l=onePageCanvas.toDataURL("image/png",1),S=onePageCanvas.width,P=onePageCanvas.clientHeight;n>0&&t.addPage(612,791),t.setPage(n+1),t.addImage(l,"PNG",20,40,.62*S,.62*P)}t.save(s)}})}for(var f=a,i=f[0].getAttribute("pdf-save-content"),r=t.pdfSaveContents,u=n.activePdfSaveId,s=n.activePdfSaveName||"default.pdf",c=0;c<r.length;c++)if(o(u,i)){var g=r[c],p=g[0],l=p.getAttribute("pdf-save-content");if(o(l,u)){console.log("Id is same"),d(r,l);break}}});e.$on("$destroy",o)}}}]),angular.module("htmlToPdfSave").service("$pdfStorage",function(){this.pdfSaveButtons=[],this.pdfSaveContents=[]}).service("pdfSaveConfig",function(){this.pdfName="default.pdf"});

View File

@ -0,0 +1,34 @@
var gulp = require('gulp');
var concat = require('gulp-concat');
var sourcemaps = require('gulp-sourcemaps');
var minify = require('gulp-minify');
var fileName = 'saveHtmlToPdf' ;
var uglify = require('gulp-uglify');
var pump = require('pump');
var rename = require("gulp-rename");
gulp.task('compress', function (cb) {
pump([
gulp.src('dist/'+fileName+'.js') ,
uglify(),
rename({
suffix: '.min'
}),
gulp.dest('dist')
],
cb
);
});
gulp.task('concat', function() {
return gulp.src('src/*.js')
// .pipe(sourcemaps.init())
.pipe(concat(fileName+'.js'))
.pipe(sourcemaps.write())
.pipe(gulp.dest('dist'));
});

View File

@ -0,0 +1,32 @@
{
"name": "angular-save-html-to-pdf",
"version": "1.3.1",
"description": "Save HTML in pdf format totally by using frontend in angularjs . Basically this respository is a combination of some angular directives which are using other libraries to convert html to html5canvas and save that html5canvas as pdf . Everything happens in the frontend so there is no need of adding anything in your backend .",
"main": "index.js",
"scripts": {
"test": "karma start karma.test.js"
},
"keywords": [
"html5canvas",
"pdf",
"html",
"html",
"to",
"pdf",
"angular"
],
"author": "hearsid",
"license": "ISC",
"dependencies": {
},
"devDependencies": {
"gulp" : "*",
"gulp-sourcemaps": "^1.6.0",
"gulp-concat": "*",
"gulp-minify": "*",
"gulp-uglify": "*",
"pump": "*",
"gulp-rename": "*"
}
}

View File

@ -0,0 +1,5 @@
angular.module('htmlToPdfSave' , []) ;

View File

@ -0,0 +1,23 @@
angular.module('htmlToPdfSave')
.directive('pdfSaveButton' , ['$rootScope' , '$pdfStorage' , function($rootScope , $pdfStorage) {
return {
restrict: 'A',
link : function(scope , element , attrs ) {
$pdfStorage.pdfSaveButtons.push(element) ;
scope.buttonText = "Button";
element.on('click' , function() {
var activePdfSaveId = attrs.pdfSaveButton ;
var activePdfSaveName = attrs.pdfName;
$rootScope.$broadcast('savePdfEvent' , {activePdfSaveId : activePdfSaveId, activePdfSaveName: activePdfSaveName}) ;
})
}
}
}]) ;

View File

@ -0,0 +1,153 @@
angular.module('htmlToPdfSave')
.directive('pdfSaveContent' , [ '$rootScope' , '$pdfStorage' , function ($rootScope , $pdfStorage) {
return {
link : function(scope , element , attrs ) {
$pdfStorage.pdfSaveContents.push(element) ;
var myListener = scope.$on('savePdfEvent' , function(event , args) {
var currentElement = element ;
var currentElementId = currentElement[0].getAttribute('pdf-save-content') ;
// save a call of query selector because angular loads the element on load by default
// var elem = document.querySelectorAll('[pdf-save]') ;
var elem = $pdfStorage.pdfSaveContents ;
var broadcastedId = args.activePdfSaveId ;
var broadcastedName = args.activePdfSaveName || 'default.pdf';
//iterate through the element array to match the id
for(var i = 0;i < elem.length ; i++) {
// handle the case of elem getting length
// if(i == 'length' || i == 'item')
// continue ;
// if the event is received by other element than for whom it what propogated for continue
if(!matchTheIds(broadcastedId , currentElementId))
continue ;
var single = elem[i] ;
var singleElement = single[0];
//var parent = single[0] ;
var pdfId = singleElement.getAttribute('pdf-save-content') ;
if(matchTheIds(pdfId , broadcastedId)) {
console.log('Id is same');
convertToPdf(elem , pdfId);
break ; // exit the loop once pdf gets printed
}
}
function matchTheIds(elemId , broadcastedId) {
return elemId == broadcastedId ;
}
function convertToPdf(theElement , id) {
//theElement = [theElement];
convert(theElement , id ) ;
}
function convert(theElement , id) {
var quotes = $('div[pdf-save-content='+id+']')[0];
html2canvas(quotes, {
onrendered: function(canvas) {
var pdf = new jsPDF('p', 'pt', 'letter');
for (var i = 0; i <= quotes.clientHeight/980; i++) {
var srcImg = canvas;
var sX = 0;
var sY = 980*i; // start 980 pixels down for every new page
var sWidth = 900;
var sHeight = 980;
var dX = 0;
var dY = 0;
var dWidth = 900;
var dHeight = 980;
window.onePageCanvas = document.createElement("canvas");
onePageCanvas.setAttribute('width', 900);
onePageCanvas.setAttribute('height', 980);
var ctx = onePageCanvas.getContext('2d');
// details on this usage of this function:
// https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Using_images#Slicing
ctx.drawImage(srcImg,sX,sY,sWidth,sHeight,dX,dY,dWidth,dHeight);
// document.body.appendChild(canvas);
var canvasDataURL = onePageCanvas.toDataURL("image/png", 1.0);
var width = onePageCanvas.width;
var height = onePageCanvas.clientHeight;
//! If we're on anything other than the first page,
// add another page
if (i > 0) {
pdf.addPage(612, 791); //8.5" x 11" in pts (in*72)
}
//! now we declare that we're working on that page
pdf.setPage(i+1);
//! now we add content to that page!
pdf.addImage(canvasDataURL, 'PNG', 20, 40, (width*.62), (height*.62));
}
//! after the for loop is finished running, we save the pdf.
pdf.save(broadcastedName);
}
});
/*var element = $('[pdf-save-content='+id+']') ,
cache_width = element.width(),
a4 =[ 595.28, 841.89]; // for a4 size paper width and height
$('body').scrollTop(0);
createPDF();
//create pdf
function createPDF(){
getCanvas().then(function(canvas){
console.log('resolved get canvas');
var img = canvas.toDataURL("image/png"),
doc = new jsPDF({
unit:'px',
format:'a4'
});
doc.addImage(img, 'JPEG', 20, 20);
doc.save(broadcastedName);
element.width(cache_width);
})
}
// create canvas object
function getCanvas(){
element.width((a4[0]*1.33333) -80).css('max-width','none');
return html2canvas(element,{
imageTimeout:2000,
removeContainer:true
});
}*/
}
}) ;
// handle the memory leak
// unbind the event
scope.$on('$destroy', myListener);
}
}
}]) ;

View File

@ -0,0 +1,10 @@
angular.module('htmlToPdfSave')
.service('$pdfStorage' , function() {
this.pdfSaveButtons = [] ;
this.pdfSaveContents = [] ;
})
.service('pdfSaveConfig' , function() {
this.pdfName = "default.pdf";
})

View File

@ -0,0 +1,20 @@
{
"name": "html2canvas",
"version": "0.4.1",
"description": "Screenshots with JavaScript",
"main": "build/html2canvas.js",
"ignore": [
"tests",
".travis.yml"
],
"homepage": "https://github.com/niklasvh/html2canvas",
"_release": "0.4.1",
"_resolution": {
"type": "version",
"tag": "0.4.1",
"commit": "051576578827a7e7c99d9ec70f654b6f50396dbf"
},
"_source": "git://github.com/niklasvh/html2canvas.git",
"_target": "*",
"_originalSource": "git://github.com/niklasvh/html2canvas.git"
}

View File

@ -0,0 +1,20 @@
/nbproject/
/images/
/tests/templates/
/tests/cache/
/tests/flashcanvas.html
/lib/
/bin/
image.jpg
/.project
/.settings/
/tests/certificate.pem
node_modules/
.envrc
server.js
*.sublime-workspace
chromedriver.log
*.baseline
*.iml
.idea/
.DS_Store

View File

@ -0,0 +1,99 @@
/*global module:false*/
module.exports = function(grunt) {
var meta = {
banner: '/*\n <%= pkg.title || pkg.name %> <%= pkg.version %>' +
'<%= pkg.homepage ? " <" + pkg.homepage + ">" : "" %>' + '\n' +
' Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>' +
'\n\n Released under <%= _.pluck(pkg.licenses, "type").join(", ") %> License\n*/\n',
pre: '\n(function(window, document, undefined){\n\n',
post: '\n})(window,document);'
};
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
qunit: {
files: ['tests/qunit/index.html']
},
concat: {
dist: {
src: [
'src/Core.js',
'src/Font.js',
'src/Generate.js',
'src/Queue.js',
'src/Parse.js',
'src/Preload.js',
'src/Renderer.js',
'src/Support.js',
'src/Util.js',
'src/renderers/Canvas.js'
],
dest: 'build/<%= pkg.name %>.js'
},
options:{
banner: meta.banner + meta.pre,
footer: meta.post
}
},
uglify: {
dist: {
src: ['<%= concat.dist.dest %>'],
dest: 'build/<%= pkg.name %>.min.js'
},
options: {
banner: meta.banner
}
},
watch: {
files: 'src/*',
tasks: ['build', 'jshint']
},
jshint: {
all: ['<%= concat.dist.dest %>'],
options: {
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
boss: true,
eqnull: true,
browser: true,
globals: {
jQuery: true
}
}
}
});
grunt.registerTask('webdriver', 'Browser render tests', function(arg1) {
var selenium = require("./tests/selenium.js");
var done = this.async();
if (arguments.length) {
selenium[arg1].apply(null, arguments);
} else {
selenium.tests();
}
});
// Load tasks
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-qunit');
// Default task.
grunt.registerTask('build', ['concat', 'uglify']);
grunt.registerTask('default', ['concat', 'jshint', 'qunit', 'uglify']);
grunt.registerTask('travis', ['concat', 'jshint', 'qunit', 'uglify', 'webdriver']);
};

22
Apollo/bower_components/html2canvas/LICENSE vendored Executable file
View File

@ -0,0 +1,22 @@
Copyright (c) 2012 Niklas von Hertzen
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

View File

@ -0,0 +1,10 @@
{
"name": "html2canvas",
"version": "0.4.1",
"description": "Screenshots with JavaScript",
"main": "build/html2canvas.js",
"ignore": [
"tests",
".travis.yml"
]
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,183 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html>
<head>
<title>
display/box/float/clear test
</title>
<style type="text/css">
/* last modified: 1 Dec 98 */
html {
font: 10px/1 Verdana, sans-serif;
background-color: blue;
color: white;
}
body {
margin: 1.5em;
border: .5em solid black;
padding: 0;
width: 48em;
background-color: white;
}
dl {
margin: 0;
border: 0;
padding: .5em;
}
dt {
background-color: rgb(204,0,0);
margin: 0;
padding: 1em;
width: 10.638%; /* refers to parent element's width of 47em. = 5em or 50px */
height: 28em;
border: .5em solid black;
float: left;
}
dd {
float: right;
margin: 0 0 0 1em;
border: 1em solid black;
padding: 1em;
width: 34em;
height: 27em;
}
ul {
margin: 0;
border: 0;
padding: 0;
}
li {
display: block; /* i.e., suppress marker */
color: black;
height: 9em;
width: 5em;
margin: 0;
border: .5em solid black;
padding: 1em;
float: left;
background-color: #FC0;
}
#bar {
background-color: black;
color: white;
width: 41.17%; /* = 14em */
border: 0;
margin: 0 1em;
}
#baz {
margin: 1em 0;
border: 0;
padding: 1em;
width: 10em;
height: 10em;
background-color: black;
color: white;
}
form {
margin: 0;
display: inline;
}
p {
margin: 0;
}
form p {
line-height: 1.9;
}
blockquote {
margin: 1em 1em 1em 2em;
border-width: 1em 1.5em 2em .5em;
border-style: solid;
border-color: black;
padding: 1em 0;
width: 5em;
height: 9em;
float: left;
background-color: #FC0;
color: black;
}
address {
font-style: normal;
}
h1 {
background-color: black;
color: white;
float: left;
margin: 1em 0;
border: 0;
padding: 1em;
width: 10em;
height: 10em;
font-weight: normal;
font-size: 1em;
}
</style>
</head>
<body>
<dl>
<dt>
toggle
</dt>
<dd>
<ul>
<li>
the way
</li>
<li id="bar">
<p>
the world ends
</p>
<form action="./" method="get">
<p>
bang
<input type="radio" name="foo" value="off">
</p>
<p>
whimper
<input type="radio" name="foo2" value="on">
</p>
</form>
</li>
<li>
i grow old
</li>
<li id="baz">
pluot?
</li>
</ul>
<blockquote>
<address>
bar maids,
</address>
</blockquote>
<h1>
sing to me, erbarme dich
</h1>
</dd>
</dl>
<p style="color: black; font-size: 1em; line-height: 1.3em; clear: both">
This is a nonsensical document, but syntactically valid HTML 4.0. All 100% conformant CSS1 agents should be able to render the document elements above this paragraph <b>indistinguishably</b> (to the pixel) from this reference rendering, (except font rasterization and form widgets). All discrepancies should be traceable to CSS1 implementation shortcomings. Once you have finished evaluating this test, you can return to the <A HREF="sec5526c.htm" style="text-decoration:none">parent page</A>.
</p>
<script type="text/javascript" src="../build/html2canvas.js"></script>
<script type="text/javascript">
html2canvas(document.body, {
onrendered: function(canvas) {
document.body.appendChild(canvas);
}
});
</script>
</body>
</html>

View File

@ -0,0 +1,65 @@
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
.feedback-overlay-black{
background-color:#000;
opacity:0.5;
position:absolute;
top:0;
left:0;
width:100%;
height:100%;
margin:0;
}
</style>
<style>
div{
padding:20px;
margin:0 auto;
border:5px solid black;
}
h1{
border-bottom:2px solid white;
}
h2{
background: #efefef;
padding:10px;
}
</style>
</head>
<body>
<div style="background:red;">
<div style="background:green;">
<div style="background:blue;border-color:white;">
<div style="background:yellow;"><div style="background:orange;"><h1>Heading</h1>
Text that isn't wrapped in anything.
<p>Followed by some text wrapped in a <b>&lt;p&gt; paragraph.</b> </p>
Maybe add a <a href="#">link</a> or a different style of <a href="#" style="background:white;" id="highlight">link with a highlight</a>.
<hr />
<h2>More content</h2>
<div style="width:10px;height:10px;border-width:10px;padding:0;">a</div>
</div></div>
</div>
</div>
</div>
<script type="text/javascript" src="../build/html2canvas.js"></script>
<script type="text/javascript">
html2canvas(document.body, {
onrendered: function(canvas) {
document.body.appendChild(canvas);
}
});
</script>
</body>
</html>

View File

@ -0,0 +1,46 @@
{
"title": "html2canvas",
"name": "html2canvas",
"description": "Screenshots with JavaScript",
"version": "0.4.1",
"author": {
"name": "Niklas von Hertzen",
"email": "niklasvh@gmail.com",
"url": "http://hertzen.com"
},
"engines": {
"node": ">=0.8.0"
},
"dependencies": {},
"repository": {
"type": "git",
"url": "git@github.com:niklasvh/html2canvas.git"
},
"bugs": {
"url": "https://github.com/niklasvh/html2canvas/issues"
},
"devDependencies": {
"grunt": ">=0.4.0",
"grunt-contrib-concat": "*",
"grunt-contrib-uglify": "*",
"grunt-contrib-jshint": "*",
"grunt-contrib-qunit": "*",
"grunt-contrib-watch": "~0.5.1",
"googleapis": "~0.4.3",
"jwt-sign": "~0.1.0",
"base64-arraybuffer": ">= 0.1.0",
"png-js": ">= 0.1.1",
"sync-webdriver": ">=0.1.1",
"express": "~3.2.3",
"baconjs": "~0.3.15"
},
"scripts": {
"test": "grunt travis --verbose"
},
"homepage": "http://html2canvas.hertzen.com",
"licenses": [
{
"type": "MIT"
}
]
}

122
Apollo/bower_components/html2canvas/readme.md vendored Executable file
View File

@ -0,0 +1,122 @@
html2canvas
===========
### Current build status ###
[![Build Status](https://travis-ci.org/niklasvh/html2canvas.png)](https://travis-ci.org/niklasvh/html2canvas)
#### JavaScript HTML renderer ####
The script allows you to take "screenshots" of webpages or parts of it, directly on the users browser. The screenshot is based on the DOM and as such may not be 100% accurate to the real representation as it does not make an actual screenshot, but builds the screenshot based on the information available on the page.
###How does it work?###
The script renders the current page as a canvas image, by reading the DOM and the different styles applied to the elements.
It does **not require any rendering from the server**, as the whole image is created on the **clients browser**. However, as it is heavily dependent on the browser, this library is *not suitable* to be used in nodejs.
It doesn't magically circumvent any browser content policy restrictions either, so rendering cross-origin content will require a [proxy](https://github.com/niklasvh/html2canvas/wiki/Proxies) to get the content to the [same origin](http://en.wikipedia.org/wiki/Same_origin_policy).
The script is still in a **very experimental state**, so I don't recommend using it in a production environment nor start building applications with it yet, as there will be still major changes made.
###Browser compatibility###
The script should work fine on the following browsers:
* Firefox 3.5+
* Google Chrome
* Opera 12+
* IE9+
* Safari 6+
As each CSS property needs to be manually built to be supported, there are a number of properties that are not yet supported.
### Usage ###
To render an `element` with html2canvas, simply call:
` html2canvas(element, options);`
To access the created canvas, provide the `onrendered` event in the options which returns the canvas element as the first argument, as such:
html2canvas(document.body, {
onrendered: function(canvas) {
/* canvas is the actual canvas element,
to append it to the page call for example
document.body.appendChild( canvas );
*/
}
});
### Building ###
The library uses [grunt](http://gruntjs.com/) for building. Alternatively, you can download the latest build from [here](http://html2canvas.hertzen.com/build/html2canvas.js).
Run the full build process (including lint, qunit and webdriver tests):
$ grunt
Skip lint and tests and simply build from source:
$ grunt build
### Running tests ###
The library has two sets of tests. The first set is a number of qunit tests that check that different values parsed by browsers are correctly converted in html2canvas. To run these tests with grunt you'll need [phantomjs](http://phantomjs.org/).
The other set of tests run Firefox, Chrome and Internet Explorer with [webdriver](https://github.com/niklasvh/webdriver.js). The selenium standalone server (runs on Java) is required for these tests and can be downloaded from [here](http://code.google.com/p/selenium/downloads/list). They capture an actual screenshot from the test pages and compare the image to the screenshot created by html2canvas and calculate the percentage differences. These tests generally aren't expected to provide 100% matches, but while commiting changes, these should generally not go decrease from the baseline values.
Start by downloading the dependencies:
$ npm install
Run qunit tests:
$ grunt test
### Examples ###
For more information and examples, please visit the [homepage](http://html2canvas.hertzen.com) or try the [test console](http://html2canvas.hertzen.com/screenshots.html).
### Contributing ###
If you wish to contribute to the project, please send the pull requests to the develop branch. Before submitting any changes, try and test that the changes work with all the support browsers. If some CSS property isn't supported or is incomplete, please create appropriate tests for it as well before submitting any code changes.
### Changelog ###
v0.4.1 - 7.9.2013
* Added support for bower
* Improved z-index ordering
* Basic implementation for CSS transformations
* Fixed inline text in top element
* Basic implementation for text-shadow
v0.4.0 - 30.1.2013
* Added rendering tests with <a href="https://github.com/niklasvh/webdriver.js">webdriver</a>
* Switched to using grunt for building
* Removed support for IE<9, including any FlashCanvas bits
* Support for border-radius
* Support for multiple background images, size, and clipping
* Support for :before and :after pseudo elements
* Support for placeholder rendering
* Reformatted all tests to small units to test specific features
v0.3.4 - 26.6.2012
* Removed (last?) jQuery dependencies (<a href="https://github.com/niklasvh/html2canvas/commit/343b86705fe163766fcf735eb0217130e4bd5b17">niklasvh</a>)
* SVG-powered rendering (<a href="https://github.com/niklasvh/html2canvas/commit/67d3e0d0f59a5a654caf71a2e3be6494ff146c75">niklasvh</a>)
* Radial gradients (<a href="https://github.com/niklasvh/html2canvas/commit/4f22c18043a73c0c3bbf3b5e4d62714c56acd3c7">SunboX</a>)
* Split renderers to their own objects (<a href="https://github.com/niklasvh/html2canvas/commit/94f2f799a457cd29a21cc56ef8c06f1697866739">niklasvh</a>)
* Simplified API, cleaned up code (<a href="https://github.com/niklasvh/html2canvas/commit/c7d526c9eaa6a4abf4754d205fe1dee360c7660e">niklasvh</a>)
v0.3.3 - 2.3.2012
* SVG taint fix, and additional taint testing options for rendering (<a href="https://github.com/niklasvh/html2canvas/commit/2dc8b9385e656696cb019d615bdfa1d98b17d5d4">niklasvh</a>)
* Added support for CORS images and option to create canvas as tainted (<a href="https://github.com/niklasvh/html2canvas/commit/3ad49efa0032cde25c6ed32a39e35d1505d3b2ef">niklasvh</a>)
* Improved minification saved ~1K! (<a href="https://github.com/cobexer/html2canvas/commit/b82be022b2b9240bd503e078ac980bde2b953e43">cobexer</a>)
* Added integrated support for Flashcanvas (<a href="https://github.com/niklasvh/html2canvas/commit/e9257191519f67d74fd5e364d8dee3c0963ba5fc">niklasvh</a>)
* Fixed a variety of legacy IE bugs (<a href="https://github.com/niklasvh/html2canvas/commit/b65357c55d0701017bafcd357bc654b54d458f8f">niklasvh</a>)
v0.3.2 - 20.2.2012
* Added changelog!
* Added bookmarklet (<a href="https://github.com/niklasvh/html2canvas/commit/b320dd306e1a2d32a3bc5a71b6ebf6d8c060cde5">cobexer</a>)
* Option to select single element to render (<a href="https://github.com/niklasvh/html2canvas/commit/0cb252ada91c84ef411288b317c03e97da1f12ad">niklasvh</a>)
* Fixed closure compiler warnings (<a href="https://github.com/niklasvh/html2canvas/commit/36ff1ec7aadcbdf66851a0b77f0b9e87e4a8e4a1">cobexer</a>)
* Enable profiling in FF (<a href="https://github.com/niklasvh/html2canvas/commit/bbd75286a8406cf9e5aea01fdb7950d547edefb9">cobexer</a>)

View File

@ -0,0 +1,410 @@
"use strict";
var _html2canvas = {},
previousElement,
computedCSS,
html2canvas;
_html2canvas.Util = {};
_html2canvas.Util.log = function(a) {
if (_html2canvas.logging && window.console && window.console.log) {
window.console.log(a);
}
};
_html2canvas.Util.trimText = (function(isNative){
return function(input) {
return isNative ? isNative.apply(input) : ((input || '') + '').replace( /^\s+|\s+$/g , '' );
};
})(String.prototype.trim);
_html2canvas.Util.asFloat = function(v) {
return parseFloat(v);
};
(function() {
// TODO: support all possible length values
var TEXT_SHADOW_PROPERTY = /((rgba|rgb)\([^\)]+\)(\s-?\d+px){0,})/g;
var TEXT_SHADOW_VALUES = /(-?\d+px)|(#.+)|(rgb\(.+\))|(rgba\(.+\))/g;
_html2canvas.Util.parseTextShadows = function (value) {
if (!value || value === 'none') {
return [];
}
// find multiple shadow declarations
var shadows = value.match(TEXT_SHADOW_PROPERTY),
results = [];
for (var i = 0; shadows && (i < shadows.length); i++) {
var s = shadows[i].match(TEXT_SHADOW_VALUES);
results.push({
color: s[0],
offsetX: s[1] ? s[1].replace('px', '') : 0,
offsetY: s[2] ? s[2].replace('px', '') : 0,
blur: s[3] ? s[3].replace('px', '') : 0
});
}
return results;
};
})();
_html2canvas.Util.parseBackgroundImage = function (value) {
var whitespace = ' \r\n\t',
method, definition, prefix, prefix_i, block, results = [],
c, mode = 0, numParen = 0, quote, args;
var appendResult = function(){
if(method) {
if(definition.substr( 0, 1 ) === '"') {
definition = definition.substr( 1, definition.length - 2 );
}
if(definition) {
args.push(definition);
}
if(method.substr( 0, 1 ) === '-' &&
(prefix_i = method.indexOf( '-', 1 ) + 1) > 0) {
prefix = method.substr( 0, prefix_i);
method = method.substr( prefix_i );
}
results.push({
prefix: prefix,
method: method.toLowerCase(),
value: block,
args: args
});
}
args = []; //for some odd reason, setting .length = 0 didn't work in safari
method =
prefix =
definition =
block = '';
};
appendResult();
for(var i = 0, ii = value.length; i<ii; i++) {
c = value[i];
if(mode === 0 && whitespace.indexOf( c ) > -1){
continue;
}
switch(c) {
case '"':
if(!quote) {
quote = c;
}
else if(quote === c) {
quote = null;
}
break;
case '(':
if(quote) { break; }
else if(mode === 0) {
mode = 1;
block += c;
continue;
} else {
numParen++;
}
break;
case ')':
if(quote) { break; }
else if(mode === 1) {
if(numParen === 0) {
mode = 0;
block += c;
appendResult();
continue;
} else {
numParen--;
}
}
break;
case ',':
if(quote) { break; }
else if(mode === 0) {
appendResult();
continue;
}
else if (mode === 1) {
if(numParen === 0 && !method.match(/^url$/i)) {
args.push(definition);
definition = '';
block += c;
continue;
}
}
break;
}
block += c;
if(mode === 0) { method += c; }
else { definition += c; }
}
appendResult();
return results;
};
_html2canvas.Util.Bounds = function (element) {
var clientRect, bounds = {};
if (element.getBoundingClientRect){
clientRect = element.getBoundingClientRect();
// TODO add scroll position to bounds, so no scrolling of window necessary
bounds.top = clientRect.top;
bounds.bottom = clientRect.bottom || (clientRect.top + clientRect.height);
bounds.left = clientRect.left;
bounds.width = element.offsetWidth;
bounds.height = element.offsetHeight;
}
return bounds;
};
// TODO ideally, we'd want everything to go through this function instead of Util.Bounds,
// but would require further work to calculate the correct positions for elements with offsetParents
_html2canvas.Util.OffsetBounds = function (element) {
var parent = element.offsetParent ? _html2canvas.Util.OffsetBounds(element.offsetParent) : {top: 0, left: 0};
return {
top: element.offsetTop + parent.top,
bottom: element.offsetTop + element.offsetHeight + parent.top,
left: element.offsetLeft + parent.left,
width: element.offsetWidth,
height: element.offsetHeight
};
};
function toPX(element, attribute, value ) {
var rsLeft = element.runtimeStyle && element.runtimeStyle[attribute],
left,
style = element.style;
// Check if we are not dealing with pixels, (Opera has issues with this)
// Ported from jQuery css.js
// From the awesome hack by Dean Edwards
// http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
// If we're not dealing with a regular pixel number
// but a number that has a weird ending, we need to convert it to pixels
if ( !/^-?[0-9]+\.?[0-9]*(?:px)?$/i.test( value ) && /^-?\d/.test(value) ) {
// Remember the original values
left = style.left;
// Put in the new values to get a computed value out
if (rsLeft) {
element.runtimeStyle.left = element.currentStyle.left;
}
style.left = attribute === "fontSize" ? "1em" : (value || 0);
value = style.pixelLeft + "px";
// Revert the changed values
style.left = left;
if (rsLeft) {
element.runtimeStyle.left = rsLeft;
}
}
if (!/^(thin|medium|thick)$/i.test(value)) {
return Math.round(parseFloat(value)) + "px";
}
return value;
}
function asInt(val) {
return parseInt(val, 10);
}
function parseBackgroundSizePosition(value, element, attribute, index) {
value = (value || '').split(',');
value = value[index || 0] || value[0] || 'auto';
value = _html2canvas.Util.trimText(value).split(' ');
if(attribute === 'backgroundSize' && (!value[0] || value[0].match(/cover|contain|auto/))) {
//these values will be handled in the parent function
} else {
value[0] = (value[0].indexOf( "%" ) === -1) ? toPX(element, attribute + "X", value[0]) : value[0];
if(value[1] === undefined) {
if(attribute === 'backgroundSize') {
value[1] = 'auto';
return value;
} else {
// IE 9 doesn't return double digit always
value[1] = value[0];
}
}
value[1] = (value[1].indexOf("%") === -1) ? toPX(element, attribute + "Y", value[1]) : value[1];
}
return value;
}
_html2canvas.Util.getCSS = function (element, attribute, index) {
if (previousElement !== element) {
computedCSS = document.defaultView.getComputedStyle(element, null);
}
var value = computedCSS[attribute];
if (/^background(Size|Position)$/.test(attribute)) {
return parseBackgroundSizePosition(value, element, attribute, index);
} else if (/border(Top|Bottom)(Left|Right)Radius/.test(attribute)) {
var arr = value.split(" ");
if (arr.length <= 1) {
arr[1] = arr[0];
}
return arr.map(asInt);
}
return value;
};
_html2canvas.Util.resizeBounds = function( current_width, current_height, target_width, target_height, stretch_mode ){
var target_ratio = target_width / target_height,
current_ratio = current_width / current_height,
output_width, output_height;
if(!stretch_mode || stretch_mode === 'auto') {
output_width = target_width;
output_height = target_height;
} else if(target_ratio < current_ratio ^ stretch_mode === 'contain') {
output_height = target_height;
output_width = target_height * current_ratio;
} else {
output_width = target_width;
output_height = target_width / current_ratio;
}
return {
width: output_width,
height: output_height
};
};
function backgroundBoundsFactory( prop, el, bounds, image, imageIndex, backgroundSize ) {
var bgposition = _html2canvas.Util.getCSS( el, prop, imageIndex ) ,
topPos,
left,
percentage,
val;
if (bgposition.length === 1){
val = bgposition[0];
bgposition = [];
bgposition[0] = val;
bgposition[1] = val;
}
if (bgposition[0].toString().indexOf("%") !== -1){
percentage = (parseFloat(bgposition[0])/100);
left = bounds.width * percentage;
if(prop !== 'backgroundSize') {
left -= (backgroundSize || image).width*percentage;
}
} else {
if(prop === 'backgroundSize') {
if(bgposition[0] === 'auto') {
left = image.width;
} else {
if (/contain|cover/.test(bgposition[0])) {
var resized = _html2canvas.Util.resizeBounds(image.width, image.height, bounds.width, bounds.height, bgposition[0]);
left = resized.width;
topPos = resized.height;
} else {
left = parseInt(bgposition[0], 10);
}
}
} else {
left = parseInt( bgposition[0], 10);
}
}
if(bgposition[1] === 'auto') {
topPos = left / image.width * image.height;
} else if (bgposition[1].toString().indexOf("%") !== -1){
percentage = (parseFloat(bgposition[1])/100);
topPos = bounds.height * percentage;
if(prop !== 'backgroundSize') {
topPos -= (backgroundSize || image).height * percentage;
}
} else {
topPos = parseInt(bgposition[1],10);
}
return [left, topPos];
}
_html2canvas.Util.BackgroundPosition = function( el, bounds, image, imageIndex, backgroundSize ) {
var result = backgroundBoundsFactory( 'backgroundPosition', el, bounds, image, imageIndex, backgroundSize );
return { left: result[0], top: result[1] };
};
_html2canvas.Util.BackgroundSize = function( el, bounds, image, imageIndex ) {
var result = backgroundBoundsFactory( 'backgroundSize', el, bounds, image, imageIndex );
return { width: result[0], height: result[1] };
};
_html2canvas.Util.Extend = function (options, defaults) {
for (var key in options) {
if (options.hasOwnProperty(key)) {
defaults[key] = options[key];
}
}
return defaults;
};
/*
* Derived from jQuery.contents()
* Copyright 2010, John Resig
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*/
_html2canvas.Util.Children = function( elem ) {
var children;
try {
children = (elem.nodeName && elem.nodeName.toUpperCase() === "IFRAME") ? elem.contentDocument || elem.contentWindow.document : (function(array) {
var ret = [];
if (array !== null) {
(function(first, second ) {
var i = first.length,
j = 0;
if (typeof second.length === "number") {
for (var l = second.length; j < l; j++) {
first[i++] = second[j];
}
} else {
while (second[j] !== undefined) {
first[i++] = second[j++];
}
}
first.length = i;
return first;
})(ret, array);
}
return ret;
})(elem.childNodes);
} catch (ex) {
_html2canvas.Util.log("html2canvas.Util.Children failed with exception: " + ex.message);
children = [];
}
return children;
};
_html2canvas.Util.isTransparent = function(backgroundColor) {
return (backgroundColor === "transparent" || backgroundColor === "rgba(0, 0, 0, 0)");
};

View File

@ -0,0 +1,64 @@
_html2canvas.Util.Font = (function () {
var fontData = {};
return function(font, fontSize, doc) {
if (fontData[font + "-" + fontSize] !== undefined) {
return fontData[font + "-" + fontSize];
}
var container = doc.createElement('div'),
img = doc.createElement('img'),
span = doc.createElement('span'),
sampleText = 'Hidden Text',
baseline,
middle,
metricsObj;
container.style.visibility = "hidden";
container.style.fontFamily = font;
container.style.fontSize = fontSize;
container.style.margin = 0;
container.style.padding = 0;
doc.body.appendChild(container);
// http://probablyprogramming.com/2009/03/15/the-tiniest-gif-ever (handtinywhite.gif)
img.src = "data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACwAAAAAAQABAAACAkQBADs=";
img.width = 1;
img.height = 1;
img.style.margin = 0;
img.style.padding = 0;
img.style.verticalAlign = "baseline";
span.style.fontFamily = font;
span.style.fontSize = fontSize;
span.style.margin = 0;
span.style.padding = 0;
span.appendChild(doc.createTextNode(sampleText));
container.appendChild(span);
container.appendChild(img);
baseline = (img.offsetTop - span.offsetTop) + 1;
container.removeChild(span);
container.appendChild(doc.createTextNode(sampleText));
container.style.lineHeight = "normal";
img.style.verticalAlign = "super";
middle = (img.offsetTop-container.offsetTop) + 1;
metricsObj = {
baseline: baseline,
lineWidth: 1,
middle: middle
};
fontData[font + "-" + fontSize] = metricsObj;
doc.body.removeChild(container);
return metricsObj;
};
})();

View File

@ -0,0 +1,424 @@
(function(){
var Util = _html2canvas.Util,
Generate = {};
_html2canvas.Generate = Generate;
var reGradients = [
/^(-webkit-linear-gradient)\(([a-z\s]+)([\w\d\.\s,%\(\)]+)\)$/,
/^(-o-linear-gradient)\(([a-z\s]+)([\w\d\.\s,%\(\)]+)\)$/,
/^(-webkit-gradient)\((linear|radial),\s((?:\d{1,3}%?)\s(?:\d{1,3}%?),\s(?:\d{1,3}%?)\s(?:\d{1,3}%?))([\w\d\.\s,%\(\)\-]+)\)$/,
/^(-moz-linear-gradient)\(((?:\d{1,3}%?)\s(?:\d{1,3}%?))([\w\d\.\s,%\(\)]+)\)$/,
/^(-webkit-radial-gradient)\(((?:\d{1,3}%?)\s(?:\d{1,3}%?)),\s(\w+)\s([a-z\-]+)([\w\d\.\s,%\(\)]+)\)$/,
/^(-moz-radial-gradient)\(((?:\d{1,3}%?)\s(?:\d{1,3}%?)),\s(\w+)\s?([a-z\-]*)([\w\d\.\s,%\(\)]+)\)$/,
/^(-o-radial-gradient)\(((?:\d{1,3}%?)\s(?:\d{1,3}%?)),\s(\w+)\s([a-z\-]+)([\w\d\.\s,%\(\)]+)\)$/
];
/*
* TODO: Add IE10 vendor prefix (-ms) support
* TODO: Add W3C gradient (linear-gradient) support
* TODO: Add old Webkit -webkit-gradient(radial, ...) support
* TODO: Maybe some RegExp optimizations are possible ;o)
*/
Generate.parseGradient = function(css, bounds) {
var gradient, i, len = reGradients.length, m1, stop, m2, m2Len, step, m3, tl,tr,br,bl;
for(i = 0; i < len; i+=1){
m1 = css.match(reGradients[i]);
if(m1) {
break;
}
}
if(m1) {
switch(m1[1]) {
case '-webkit-linear-gradient':
case '-o-linear-gradient':
gradient = {
type: 'linear',
x0: null,
y0: null,
x1: null,
y1: null,
colorStops: []
};
// get coordinates
m2 = m1[2].match(/\w+/g);
if(m2){
m2Len = m2.length;
for(i = 0; i < m2Len; i+=1){
switch(m2[i]) {
case 'top':
gradient.y0 = 0;
gradient.y1 = bounds.height;
break;
case 'right':
gradient.x0 = bounds.width;
gradient.x1 = 0;
break;
case 'bottom':
gradient.y0 = bounds.height;
gradient.y1 = 0;
break;
case 'left':
gradient.x0 = 0;
gradient.x1 = bounds.width;
break;
}
}
}
if(gradient.x0 === null && gradient.x1 === null){ // center
gradient.x0 = gradient.x1 = bounds.width / 2;
}
if(gradient.y0 === null && gradient.y1 === null){ // center
gradient.y0 = gradient.y1 = bounds.height / 2;
}
// get colors and stops
m2 = m1[3].match(/((?:rgb|rgba)\(\d{1,3},\s\d{1,3},\s\d{1,3}(?:,\s[0-9\.]+)?\)(?:\s\d{1,3}(?:%|px))?)+/g);
if(m2){
m2Len = m2.length;
step = 1 / Math.max(m2Len - 1, 1);
for(i = 0; i < m2Len; i+=1){
m3 = m2[i].match(/((?:rgb|rgba)\(\d{1,3},\s\d{1,3},\s\d{1,3}(?:,\s[0-9\.]+)?\))\s*(\d{1,3})?(%|px)?/);
if(m3[2]){
stop = parseFloat(m3[2]);
if(m3[3] === '%'){
stop /= 100;
} else { // px - stupid opera
stop /= bounds.width;
}
} else {
stop = i * step;
}
gradient.colorStops.push({
color: m3[1],
stop: stop
});
}
}
break;
case '-webkit-gradient':
gradient = {
type: m1[2] === 'radial' ? 'circle' : m1[2], // TODO: Add radial gradient support for older mozilla definitions
x0: 0,
y0: 0,
x1: 0,
y1: 0,
colorStops: []
};
// get coordinates
m2 = m1[3].match(/(\d{1,3})%?\s(\d{1,3})%?,\s(\d{1,3})%?\s(\d{1,3})%?/);
if(m2){
gradient.x0 = (m2[1] * bounds.width) / 100;
gradient.y0 = (m2[2] * bounds.height) / 100;
gradient.x1 = (m2[3] * bounds.width) / 100;
gradient.y1 = (m2[4] * bounds.height) / 100;
}
// get colors and stops
m2 = m1[4].match(/((?:from|to|color-stop)\((?:[0-9\.]+,\s)?(?:rgb|rgba)\(\d{1,3},\s\d{1,3},\s\d{1,3}(?:,\s[0-9\.]+)?\)\))+/g);
if(m2){
m2Len = m2.length;
for(i = 0; i < m2Len; i+=1){
m3 = m2[i].match(/(from|to|color-stop)\(([0-9\.]+)?(?:,\s)?((?:rgb|rgba)\(\d{1,3},\s\d{1,3},\s\d{1,3}(?:,\s[0-9\.]+)?\))\)/);
stop = parseFloat(m3[2]);
if(m3[1] === 'from') {
stop = 0.0;
}
if(m3[1] === 'to') {
stop = 1.0;
}
gradient.colorStops.push({
color: m3[3],
stop: stop
});
}
}
break;
case '-moz-linear-gradient':
gradient = {
type: 'linear',
x0: 0,
y0: 0,
x1: 0,
y1: 0,
colorStops: []
};
// get coordinates
m2 = m1[2].match(/(\d{1,3})%?\s(\d{1,3})%?/);
// m2[1] == 0% -> left
// m2[1] == 50% -> center
// m2[1] == 100% -> right
// m2[2] == 0% -> top
// m2[2] == 50% -> center
// m2[2] == 100% -> bottom
if(m2){
gradient.x0 = (m2[1] * bounds.width) / 100;
gradient.y0 = (m2[2] * bounds.height) / 100;
gradient.x1 = bounds.width - gradient.x0;
gradient.y1 = bounds.height - gradient.y0;
}
// get colors and stops
m2 = m1[3].match(/((?:rgb|rgba)\(\d{1,3},\s\d{1,3},\s\d{1,3}(?:,\s[0-9\.]+)?\)(?:\s\d{1,3}%)?)+/g);
if(m2){
m2Len = m2.length;
step = 1 / Math.max(m2Len - 1, 1);
for(i = 0; i < m2Len; i+=1){
m3 = m2[i].match(/((?:rgb|rgba)\(\d{1,3},\s\d{1,3},\s\d{1,3}(?:,\s[0-9\.]+)?\))\s*(\d{1,3})?(%)?/);
if(m3[2]){
stop = parseFloat(m3[2]);
if(m3[3]){ // percentage
stop /= 100;
}
} else {
stop = i * step;
}
gradient.colorStops.push({
color: m3[1],
stop: stop
});
}
}
break;
case '-webkit-radial-gradient':
case '-moz-radial-gradient':
case '-o-radial-gradient':
gradient = {
type: 'circle',
x0: 0,
y0: 0,
x1: bounds.width,
y1: bounds.height,
cx: 0,
cy: 0,
rx: 0,
ry: 0,
colorStops: []
};
// center
m2 = m1[2].match(/(\d{1,3})%?\s(\d{1,3})%?/);
if(m2){
gradient.cx = (m2[1] * bounds.width) / 100;
gradient.cy = (m2[2] * bounds.height) / 100;
}
// size
m2 = m1[3].match(/\w+/);
m3 = m1[4].match(/[a-z\-]*/);
if(m2 && m3){
switch(m3[0]){
case 'farthest-corner':
case 'cover': // is equivalent to farthest-corner
case '': // mozilla removes "cover" from definition :(
tl = Math.sqrt(Math.pow(gradient.cx, 2) + Math.pow(gradient.cy, 2));
tr = Math.sqrt(Math.pow(gradient.cx, 2) + Math.pow(gradient.y1 - gradient.cy, 2));
br = Math.sqrt(Math.pow(gradient.x1 - gradient.cx, 2) + Math.pow(gradient.y1 - gradient.cy, 2));
bl = Math.sqrt(Math.pow(gradient.x1 - gradient.cx, 2) + Math.pow(gradient.cy, 2));
gradient.rx = gradient.ry = Math.max(tl, tr, br, bl);
break;
case 'closest-corner':
tl = Math.sqrt(Math.pow(gradient.cx, 2) + Math.pow(gradient.cy, 2));
tr = Math.sqrt(Math.pow(gradient.cx, 2) + Math.pow(gradient.y1 - gradient.cy, 2));
br = Math.sqrt(Math.pow(gradient.x1 - gradient.cx, 2) + Math.pow(gradient.y1 - gradient.cy, 2));
bl = Math.sqrt(Math.pow(gradient.x1 - gradient.cx, 2) + Math.pow(gradient.cy, 2));
gradient.rx = gradient.ry = Math.min(tl, tr, br, bl);
break;
case 'farthest-side':
if(m2[0] === 'circle'){
gradient.rx = gradient.ry = Math.max(
gradient.cx,
gradient.cy,
gradient.x1 - gradient.cx,
gradient.y1 - gradient.cy
);
} else { // ellipse
gradient.type = m2[0];
gradient.rx = Math.max(
gradient.cx,
gradient.x1 - gradient.cx
);
gradient.ry = Math.max(
gradient.cy,
gradient.y1 - gradient.cy
);
}
break;
case 'closest-side':
case 'contain': // is equivalent to closest-side
if(m2[0] === 'circle'){
gradient.rx = gradient.ry = Math.min(
gradient.cx,
gradient.cy,
gradient.x1 - gradient.cx,
gradient.y1 - gradient.cy
);
} else { // ellipse
gradient.type = m2[0];
gradient.rx = Math.min(
gradient.cx,
gradient.x1 - gradient.cx
);
gradient.ry = Math.min(
gradient.cy,
gradient.y1 - gradient.cy
);
}
break;
// TODO: add support for "30px 40px" sizes (webkit only)
}
}
// color stops
m2 = m1[5].match(/((?:rgb|rgba)\(\d{1,3},\s\d{1,3},\s\d{1,3}(?:,\s[0-9\.]+)?\)(?:\s\d{1,3}(?:%|px))?)+/g);
if(m2){
m2Len = m2.length;
step = 1 / Math.max(m2Len - 1, 1);
for(i = 0; i < m2Len; i+=1){
m3 = m2[i].match(/((?:rgb|rgba)\(\d{1,3},\s\d{1,3},\s\d{1,3}(?:,\s[0-9\.]+)?\))\s*(\d{1,3})?(%|px)?/);
if(m3[2]){
stop = parseFloat(m3[2]);
if(m3[3] === '%'){
stop /= 100;
} else { // px - stupid opera
stop /= bounds.width;
}
} else {
stop = i * step;
}
gradient.colorStops.push({
color: m3[1],
stop: stop
});
}
}
break;
}
}
return gradient;
};
function addScrollStops(grad) {
return function(colorStop) {
try {
grad.addColorStop(colorStop.stop, colorStop.color);
}
catch(e) {
Util.log(['failed to add color stop: ', e, '; tried to add: ', colorStop]);
}
};
}
Generate.Gradient = function(src, bounds) {
if(bounds.width === 0 || bounds.height === 0) {
return;
}
var canvas = document.createElement('canvas'),
ctx = canvas.getContext('2d'),
gradient, grad;
canvas.width = bounds.width;
canvas.height = bounds.height;
// TODO: add support for multi defined background gradients
gradient = _html2canvas.Generate.parseGradient(src, bounds);
if(gradient) {
switch(gradient.type) {
case 'linear':
grad = ctx.createLinearGradient(gradient.x0, gradient.y0, gradient.x1, gradient.y1);
gradient.colorStops.forEach(addScrollStops(grad));
ctx.fillStyle = grad;
ctx.fillRect(0, 0, bounds.width, bounds.height);
break;
case 'circle':
grad = ctx.createRadialGradient(gradient.cx, gradient.cy, 0, gradient.cx, gradient.cy, gradient.rx);
gradient.colorStops.forEach(addScrollStops(grad));
ctx.fillStyle = grad;
ctx.fillRect(0, 0, bounds.width, bounds.height);
break;
case 'ellipse':
var canvasRadial = document.createElement('canvas'),
ctxRadial = canvasRadial.getContext('2d'),
ri = Math.max(gradient.rx, gradient.ry),
di = ri * 2;
canvasRadial.width = canvasRadial.height = di;
grad = ctxRadial.createRadialGradient(gradient.rx, gradient.ry, 0, gradient.rx, gradient.ry, ri);
gradient.colorStops.forEach(addScrollStops(grad));
ctxRadial.fillStyle = grad;
ctxRadial.fillRect(0, 0, di, di);
ctx.fillStyle = gradient.colorStops[gradient.colorStops.length - 1].color;
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.drawImage(canvasRadial, gradient.cx - gradient.rx, gradient.cy - gradient.ry, 2 * gradient.rx, 2 * gradient.ry);
break;
}
}
return canvas;
};
Generate.ListAlpha = function(number) {
var tmp = "",
modulus;
do {
modulus = number % 26;
tmp = String.fromCharCode((modulus) + 64) + tmp;
number = number / 26;
}while((number*26) > 26);
return tmp;
};
Generate.ListRoman = function(number) {
var romanArray = ["M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"],
decimal = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1],
roman = "",
v,
len = romanArray.length;
if (number <= 0 || number >= 4000) {
return number;
}
for (v=0; v < len; v+=1) {
while (number >= decimal[v]) {
number -= decimal[v];
roman += romanArray[v];
}
}
return roman;
};
})();

1143
Apollo/bower_components/html2canvas/src/Parse.js vendored Executable file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,317 @@
_html2canvas.Preload = function( options ) {
var images = {
numLoaded: 0, // also failed are counted here
numFailed: 0,
numTotal: 0,
cleanupDone: false
},
pageOrigin,
Util = _html2canvas.Util,
methods,
i,
count = 0,
element = options.elements[0] || document.body,
doc = element.ownerDocument,
domImages = element.getElementsByTagName('img'), // Fetch images of the present element only
imgLen = domImages.length,
link = doc.createElement("a"),
supportCORS = (function( img ){
return (img.crossOrigin !== undefined);
})(new Image()),
timeoutTimer;
link.href = window.location.href;
pageOrigin = link.protocol + link.host;
function isSameOrigin(url){
link.href = url;
link.href = link.href; // YES, BELIEVE IT OR NOT, that is required for IE9 - http://jsfiddle.net/niklasvh/2e48b/
var origin = link.protocol + link.host;
return (origin === pageOrigin);
}
function start(){
Util.log("html2canvas: start: images: " + images.numLoaded + " / " + images.numTotal + " (failed: " + images.numFailed + ")");
if (!images.firstRun && images.numLoaded >= images.numTotal){
Util.log("Finished loading images: # " + images.numTotal + " (failed: " + images.numFailed + ")");
if (typeof options.complete === "function"){
options.complete(images);
}
}
}
// TODO modify proxy to serve images with CORS enabled, where available
function proxyGetImage(url, img, imageObj){
var callback_name,
scriptUrl = options.proxy,
script;
link.href = url;
url = link.href; // work around for pages with base href="" set - WARNING: this may change the url
callback_name = 'html2canvas_' + (count++);
imageObj.callbackname = callback_name;
if (scriptUrl.indexOf("?") > -1) {
scriptUrl += "&";
} else {
scriptUrl += "?";
}
scriptUrl += 'url=' + encodeURIComponent(url) + '&callback=' + callback_name;
script = doc.createElement("script");
window[callback_name] = function(a){
if (a.substring(0,6) === "error:"){
imageObj.succeeded = false;
images.numLoaded++;
images.numFailed++;
start();
} else {
setImageLoadHandlers(img, imageObj);
img.src = a;
}
window[callback_name] = undefined; // to work with IE<9 // NOTE: that the undefined callback property-name still exists on the window object (for IE<9)
try {
delete window[callback_name]; // for all browser that support this
} catch(ex) {}
script.parentNode.removeChild(script);
script = null;
delete imageObj.script;
delete imageObj.callbackname;
};
script.setAttribute("type", "text/javascript");
script.setAttribute("src", scriptUrl);
imageObj.script = script;
window.document.body.appendChild(script);
}
function loadPseudoElement(element, type) {
var style = window.getComputedStyle(element, type),
content = style.content;
if (content.substr(0, 3) === 'url') {
methods.loadImage(_html2canvas.Util.parseBackgroundImage(content)[0].args[0]);
}
loadBackgroundImages(style.backgroundImage, element);
}
function loadPseudoElementImages(element) {
loadPseudoElement(element, ":before");
loadPseudoElement(element, ":after");
}
function loadGradientImage(backgroundImage, bounds) {
var img = _html2canvas.Generate.Gradient(backgroundImage, bounds);
if (img !== undefined){
images[backgroundImage] = {
img: img,
succeeded: true
};
images.numTotal++;
images.numLoaded++;
start();
}
}
function invalidBackgrounds(background_image) {
return (background_image && background_image.method && background_image.args && background_image.args.length > 0 );
}
function loadBackgroundImages(background_image, el) {
var bounds;
_html2canvas.Util.parseBackgroundImage(background_image).filter(invalidBackgrounds).forEach(function(background_image) {
if (background_image.method === 'url') {
methods.loadImage(background_image.args[0]);
} else if(background_image.method.match(/\-?gradient$/)) {
if(bounds === undefined) {
bounds = _html2canvas.Util.Bounds(el);
}
loadGradientImage(background_image.value, bounds);
}
});
}
function getImages (el) {
var elNodeType = false;
// Firefox fails with permission denied on pages with iframes
try {
Util.Children(el).forEach(getImages);
}
catch( e ) {}
try {
elNodeType = el.nodeType;
} catch (ex) {
elNodeType = false;
Util.log("html2canvas: failed to access some element's nodeType - Exception: " + ex.message);
}
if (elNodeType === 1 || elNodeType === undefined) {
loadPseudoElementImages(el);
try {
loadBackgroundImages(Util.getCSS(el, 'backgroundImage'), el);
} catch(e) {
Util.log("html2canvas: failed to get background-image - Exception: " + e.message);
}
loadBackgroundImages(el);
}
}
function setImageLoadHandlers(img, imageObj) {
img.onload = function() {
if ( imageObj.timer !== undefined ) {
// CORS succeeded
window.clearTimeout( imageObj.timer );
}
images.numLoaded++;
imageObj.succeeded = true;
img.onerror = img.onload = null;
start();
};
img.onerror = function() {
if (img.crossOrigin === "anonymous") {
// CORS failed
window.clearTimeout( imageObj.timer );
// let's try with proxy instead
if ( options.proxy ) {
var src = img.src;
img = new Image();
imageObj.img = img;
img.src = src;
proxyGetImage( img.src, img, imageObj );
return;
}
}
images.numLoaded++;
images.numFailed++;
imageObj.succeeded = false;
img.onerror = img.onload = null;
start();
};
}
methods = {
loadImage: function( src ) {
var img, imageObj;
if ( src && images[src] === undefined ) {
img = new Image();
if ( src.match(/data:image\/.*;base64,/i) ) {
img.src = src.replace(/url\(['"]{0,}|['"]{0,}\)$/ig, '');
imageObj = images[src] = {
img: img
};
images.numTotal++;
setImageLoadHandlers(img, imageObj);
} else if ( isSameOrigin( src ) || options.allowTaint === true ) {
imageObj = images[src] = {
img: img
};
images.numTotal++;
setImageLoadHandlers(img, imageObj);
img.src = src;
} else if ( supportCORS && !options.allowTaint && options.useCORS ) {
// attempt to load with CORS
img.crossOrigin = "anonymous";
imageObj = images[src] = {
img: img
};
images.numTotal++;
setImageLoadHandlers(img, imageObj);
img.src = src;
} else if ( options.proxy ) {
imageObj = images[src] = {
img: img
};
images.numTotal++;
proxyGetImage( src, img, imageObj );
}
}
},
cleanupDOM: function(cause) {
var img, src;
if (!images.cleanupDone) {
if (cause && typeof cause === "string") {
Util.log("html2canvas: Cleanup because: " + cause);
} else {
Util.log("html2canvas: Cleanup after timeout: " + options.timeout + " ms.");
}
for (src in images) {
if (images.hasOwnProperty(src)) {
img = images[src];
if (typeof img === "object" && img.callbackname && img.succeeded === undefined) {
// cancel proxy image request
window[img.callbackname] = undefined; // to work with IE<9 // NOTE: that the undefined callback property-name still exists on the window object (for IE<9)
try {
delete window[img.callbackname]; // for all browser that support this
} catch(ex) {}
if (img.script && img.script.parentNode) {
img.script.setAttribute("src", "about:blank"); // try to cancel running request
img.script.parentNode.removeChild(img.script);
}
images.numLoaded++;
images.numFailed++;
Util.log("html2canvas: Cleaned up failed img: '" + src + "' Steps: " + images.numLoaded + " / " + images.numTotal);
}
}
}
// cancel any pending requests
if(window.stop !== undefined) {
window.stop();
} else if(document.execCommand !== undefined) {
document.execCommand("Stop", false);
}
if (document.close !== undefined) {
document.close();
}
images.cleanupDone = true;
if (!(cause && typeof cause === "string")) {
start();
}
}
},
renderingDone: function() {
if (timeoutTimer) {
window.clearTimeout(timeoutTimer);
}
}
};
if (options.timeout > 0) {
timeoutTimer = window.setTimeout(methods.cleanupDOM, options.timeout);
}
Util.log('html2canvas: Preload starts: finding background-images');
images.firstRun = true;
getImages(element);
Util.log('html2canvas: Preload: Finding images');
// load <img> images
for (i = 0; i < imgLen; i+=1){
methods.loadImage( domImages[i].getAttribute( "src" ) );
}
images.firstRun = false;
Util.log('html2canvas: Preload: Done.');
if (images.numTotal === images.numLoaded) {
start();
}
return methods;
};

View File

@ -0,0 +1,123 @@
function h2cRenderContext(width, height) {
var storage = [];
return {
storage: storage,
width: width,
height: height,
clip: function() {
storage.push({
type: "function",
name: "clip",
'arguments': arguments
});
},
translate: function() {
storage.push({
type: "function",
name: "translate",
'arguments': arguments
});
},
fill: function() {
storage.push({
type: "function",
name: "fill",
'arguments': arguments
});
},
save: function() {
storage.push({
type: "function",
name: "save",
'arguments': arguments
});
},
restore: function() {
storage.push({
type: "function",
name: "restore",
'arguments': arguments
});
},
fillRect: function () {
storage.push({
type: "function",
name: "fillRect",
'arguments': arguments
});
},
createPattern: function() {
storage.push({
type: "function",
name: "createPattern",
'arguments': arguments
});
},
drawShape: function() {
var shape = [];
storage.push({
type: "function",
name: "drawShape",
'arguments': shape
});
return {
moveTo: function() {
shape.push({
name: "moveTo",
'arguments': arguments
});
},
lineTo: function() {
shape.push({
name: "lineTo",
'arguments': arguments
});
},
arcTo: function() {
shape.push({
name: "arcTo",
'arguments': arguments
});
},
bezierCurveTo: function() {
shape.push({
name: "bezierCurveTo",
'arguments': arguments
});
},
quadraticCurveTo: function() {
shape.push({
name: "quadraticCurveTo",
'arguments': arguments
});
}
};
},
drawImage: function () {
storage.push({
type: "function",
name: "drawImage",
'arguments': arguments
});
},
fillText: function () {
storage.push({
type: "function",
name: "fillText",
'arguments': arguments
});
},
setVariable: function (variable, value) {
storage.push({
type: "variable",
name: variable,
'arguments': value
});
return value;
}
};
}

View File

@ -0,0 +1,101 @@
_html2canvas.Renderer = function(parseQueue, options){
// http://www.w3.org/TR/CSS21/zindex.html
function createRenderQueue(parseQueue) {
var queue = [],
rootContext;
rootContext = (function buildStackingContext(rootNode) {
var rootContext = {};
function insert(context, node, specialParent) {
var zi = (node.zIndex.zindex === 'auto') ? 0 : Number(node.zIndex.zindex),
contextForChildren = context, // the stacking context for children
isPositioned = node.zIndex.isPositioned,
isFloated = node.zIndex.isFloated,
stub = {node: node},
childrenDest = specialParent; // where children without z-index should be pushed into
if (node.zIndex.ownStacking) {
// '!' comes before numbers in sorted array
contextForChildren = stub.context = { '!': [{node:node, children: []}]};
childrenDest = undefined;
} else if (isPositioned || isFloated) {
childrenDest = stub.children = [];
}
if (zi === 0 && specialParent) {
specialParent.push(stub);
} else {
if (!context[zi]) { context[zi] = []; }
context[zi].push(stub);
}
node.zIndex.children.forEach(function(childNode) {
insert(contextForChildren, childNode, childrenDest);
});
}
insert(rootContext, rootNode);
return rootContext;
})(parseQueue);
function sortZ(context) {
Object.keys(context).sort().forEach(function(zi) {
var nonPositioned = [],
floated = [],
positioned = [],
list = [];
// positioned after static
context[zi].forEach(function(v) {
if (v.node.zIndex.isPositioned || v.node.zIndex.opacity < 1) {
// http://www.w3.org/TR/css3-color/#transparency
// non-positioned element with opactiy < 1 should be stacked as if it were a positioned element with z-index: 0 and opacity: 1.
positioned.push(v);
} else if (v.node.zIndex.isFloated) {
floated.push(v);
} else {
nonPositioned.push(v);
}
});
(function walk(arr) {
arr.forEach(function(v) {
list.push(v);
if (v.children) { walk(v.children); }
});
})(nonPositioned.concat(floated, positioned));
list.forEach(function(v) {
if (v.context) {
sortZ(v.context);
} else {
queue.push(v.node);
}
});
});
}
sortZ(rootContext);
return queue;
}
function getRenderer(rendererName) {
var renderer;
if (typeof options.renderer === "string" && _html2canvas.Renderer[rendererName] !== undefined) {
renderer = _html2canvas.Renderer[rendererName](options);
} else if (typeof rendererName === "function") {
renderer = rendererName(options);
} else {
throw new Error("Unknown renderer");
}
if ( typeof renderer !== "function" ) {
throw new Error("Invalid renderer defined");
}
return renderer;
}
return getRenderer(options.renderer)(parseQueue, options, document, createRenderQueue(parseQueue.stack), _html2canvas);
};

View File

@ -0,0 +1,63 @@
_html2canvas.Util.Support = function (options, doc) {
function supportSVGRendering() {
var img = new Image(),
canvas = doc.createElement("canvas"),
ctx = (canvas.getContext === undefined) ? false : canvas.getContext("2d");
if (ctx === false) {
return false;
}
canvas.width = canvas.height = 10;
img.src = [
"data:image/svg+xml,",
"<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10'>",
"<foreignObject width='10' height='10'>",
"<div xmlns='http://www.w3.org/1999/xhtml' style='width:10;height:10;'>",
"sup",
"</div>",
"</foreignObject>",
"</svg>"
].join("");
try {
ctx.drawImage(img, 0, 0);
canvas.toDataURL();
} catch(e) {
return false;
}
_html2canvas.Util.log('html2canvas: Parse: SVG powered rendering available');
return true;
}
// Test whether we can use ranges to measure bounding boxes
// Opera doesn't provide valid bounds.height/bottom even though it supports the method.
function supportRangeBounds() {
var r, testElement, rangeBounds, rangeHeight, support = false;
if (doc.createRange) {
r = doc.createRange();
if (r.getBoundingClientRect) {
testElement = doc.createElement('boundtest');
testElement.style.height = "123px";
testElement.style.display = "block";
doc.body.appendChild(testElement);
r.selectNode(testElement);
rangeBounds = r.getBoundingClientRect();
rangeHeight = rangeBounds.height;
if (rangeHeight === 123) {
support = true;
}
doc.body.removeChild(testElement);
}
}
return support;
}
return {
rangeBounds: supportRangeBounds(),
svgRendering: options.svgRendering && supportSVGRendering()
};
};

View File

@ -0,0 +1,81 @@
window.html2canvas = function(elements, opts) {
elements = (elements.length) ? elements : [elements];
var queue,
canvas,
options = {
// general
logging: false,
elements: elements,
background: "#fff",
// preload options
proxy: null,
timeout: 0, // no timeout
useCORS: false, // try to load images as CORS (where available), before falling back to proxy
allowTaint: false, // whether to allow images to taint the canvas, won't need proxy if set to true
// parse options
svgRendering: false, // use svg powered rendering where available (FF11+)
ignoreElements: "IFRAME|OBJECT|PARAM",
useOverflow: true,
letterRendering: false,
chinese: false,
// render options
width: null,
height: null,
taintTest: true, // do a taint test with all images before applying to canvas
renderer: "Canvas"
};
options = _html2canvas.Util.Extend(opts, options);
_html2canvas.logging = options.logging;
options.complete = function( images ) {
if (typeof options.onpreloaded === "function") {
if ( options.onpreloaded( images ) === false ) {
return;
}
}
queue = _html2canvas.Parse( images, options );
if (typeof options.onparsed === "function") {
if ( options.onparsed( queue ) === false ) {
return;
}
}
canvas = _html2canvas.Renderer( queue, options );
if (typeof options.onrendered === "function") {
options.onrendered( canvas );
}
};
// for pages without images, we still want this to be async, i.e. return methods before executing
window.setTimeout( function(){
_html2canvas.Preload( options );
}, 0 );
return {
render: function( queue, opts ) {
return _html2canvas.Renderer( queue, _html2canvas.Util.Extend(opts, options) );
},
parse: function( images, opts ) {
return _html2canvas.Parse( images, _html2canvas.Util.Extend(opts, options) );
},
preload: function( opts ) {
return _html2canvas.Preload( _html2canvas.Util.Extend(opts, options) );
},
log: _html2canvas.Util.log
};
};
window.html2canvas.log = _html2canvas.Util.log; // for renderers
window.html2canvas.Renderer = {
Canvas: undefined // We are assuming this will be used
};

View File

@ -0,0 +1,128 @@
_html2canvas.Renderer.Canvas = function(options) {
options = options || {};
var doc = document,
safeImages = [],
testCanvas = document.createElement("canvas"),
testctx = testCanvas.getContext("2d"),
Util = _html2canvas.Util,
canvas = options.canvas || doc.createElement('canvas');
function createShape(ctx, args) {
ctx.beginPath();
args.forEach(function(arg) {
ctx[arg.name].apply(ctx, arg['arguments']);
});
ctx.closePath();
}
function safeImage(item) {
if (safeImages.indexOf(item['arguments'][0].src ) === -1) {
testctx.drawImage(item['arguments'][0], 0, 0);
try {
testctx.getImageData(0, 0, 1, 1);
} catch(e) {
testCanvas = doc.createElement("canvas");
testctx = testCanvas.getContext("2d");
return false;
}
safeImages.push(item['arguments'][0].src);
}
return true;
}
function renderItem(ctx, item) {
switch(item.type){
case "variable":
ctx[item.name] = item['arguments'];
break;
case "function":
switch(item.name) {
case "createPattern":
if (item['arguments'][0].width > 0 && item['arguments'][0].height > 0) {
try {
ctx.fillStyle = ctx.createPattern(item['arguments'][0], "repeat");
}
catch(e) {
Util.log("html2canvas: Renderer: Error creating pattern", e.message);
}
}
break;
case "drawShape":
createShape(ctx, item['arguments']);
break;
case "drawImage":
if (item['arguments'][8] > 0 && item['arguments'][7] > 0) {
if (!options.taintTest || (options.taintTest && safeImage(item))) {
ctx.drawImage.apply( ctx, item['arguments'] );
}
}
break;
default:
ctx[item.name].apply(ctx, item['arguments']);
}
break;
}
}
return function(parsedData, options, document, queue, _html2canvas) {
var ctx = canvas.getContext("2d"),
newCanvas,
bounds,
fstyle,
zStack = parsedData.stack;
canvas.width = canvas.style.width = options.width || zStack.ctx.width;
canvas.height = canvas.style.height = options.height || zStack.ctx.height;
fstyle = ctx.fillStyle;
ctx.fillStyle = (Util.isTransparent(zStack.backgroundColor) && options.background !== undefined) ? options.background : parsedData.backgroundColor;
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = fstyle;
queue.forEach(function(storageContext) {
// set common settings for canvas
ctx.textBaseline = "bottom";
ctx.save();
if (storageContext.transform.matrix) {
ctx.translate(storageContext.transform.origin[0], storageContext.transform.origin[1]);
ctx.transform.apply(ctx, storageContext.transform.matrix);
ctx.translate(-storageContext.transform.origin[0], -storageContext.transform.origin[1]);
}
if (storageContext.clip){
ctx.beginPath();
ctx.rect(storageContext.clip.left, storageContext.clip.top, storageContext.clip.width, storageContext.clip.height);
ctx.clip();
}
if (storageContext.ctx.storage) {
storageContext.ctx.storage.forEach(function(item) {
renderItem(ctx, item);
});
}
ctx.restore();
});
Util.log("html2canvas: Renderer: Canvas renderer done - returning canvas obj");
if (options.elements.length === 1) {
if (typeof options.elements[0] === "object" && options.elements[0].nodeName !== "BODY") {
// crop image to the bounds of selected (single) element
bounds = _html2canvas.Util.Bounds(options.elements[0]);
newCanvas = document.createElement('canvas');
newCanvas.width = Math.ceil(bounds.width);
newCanvas.height = Math.ceil(bounds.height);
ctx = newCanvas.getContext("2d");
ctx.drawImage(canvas, bounds.left, bounds.top, bounds.width, bounds.height, 0, 0, bounds.width, bounds.height);
canvas = null;
return newCanvas;
}
}
return canvas;
};
};

View File

@ -0,0 +1,206 @@
/*
html2canvas @VERSION@ <http://html2canvas.hertzen.com>
Copyright (c) 2011 Niklas von Hertzen. All rights reserved.
http://www.twitter.com/niklasvh
Released under MIT License
*/
// WARNING THIS file is outdated, and hasn't been tested in quite a while
_html2canvas.Renderer.SVG = function( options ) {
options = options || {};
var doc = document,
svgNS = "http://www.w3.org/2000/svg",
svg = doc.createElementNS(svgNS, "svg"),
xlinkNS = "http://www.w3.org/1999/xlink",
defs = doc.createElementNS(svgNS, "defs"),
i,
a,
queueLen,
storageLen,
storageContext,
renderItem,
el,
settings = {},
text,
fontStyle,
clipId = 0,
methods;
methods = {
_create: function( zStack, options, doc, queue, _html2canvas ) {
svg.setAttribute("version", "1.1");
svg.setAttribute("baseProfile", "full");
svg.setAttribute("viewBox", "0 0 " + Math.max(zStack.ctx.width, options.width) + " " + Math.max(zStack.ctx.height, options.height));
svg.setAttribute("width", Math.max(zStack.ctx.width, options.width) + "px");
svg.setAttribute("height", Math.max(zStack.ctx.height, options.height) + "px");
svg.setAttribute("preserveAspectRatio", "none");
svg.appendChild(defs);
for (i = 0, queueLen = queue.length; i < queueLen; i+=1){
storageContext = queue.splice(0, 1)[0];
storageContext.canvasPosition = storageContext.canvasPosition || {};
//this.canvasRenderContext(storageContext,parentctx);
/*
if (storageContext.clip){
ctx.save();
ctx.beginPath();
// console.log(storageContext);
ctx.rect(storageContext.clip.left, storageContext.clip.top, storageContext.clip.width, storageContext.clip.height);
ctx.clip();
}*/
if (storageContext.ctx.storage){
for (a = 0, storageLen = storageContext.ctx.storage.length; a < storageLen; a+=1){
renderItem = storageContext.ctx.storage[a];
switch(renderItem.type){
case "variable":
settings[renderItem.name] = renderItem['arguments'];
break;
case "function":
if (renderItem.name === "fillRect") {
el = doc.createElementNS(svgNS, "rect");
el.setAttribute("x", renderItem['arguments'][0]);
el.setAttribute("y", renderItem['arguments'][1]);
el.setAttribute("width", renderItem['arguments'][2]);
el.setAttribute("height", renderItem['arguments'][3]);
el.setAttribute("fill", settings.fillStyle);
svg.appendChild(el);
} else if(renderItem.name === "fillText") {
el = doc.createElementNS(svgNS, "text");
fontStyle = settings.font.split(" ");
el.style.fontVariant = fontStyle.splice(0, 1)[0];
el.style.fontWeight = fontStyle.splice(0, 1)[0];
el.style.fontStyle = fontStyle.splice(0, 1)[0];
el.style.fontSize = fontStyle.splice(0, 1)[0];
el.setAttribute("x", renderItem['arguments'][1]);
el.setAttribute("y", renderItem['arguments'][2] - (parseInt(el.style.fontSize, 10) + 3));
el.setAttribute("fill", settings.fillStyle);
// TODO get proper baseline
el.style.dominantBaseline = "text-before-edge";
el.style.fontFamily = fontStyle.join(" ");
text = doc.createTextNode(renderItem['arguments'][0]);
el.appendChild(text);
svg.appendChild(el);
} else if(renderItem.name === "drawImage") {
if (renderItem['arguments'][8] > 0 && renderItem['arguments'][7]){
// TODO check whether even any clipping is necessary for this particular image
el = doc.createElementNS(svgNS, "clipPath");
el.setAttribute("id", "clipId" + clipId);
text = doc.createElementNS(svgNS, "rect");
text.setAttribute("x", renderItem['arguments'][5] );
text.setAttribute("y", renderItem['arguments'][6]);
text.setAttribute("width", renderItem['arguments'][3]);
text.setAttribute("height", renderItem['arguments'][4]);
el.appendChild(text);
defs.appendChild(el);
el = doc.createElementNS(svgNS, "image");
el.setAttributeNS(xlinkNS, "xlink:href", renderItem['arguments'][0].src);
el.setAttribute("width", renderItem['arguments'][7]);
el.setAttribute("height", renderItem['arguments'][8]);
el.setAttribute("x", renderItem['arguments'][5]);
el.setAttribute("y", renderItem['arguments'][6]);
el.setAttribute("clip-path", "url(#clipId" + clipId + ")");
// el.setAttribute("xlink:href", );
el.setAttribute("preserveAspectRatio", "none");
svg.appendChild(el);
clipId += 1;
/*
ctx.drawImage(
renderItem['arguments'][0],
renderItem['arguments'][1],
renderItem['arguments'][2],
renderItem['arguments'][3],
renderItem['arguments'][4],
renderItem['arguments'][5],
renderItem['arguments'][6],
renderItem['arguments'][7],
renderItem['arguments'][8]
);
*/
}
}
break;
default:
}
}
}
/*
if (storageContext.clip){
ctx.restore();
}
*/
}
_html2canvas.Util.log("html2canvas: Renderer: SVG Renderer done - returning SVG DOM obj");
return svg;
}
};
return methods;
};

37
Apollo/bower_components/jsPDF/.bower.json vendored Executable file
View File

@ -0,0 +1,37 @@
{
"name": "jspdf",
"homepage": "https://github.com/mrrio/jspdf",
"description": "PDF Document creation from JavaScript",
"main": "dist/jspdf.debug.js",
"moduleType": [
"amd",
"globals"
],
"keywords": [
"pdf"
],
"license": "MIT",
"ignore": [
"**/.*",
"libs",
"CNAME",
"jspdf.js",
"examples/jspdf.PLUGINTEMPLATE.js",
"plugins/*",
"todo.txt",
"wscript.py",
"build.sh",
"test",
"tools"
],
"version": "1.3.5",
"_release": "1.3.5",
"_resolution": {
"type": "version",
"tag": "v1.3.5",
"commit": "ff30727c294bc1e91f4eeac97bf73108f4794c84"
},
"_source": "git://github.com/MrRio/jsPDF.git",
"_target": "*",
"_originalSource": "git://github.com/MrRio/jsPDF.git"
}

View File

@ -0,0 +1,46 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at james@parall.ax. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/

View File

@ -0,0 +1,53 @@
#Hotfixes
We sometimes bake-in solutions (A.K.A. hotfixes) to solve issues for specific use cases.
When we deem a hotfix will not break existing code,
will make it default behaviour and mark the hotfix as _accepted_,
At that point the define can be removed.
To enable a hotfix, define the following member of your created PDF,
where the pdf.hotfix field is the name of the hotfix.
var pdf new jsPDF(...);
pdf.hotfix.fill_close = true;
# Active Hotfixes
## px_scaling
### Applies To
jsPDF Core
### Description
When supplying 'px' as the unit for the PDF, the internal scaling factor was being miscalculated making drawn components
larger than they should be. Enabling this hotfix will correct this scaling calculation and items will be drawn to the
correct scale.
### To Enable
To enable this hotfix, supply a 'hotfixes' array to the options object in the jsPDF constructor function, and add the
string 'px_scaling' to this array.
#Accepted Hotfixes
## scale_text
### Applies To
context2d plugin
### Affects
Drawing and Filling Text when a scale transformation is active.
### Description
jsPDF currently has no way to draw scaled text.
This hotfix scales the current font size by the x-axis scale factor.
## fill_close
### Applies To
context2d plugin
### Affects
Filling paths
### Description
In certain cases, closing a fill would result in a path resolving to an incorrect point.
The was most likely fixed when we refactored matrix logic. Enabling this hotfix will ignore a most-likely unneeded workaround.

View File

@ -0,0 +1,13 @@
Thank you for submitting an issue to jsPDF. Please read carefully.
**Are you using the latest version of jsPDF?**
**Have you tried using jspdf.debug.js?**
**Steps to reproduce**
Ideally a link too. Try fork this http://jsbin.com/rilace/edit?html,js,output
**What I saw**
**What I expected**

20
Apollo/bower_components/jsPDF/MIT-LICENSE.txt vendored Executable file
View File

@ -0,0 +1,20 @@
Copyright (c) 2010-2016 James Hall, https://github.com/MrRio/jsPDF
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

95
Apollo/bower_components/jsPDF/README.md vendored Executable file
View File

@ -0,0 +1,95 @@
# jsPDF
[![Greenkeeper badge](https://badges.greenkeeper.io/MrRio/jsPDF.svg)](https://greenkeeper.io/)
[![Build Status](https://saucelabs.com/buildstatus/jspdf)](https://saucelabs.com/beta/builds/526e7fda50bd4f97a854bf10f280305d)
[![Code Climate](https://codeclimate.com/repos/57f943855cdc43705e00592f/badges/2665cddeba042dc5191f/gpa.svg)](https://codeclimate.com/repos/57f943855cdc43705e00592f/feed) [![Test Coverage](https://codeclimate.com/repos/57f943855cdc43705e00592f/badges/2665cddeba042dc5191f/coverage.svg)](https://codeclimate.com/repos/57f943855cdc43705e00592f/coverage)
**A library to generate PDFs in client-side JavaScript.**
You can [catch me on twitter](http://twitter.com/MrRio): [@MrRio](http://twitter.com/MrRio) or head over to [my company's website](http://parall.ax) for consultancy.
## [Live Demo](http://rawgit.com/MrRio/jsPDF/master/) | [Documentation](http://rawgit.com/MrRio/jsPDF/master/docs/)
## Creating your first document
The easiest way to get started is to drop the CDN hosted library into your page:
```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.4/jspdf.debug.js"></script>
```
or can always get latest version via [unpkg](https://unpkg.com/#/)
```html
<script src="https://unpkg.com/jspdf@latest/dist/jspdf.min.js"></script>
```
NPM
```bash
npm i jspdf --save
```
Bower
```bash
bower install jspdf --save
```
Then you're ready to start making your document:
```javascript
// Default export is a4 paper, portrait, using milimeters for units
var doc = new jsPDF()
doc.text('Hello world!', 10, 10)
doc.save('a4.pdf')
```
If you want to change the paper size, orientation, or units, you can do:
```javascript
// Landscape export, 2×4 inches
var doc = new jsPDF({
orientation: 'landscape',
unit: 'in',
format: [4, 2]
})
doc.text('Hello world!', 1, 1)
doc.save('two-by-four.pdf')
```
Great! Now give us a Star :)
## Contributing
Build the library with `npm run build`. This will fetch all dependencies and then compile the `dist` files. To see the examples locally you can start a web server with `npm start` and go to `localhost:8000`.
## Credits
- Big thanks to Daniel Dotsenko from [Willow Systems Corporation](http://willow-systems.com) for making huge contributions to the codebase.
- Thanks to Ajaxian.com for [featuring us back in 2009](http://ajaxian.com/archives/dynamically-generic-pdfs-with-javascript).
- Everyone else that's contributed patches or bug reports. You rock.
## License (MIT)
Copyright (c) 2010-2017 James Hall, https://github.com/MrRio/jsPDF
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

11
Apollo/bower_components/jsPDF/RELEASE.md vendored Executable file
View File

@ -0,0 +1,11 @@
Release Instructions
====================
PLEASE DO NOT POST A RELEASE UNLESS YOU HAVE ACCESS TO NPM
- Add a new draft release in GitHub.
- Describe the Release
- Update the CDN link in the README (@TODO: Automate?)
- `npm version 1.x.y`
- git push origin v1.x.y
- Publish the release on GitHub
- `npm publish`

27
Apollo/bower_components/jsPDF/bower.json vendored Executable file
View File

@ -0,0 +1,27 @@
{
"name": "jspdf",
"homepage": "https://github.com/mrrio/jspdf",
"description": "PDF Document creation from JavaScript",
"main": "dist/jspdf.debug.js",
"moduleType": [
"amd",
"globals"
],
"keywords": [
"pdf"
],
"license": "MIT",
"ignore": [
"**/.*",
"libs",
"CNAME",
"jspdf.js",
"examples/jspdf.PLUGINTEMPLATE.js",
"plugins/*",
"todo.txt",
"wscript.py",
"build.sh",
"test",
"tools"
]
}

110
Apollo/bower_components/jsPDF/build.js vendored Executable file
View File

@ -0,0 +1,110 @@
'use strict'
var fs = require('fs')
var rollup = require('rollup')
var uglify = require('uglify-js')
var babel = require('rollup-plugin-babel')
var execSync = require('child_process').execSync
bundle({
minified: 'dist/jspdf.min.js',
debug: 'dist/jspdf.debug.js'
})
// Monkey patching adler32 and filesaver
function monkeyPatch () {
return {
transform: (code, id) => {
var file = id.split('/').pop()
if (file === 'adler32cs.js') {
code = code.replace(/this, function/g, 'jsPDF, function')
code = code.replace(/require\('buffer'\)/g, '{}')
}
return code
}
}
}
// Rollup removes local variables unless used within a module.
// This plugin makes sure specified local variables are preserved
// and kept local. This plugin wouldn't be necessary if es2015
// modules would be used.
function rawjs (opts) {
opts = opts || {}
return {
transform: (code, id) => {
var variable = opts[id.split('/').pop()]
if (!variable) return code
var keepStr = '/*rollup-keeper-start*/window.tmp=' + variable +
';/*rollup-keeper-end*/'
return code + keepStr
},
transformBundle: (code) => {
for (var file in opts) {
var r = new RegExp(opts[file] + '\\$\\d+', 'g')
code = code.replace(r, opts[file])
}
var re = /\/\*rollup-keeper-start\*\/.*\/\*rollup-keeper-end\*\//g
return code.replace(re, '')
}
}
}
function bundle (paths) {
rollup.rollup({
entry: './main.js',
plugins: [
monkeyPatch(),
rawjs({
'jspdf.js': 'jsPDF',
'filesaver.tmp.js': 'saveAs',
'deflate.js': 'Deflater',
'zlib.js': 'FlateStream',
'css_colors.js': 'CssColors',
'html2pdf.js': 'html2pdf'
}),
babel({
presets: ['es2015-rollup'],
exclude: ['node_modules/**', 'libs/**']
})
]
}).then((bundle) => {
return bundle.generate({
format: 'umd',
moduleName: 'jspdf'
})
}).then(output => {
let code = output.code
code = code.replace(
/Permission\s+is\s+hereby\s+granted[\S\s]+?IN\s+THE\s+SOFTWARE\./,
'Licensed under the MIT License'
)
code = code.replace(
/Permission\s+is\s+hereby\s+granted[\S\s]+?IN\s+THE\s+SOFTWARE\./g,
''
)
fs.writeFileSync(paths.debug, renew(code))
var minified = uglify.minify(code, {
output: {
comments: /@preserve|@license|copyright/i
}
})
fs.writeFileSync(paths.minified, renew(minified.code))
}).catch((err) => {
console.error(err)
})
}
function renew (code) {
var date = new Date().toISOString()
var version = require('./package.json').version
var whoami = execSync('whoami').toString().trim()
var commit = execSync('git rev-parse --short=10 HEAD').toString().trim()
code = code.replace('${versionID}', version + ' Built on ' + date)
code = code.replace('${commitID}', commit)
code = code.replace(/1\.0\.0-trunk/, version + ' ' + date + ':' + whoami)
return code
}

17089
Apollo/bower_components/jsPDF/dist/jspdf.debug.js vendored Executable file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,273 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>FontObject - Documentation</title>
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="FontObject.html">FontObject</a></li><li><a href="jsPDF.html">jsPDF</a></li><li><a href="PubSub.html">PubSub</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addFont">addFont</a></li><li><a href="global.html#addMetadata">addMetadata</a></li><li><a href="global.html#addPage">addPage</a></li><li><a href="global.html#CapJoinStyles">CapJoinStyles</a></li><li><a href="global.html#circle">circle</a></li><li><a href="global.html#CssColors">CssColors</a></li><li><a href="global.html#ellipse">ellipse</a></li><li><a href="global.html#getFontList">getFontList</a></li><li><a href="global.html#html2pdf">html2pdf</a></li><li><a href="global.html#http">http</a></li><li><a href="global.html#lines">lines</a></li><li><a href="global.html#lstext">lstext</a></li><li><a href="global.html#output">output</a></li><li><a href="global.html#rect">rect</a></li><li><a href="global.html#requirejs">requirejs</a></li><li><a href="global.html#reset">reset</a></li><li><a href="global.html#roundedRect">roundedRect</a></li><li><a href="global.html#save">save</a></li><li><a href="global.html#setDisplayMode">setDisplayMode</a></li><li><a href="global.html#setDrawColor">setDrawColor</a></li><li><a href="global.html#setFillColor">setFillColor</a></li><li><a href="global.html#setFont">setFont</a></li><li><a href="global.html#setFontSize">setFontSize</a></li><li><a href="global.html#setFontStyle">setFontStyle</a></li><li><a href="global.html#setLineCap">setLineCap</a></li><li><a href="global.html#setLineJoin">setLineJoin</a></li><li><a href="global.html#setLineWidth">setLineWidth</a></li><li><a href="global.html#setPage">setPage</a></li><li><a href="global.html#setProperties">setProperties</a></li><li><a href="global.html#setTextColor">setTextColor</a></li><li><a href="global.html#text">text</a></li><li><a href="global.html#toUrl">toUrl</a></li><li><a href="global.html#triangle">triangle</a></li><li><a href="global.html#triggerEvent">triggerEvent</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">FontObject</h1>
<section>
<header>
<h2>
FontObject
</h2>
</header>
<article>
<div class="container-overview">
<h4 class="name" id="FontObject"><span class="type-signature"></span>new FontObject<span class="signature">()</span><span class="type-signature"></span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="jspdf.js.html">jspdf.js</a>, <a href="jspdf.js.html#line419">line 419</a>
</li></ul></dd>
</dl>
<h5 class="subsection-title">Properties:</h5>
<table class="props">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>id</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last"><p>PDF-document-instance-specific label assinged to the font.</p></td>
</tr>
<tr>
<td class="name"><code>PostScriptName</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last"><p>PDF specification full name for the font</p></td>
</tr>
<tr>
<td class="name"><code>encoding</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"><p>Encoding_name-to-Font_metrics_object mapping.</p></td>
</tr>
</tbody>
</table>
<div class="description">
<p>FontObject describes a particular font as member of an instnace of jsPDF</p>
<p>It's a collection of properties like 'id' (to be used in PDF stream),
'fontName' (font's family name), 'fontStyle' (font's style variant label)</p>
</div>
</div>
</article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.2</a> on Sat Oct 08 2016 21:42:26 GMT+0100 (BST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/linenumber.js"></script>
</body>
</html>

176
Apollo/bower_components/jsPDF/docs/PubSub.html vendored Executable file
View File

@ -0,0 +1,176 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>PubSub - Documentation</title>
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="FontObject.html">FontObject</a></li><li><a href="jsPDF.html">jsPDF</a></li><li><a href="PubSub.html">PubSub</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addFont">addFont</a></li><li><a href="global.html#addMetadata">addMetadata</a></li><li><a href="global.html#addPage">addPage</a></li><li><a href="global.html#CapJoinStyles">CapJoinStyles</a></li><li><a href="global.html#circle">circle</a></li><li><a href="global.html#CssColors">CssColors</a></li><li><a href="global.html#ellipse">ellipse</a></li><li><a href="global.html#getFontList">getFontList</a></li><li><a href="global.html#html2pdf">html2pdf</a></li><li><a href="global.html#http">http</a></li><li><a href="global.html#lines">lines</a></li><li><a href="global.html#lstext">lstext</a></li><li><a href="global.html#output">output</a></li><li><a href="global.html#rect">rect</a></li><li><a href="global.html#requirejs">requirejs</a></li><li><a href="global.html#reset">reset</a></li><li><a href="global.html#roundedRect">roundedRect</a></li><li><a href="global.html#save">save</a></li><li><a href="global.html#setDisplayMode">setDisplayMode</a></li><li><a href="global.html#setDrawColor">setDrawColor</a></li><li><a href="global.html#setFillColor">setFillColor</a></li><li><a href="global.html#setFont">setFont</a></li><li><a href="global.html#setFontSize">setFontSize</a></li><li><a href="global.html#setFontStyle">setFontStyle</a></li><li><a href="global.html#setLineCap">setLineCap</a></li><li><a href="global.html#setLineJoin">setLineJoin</a></li><li><a href="global.html#setLineWidth">setLineWidth</a></li><li><a href="global.html#setPage">setPage</a></li><li><a href="global.html#setProperties">setProperties</a></li><li><a href="global.html#setTextColor">setTextColor</a></li><li><a href="global.html#text">text</a></li><li><a href="global.html#toUrl">toUrl</a></li><li><a href="global.html#triangle">triangle</a></li><li><a href="global.html#triggerEvent">triggerEvent</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">PubSub</h1>
<section>
<header>
<h2>
PubSub
</h2>
</header>
<article>
<div class="container-overview">
<h4 class="name" id="PubSub"><span class="type-signature"></span>new PubSub<span class="signature">()</span><span class="type-signature"></span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="jspdf.js.html">jspdf.js</a>, <a href="jspdf.js.html#line105">line 105</a>
</li></ul></dd>
</dl>
<div class="description">
<p>jsPDF's Internal PubSub Implementation.
See mrrio.github.io/jsPDF/doc/symbols/PubSub.html
Backward compatible rewritten on 2014 by
Diego Casorran, https://github.com/diegocr</p>
</div>
</div>
</article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.2</a> on Sat Oct 08 2016 21:42:26 GMT+0100 (BST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/linenumber.js"></script>
</body>
</html>

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,219 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>examples/js/test_harness.js - Documentation</title>
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="FontObject.html">FontObject</a></li><li><a href="jsPDF.html">jsPDF</a></li><li><a href="PubSub.html">PubSub</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addFont">addFont</a></li><li><a href="global.html#addMetadata">addMetadata</a></li><li><a href="global.html#addPage">addPage</a></li><li><a href="global.html#CapJoinStyles">CapJoinStyles</a></li><li><a href="global.html#circle">circle</a></li><li><a href="global.html#CssColors">CssColors</a></li><li><a href="global.html#ellipse">ellipse</a></li><li><a href="global.html#getFontList">getFontList</a></li><li><a href="global.html#html2pdf">html2pdf</a></li><li><a href="global.html#init">init</a></li><li><a href="global.html#jsPDFEditor">jsPDFEditor</a></li><li><a href="global.html#lines">lines</a></li><li><a href="global.html#output">output</a></li><li><a href="global.html#pdf_test_harness_init">pdf_test_harness_init</a></li><li><a href="global.html#rect">rect</a></li><li><a href="global.html#requirejs">requirejs</a></li><li><a href="global.html#reset">reset</a></li><li><a href="global.html#roundedRect">roundedRect</a></li><li><a href="global.html#save">save</a></li><li><a href="global.html#setDrawColor">setDrawColor</a></li><li><a href="global.html#setFillColor">setFillColor</a></li><li><a href="global.html#setFont">setFont</a></li><li><a href="global.html#setFontSize">setFontSize</a></li><li><a href="global.html#setFontStyle">setFontStyle</a></li><li><a href="global.html#setLineCap">setLineCap</a></li><li><a href="global.html#setLineJoin">setLineJoin</a></li><li><a href="global.html#setLineWidth">setLineWidth</a></li><li><a href="global.html#setProperties">setProperties</a></li><li><a href="global.html#setTextColor">setTextColor</a></li><li><a href="global.html#text">text</a></li><li><a href="global.html#toUrl">toUrl</a></li><li><a href="global.html#triangle">triangle</a></li><li><a href="global.html#triggerEvent">triggerEvent</a></li><li><a href="global.html#update">update</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">examples/js/test_harness.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>/**
* jsPDF PDF Test Harness
* Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv
*
* Licensed under the MIT License.
* http://opensource.org/licenses/mit-license
*/
/**
* An easy way to view PDF and PDF source code side by side.
*/
pdf_test_harness_init = function(pdf, message) {
var harness = new pdf_test_harness();
var body = document.getElementsByTagName('body')[0];
body.style.display = 'flex';
var div = document.createElement('div');
div.setAttribute('style', 'position:fixed;height:20px;left:0;right:0;background:lightblue');
body.appendChild(div);
harness.header = div;
var div2 = document.createElement('div');
div2.setAttribute('style', 'position:fixed;display:flex;top:20px; bottom:0;left:0;right:0');
body.appendChild(div2);
harness.body = div2;
var btn1 = document.createElement('input');
btn1.setAttribute('type', 'radio');
btn1.setAttribute('name', 'view');
div.appendChild(btn1);
btn1.checked = true;
var lbl1 = document.createElement('label');
lbl1.setAttribute('for', 'btn1');
lbl1.innerHTML = 'PDF'
div.appendChild(lbl1);
var btn2 = document.createElement('input');
btn2.setAttribute('type', 'radio');
btn2.setAttribute('name', 'view');
div.appendChild(btn2);
var lbl2 = document.createElement('label');
lbl2.setAttribute('for', 'btn2');
lbl2.innerHTML = 'Source'
div.appendChild(lbl2);
var btn3 = document.createElement('input');
btn3.setAttribute('type', 'radio');
btn3.setAttribute('name', 'view');
div.appendChild(btn3);
var lbl3 = document.createElement('label');
lbl3.setAttribute('for', 'btn3');
lbl3.innerHTML = 'Both'
div.appendChild(lbl3);
harness.source = document.createElement('pre');
harness.source.setAttribute('style', 'margin-top:0;width:100%;height:100%;position:absolute;top:0px;bottom:0px;overflow:auto');
div2.appendChild(harness.source);
harness.iframe = document.createElement('iframe');
harness.iframe.setAttribute('style', 'width:100%;height:100%;position:absolute;overflow:auto;top:0px;bottom:0px');
div2.appendChild(harness.iframe);
//if (pdf_test_harness.onload) {
//harness.pdf = pdf_test_harness.onload(harness);
if (message) {
message += "&lt;p style='text-align:center;font-style:italic;font-size:.8em'>click to close&lt;/p>";
var popup = document.createElement('div');
popup.setAttribute('style', 'z-index:100;margin:100px auto;cursor:pointer;font-size:1.3em;top:50px;background-color:rgb(243, 224, 141);padding:1em;border:1px solid black');
popup.innerHTML = message;
body.appendChild(popup);
popup.onclick = function() {
popup.parentNode.removeChild(popup);
}
}
//}
harness.pdf = pdf;
harness.render('pdf');
btn1.onclick = function() {
harness.render('pdf');
}
btn2.onclick = function() {
harness.render('source');
}
btn3.onclick = function() {
harness.render('both');
}
return harness;
}
pdf_test_harness = function(pdf) {
this.pdf = pdf;
this.onload = undefined;
this.iframe = undefined;
this.entityMap = {
"&amp;" : "&amp;amp;",
"&lt;" : "&amp;lt;",
">" : "&amp;gt;",
'"' : '&amp;quot;',
"'" : '&amp;#39;',
"/" : '&amp;#x2F;'
};
this.escapeHtml = function(string) {
return String(string).replace(/[&amp;&lt;>"'\/]/g, function(s) {
return this.entityMap[s];
}.bind(this));
};
this.getParameterByName = function(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&amp;]" + name + "=([^&amp;#]*)"), results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
};
this.setPdf = function(pdf) {
this.pdf = pdf;
this.rendered = undefined;
this.render(this.view);
};
// generate the pdf, the source code, or both
this.render = function(view) {
this.view = view;
//Current code only lets us render one time.
if (!this.rendered) {
this.rendered = this.pdf.output('datauristring');
this.iframe.src = this.rendered;
var raw = this.pdf.output();
raw = this.escapeHtml(raw);
this.source.innerHTML = raw;
}
if ('pdf' === view) {
this.source.style.display = 'none';
this.iframe.style.display = 'block';
this.iframe.style.width = '100%';
} else if ('source' === view) {
this.iframe.style.display = 'none';
this.source.style.display = 'block';
this.source.style.width = '100%';
}
if ('both' === view) {
raw = this.escapeHtml(raw);
this.iframe.style.width = '50%';
this.iframe.style.position = 'relative';
this.iframe.style.display = 'inline-block';
this.source.style.width = '50%';
this.source.style.position = 'relative';
this.source.style.display = 'inline-block';
}
}
}
</code></pre>
</article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.1</a> on Mon Oct 03 2016 12:36:18 GMT+0100 (BST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/linenumber.js"></script>
</body>
</html>

View File

@ -0,0 +1,5 @@
# Getting Started
We're currently updating our documentation. Watch this space!
http://mrrio.github.io/jsPDF/doc/symbols/jsPDF.html

5426
Apollo/bower_components/jsPDF/docs/global.html vendored Executable file

File diff suppressed because it is too large Load Diff

111
Apollo/bower_components/jsPDF/docs/index.html vendored Executable file
View File

@ -0,0 +1,111 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Home - Documentation</title>
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="jsPDF.html">jsPDF</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addFont">addFont</a></li><li><a href="global.html#addHTML">addHTML</a></li><li><a href="global.html#addMetadata">addMetadata</a></li><li><a href="global.html#addPage">addPage</a></li><li><a href="global.html#autoPrint">autoPrint</a></li><li><a href="global.html#CapJoinStyles">CapJoinStyles</a></li><li><a href="global.html#circle">circle</a></li><li><a href="global.html#ellipse">ellipse</a></li><li><a href="global.html#getFontList">getFontList</a></li><li><a href="global.html#lines">lines</a></li><li><a href="global.html#lstext">lstext</a></li><li><a href="global.html#output">output</a></li><li><a href="global.html#rect">rect</a></li><li><a href="global.html#roundedRect">roundedRect</a></li><li><a href="global.html#save">save</a></li><li><a href="global.html#setDisplayMode">setDisplayMode</a></li><li><a href="global.html#setDrawColor">setDrawColor</a></li><li><a href="global.html#setFillColor">setFillColor</a></li><li><a href="global.html#setFont">setFont</a></li><li><a href="global.html#setFontSize">setFontSize</a></li><li><a href="global.html#setFontStyle">setFontStyle</a></li><li><a href="global.html#setLineCap">setLineCap</a></li><li><a href="global.html#setLineJoin">setLineJoin</a></li><li><a href="global.html#setLineWidth">setLineWidth</a></li><li><a href="global.html#setPage">setPage</a></li><li><a href="global.html#setProperties">setProperties</a></li><li><a href="global.html#setTextColor">setTextColor</a></li><li><a href="global.html#text">text</a></li><li><a href="global.html#triangle">triangle</a></li></ul>
</nav>
<div id="main">
<section class="readme">
<article><h1>jsPDF</h1><p><a href="https://greenkeeper.io/"><img src="https://badges.greenkeeper.io/MrRio/jsPDF.svg" alt="Greenkeeper badge"></a></p>
<p><a href="https://saucelabs.com/beta/builds/526e7fda50bd4f97a854bf10f280305d"><img src="https://saucelabs.com/buildstatus/jspdf" alt="Build Status"></a></p>
<p><a href="https://codeclimate.com/repos/57f943855cdc43705e00592f/feed"><img src="https://codeclimate.com/repos/57f943855cdc43705e00592f/badges/2665cddeba042dc5191f/gpa.svg" alt="Code Climate"></a> <a href="https://codeclimate.com/repos/57f943855cdc43705e00592f/coverage"><img src="https://codeclimate.com/repos/57f943855cdc43705e00592f/badges/2665cddeba042dc5191f/coverage.svg" alt="Test Coverage"></a></p>
<p><strong>A library to generate PDFs in client-side JavaScript.</strong></p>
<p>You can <a href="http://twitter.com/MrRio">catch me on twitter</a>: <a href="http://twitter.com/MrRio">@MrRio</a> or head over to <a href="http://parall.ax">my company's website</a> for consultancy.</p>
<h2><a href="http://rawgit.com/MrRio/jsPDF/master/">Live Demo</a> | <a href="http://rawgit.com/MrRio/jsPDF/master/docs/">Documentation</a></h2><h2>Creating your first document</h2><p>The easiest way to get started is to drop the CDN hosted library into your page:</p>
<pre class="prettyprint source lang-html"><code>&lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.4/jspdf.debug.js&quot;>&lt;/script></code></pre><p>Then you're ready to start making your document:</p>
<pre class="prettyprint source lang-javascript"><code>// Default export is a4 paper, portrait, using milimeters for units
var doc = new jsPDF()
doc.text('Hello world!', 10, 10)
doc.save('a4.pdf')</code></pre><p>If you want to change the paper size, orientation, or units, you can do:</p>
<pre class="prettyprint source lang-javascript"><code>// Landscape export, 2×4 inches
var doc = new jsPDF({
orientation: 'landscape',
unit: 'in',
format: [4, 2]
})
doc.text('Hello world!', 1, 1)
doc.save('two-by-four.pdf')</code></pre><p>Great! Now give us a Star :)</p>
<h2>Contributing</h2><p>Build the library with <code>npm run build</code>. This will fetch all dependencies and then compile the <code>dist</code> files. To see the examples locally you can start a web server with <code>npm start</code> and go to <code>localhost:8000</code>.</p>
<h2>Credits</h2><ul>
<li>Big thanks to Daniel Dotsenko from <a href="http://willow-systems.com">Willow Systems Corporation</a> for making huge contributions to the codebase.</li>
<li>Thanks to Ajaxian.com for <a href="http://ajaxian.com/archives/dynamically-generic-pdfs-with-javascript">featuring us back in 2009</a>.</li>
<li>Everyone else that's contributed patches or bug reports. You rock.</li>
</ul>
<h2>License (MIT)</h2><p>Copyright (c) 2010-2017 James Hall, https://github.com/MrRio/jsPDF</p>
<p>Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
&quot;Software&quot;), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:</p>
<p>The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.</p>
<p>THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p></article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.3</a> on Sat Jul 29 2017 10:16:38 GMT+0100 (BST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/linenumber.js"></script>
</body>
</html>

365
Apollo/bower_components/jsPDF/docs/jsPDF.html vendored Executable file
View File

@ -0,0 +1,365 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jsPDF - Documentation</title>
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="jsPDF.html">jsPDF</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addFont">addFont</a></li><li><a href="global.html#addHTML">addHTML</a></li><li><a href="global.html#addMetadata">addMetadata</a></li><li><a href="global.html#addPage">addPage</a></li><li><a href="global.html#autoPrint">autoPrint</a></li><li><a href="global.html#CapJoinStyles">CapJoinStyles</a></li><li><a href="global.html#circle">circle</a></li><li><a href="global.html#ellipse">ellipse</a></li><li><a href="global.html#getFontList">getFontList</a></li><li><a href="global.html#lines">lines</a></li><li><a href="global.html#lstext">lstext</a></li><li><a href="global.html#output">output</a></li><li><a href="global.html#rect">rect</a></li><li><a href="global.html#roundedRect">roundedRect</a></li><li><a href="global.html#save">save</a></li><li><a href="global.html#setDisplayMode">setDisplayMode</a></li><li><a href="global.html#setDrawColor">setDrawColor</a></li><li><a href="global.html#setFillColor">setFillColor</a></li><li><a href="global.html#setFont">setFont</a></li><li><a href="global.html#setFontSize">setFontSize</a></li><li><a href="global.html#setFontStyle">setFontStyle</a></li><li><a href="global.html#setLineCap">setLineCap</a></li><li><a href="global.html#setLineJoin">setLineJoin</a></li><li><a href="global.html#setLineWidth">setLineWidth</a></li><li><a href="global.html#setPage">setPage</a></li><li><a href="global.html#setProperties">setProperties</a></li><li><a href="global.html#setTextColor">setTextColor</a></li><li><a href="global.html#text">text</a></li><li><a href="global.html#triangle">triangle</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">jsPDF</h1>
<section>
<header>
<h2>
jsPDF
</h2>
</header>
<article>
<div class="container-overview">
<h4 class="name" id="jsPDF"><span class="type-signature"></span>new jsPDF<span class="signature">(orientation, unit, format)</span><span class="type-signature"> &rarr; {<a href="jsPDF.html">jsPDF</a>}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="jspdf.js.html">jspdf.js</a>, <a href="jspdf.js.html#line47">line 47</a>
</li></ul></dd>
</dl>
<div class="description">
<p>If the first parameter (orientation) is an object, it will be interpreted as an object of named parameters</p>
<pre class="prettyprint source"><code>{
orientation: 'p',
unit: 'mm',
format: 'a4',
hotfixes: [] // an array of hotfix strings to enable
}</code></pre>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>orientation</code></td>
<td class="type">
</td>
<td class="description last"><p>One of &quot;portrait&quot; or &quot;landscape&quot; (or shortcuts &quot;p&quot; (Default), &quot;l&quot;) <br />
Can also be an options object.</p></td>
</tr>
<tr>
<td class="name"><code>unit</code></td>
<td class="type">
</td>
<td class="description last"><p>Measurement unit to be used when coordinates are specified.
One of &quot;pt&quot; (points), &quot;mm&quot; (Default), &quot;cm&quot;, &quot;in&quot;</p></td>
</tr>
<tr>
<td class="name"><code>format</code></td>
<td class="type">
</td>
<td class="description last"><p>One of 'pageFormats' as shown below, default: a4</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="jsPDF.html">jsPDF</a></span>
</dd>
</dl>
</div>
<h3 class="subsection-title">Members</h3>
<h4 class="name" id=".API"><span class="type-signature">(static) </span>API<span class="type-signature"></span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="jspdf.js.html">jspdf.js</a>, <a href="jspdf.js.html#line2244">line 2244</a>
</li></ul></dd>
</dl>
<div class="description">
<p>jsPDF.API is a STATIC property of jsPDF class.
jsPDF.API is an object you can add methods and properties to.
The methods / properties you add will show up in new jsPDF objects.</p>
<p>One property is prepopulated. It is the 'events' Object. Plugin authors can add topics,
callbacks to this object. These will be reassigned to all new instances of jsPDF.
Examples:
jsPDF.API.events['initialized'] = function(){ 'this' is API object }
jsPDF.API.events['addFont'] = function(added_font_object){ 'this' is API object }</p>
</div>
<h5>Example</h5>
<pre class="prettyprint"><code>jsPDF.API.mymethod = function(){
// 'this' will be ref to internal API object. see jsPDF source
// , so you can refer to built-in methods like so:
// this.line(....)
// this.text(....)
}
var pdfdoc = new jsPDF()
pdfdoc.mymethod() // &lt;- !!!!!!</code></pre>
</article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.3</a> on Sat Jul 29 2017 10:16:38 GMT+0100 (BST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/linenumber.js"></script>
</body>
</html>

2344
Apollo/bower_components/jsPDF/docs/jspdf.js.html vendored Executable file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,221 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>libs/css_colors.js - Documentation</title>
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="FontObject.html">FontObject</a></li><li><a href="jsPDF.html">jsPDF</a></li><li><a href="PubSub.html">PubSub</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addFont">addFont</a></li><li><a href="global.html#addMetadata">addMetadata</a></li><li><a href="global.html#addPage">addPage</a></li><li><a href="global.html#CapJoinStyles">CapJoinStyles</a></li><li><a href="global.html#circle">circle</a></li><li><a href="global.html#CssColors">CssColors</a></li><li><a href="global.html#ellipse">ellipse</a></li><li><a href="global.html#getFontList">getFontList</a></li><li><a href="global.html#html2pdf">html2pdf</a></li><li><a href="global.html#http">http</a></li><li><a href="global.html#lines">lines</a></li><li><a href="global.html#lstext">lstext</a></li><li><a href="global.html#output">output</a></li><li><a href="global.html#rect">rect</a></li><li><a href="global.html#requirejs">requirejs</a></li><li><a href="global.html#reset">reset</a></li><li><a href="global.html#roundedRect">roundedRect</a></li><li><a href="global.html#save">save</a></li><li><a href="global.html#setDisplayMode">setDisplayMode</a></li><li><a href="global.html#setDrawColor">setDrawColor</a></li><li><a href="global.html#setFillColor">setFillColor</a></li><li><a href="global.html#setFont">setFont</a></li><li><a href="global.html#setFontSize">setFontSize</a></li><li><a href="global.html#setFontStyle">setFontStyle</a></li><li><a href="global.html#setLineCap">setLineCap</a></li><li><a href="global.html#setLineJoin">setLineJoin</a></li><li><a href="global.html#setLineWidth">setLineWidth</a></li><li><a href="global.html#setPage">setPage</a></li><li><a href="global.html#setProperties">setProperties</a></li><li><a href="global.html#setTextColor">setTextColor</a></li><li><a href="global.html#text">text</a></li><li><a href="global.html#toUrl">toUrl</a></li><li><a href="global.html#triangle">triangle</a></li><li><a href="global.html#triggerEvent">triggerEvent</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">libs/css_colors.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>/**
* CssColors
* Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv
*
* Licensed under the MIT License.
* http://opensource.org/licenses/mit-license
*/
/**
* Usage CssColors('red');
* Returns RGB hex color with '#' prefix
*/
var CssColors = {};
CssColors._colorsTable = {
"aliceblue" : "#f0f8ff",
"antiquewhite" : "#faebd7",
"aqua" : "#00ffff",
"aquamarine" : "#7fffd4",
"azure" : "#f0ffff",
"beige" : "#f5f5dc",
"bisque" : "#ffe4c4",
"black" : "#000000",
"blanchedalmond" : "#ffebcd",
"blue" : "#0000ff",
"blueviolet" : "#8a2be2",
"brown" : "#a52a2a",
"burlywood" : "#deb887",
"cadetblue" : "#5f9ea0",
"chartreuse" : "#7fff00",
"chocolate" : "#d2691e",
"coral" : "#ff7f50",
"cornflowerblue" : "#6495ed",
"cornsilk" : "#fff8dc",
"crimson" : "#dc143c",
"cyan" : "#00ffff",
"darkblue" : "#00008b",
"darkcyan" : "#008b8b",
"darkgoldenrod" : "#b8860b",
"darkgray" : "#a9a9a9",
"darkgreen" : "#006400",
"darkkhaki" : "#bdb76b",
"darkmagenta" : "#8b008b",
"darkolivegreen" : "#556b2f",
"darkorange" : "#ff8c00",
"darkorchid" : "#9932cc",
"darkred" : "#8b0000",
"darksalmon" : "#e9967a",
"darkseagreen" : "#8fbc8f",
"darkslateblue" : "#483d8b",
"darkslategray" : "#2f4f4f",
"darkturquoise" : "#00ced1",
"darkviolet" : "#9400d3",
"deeppink" : "#ff1493",
"deepskyblue" : "#00bfff",
"dimgray" : "#696969",
"dodgerblue" : "#1e90ff",
"firebrick" : "#b22222",
"floralwhite" : "#fffaf0",
"forestgreen" : "#228b22",
"fuchsia" : "#ff00ff",
"gainsboro" : "#dcdcdc",
"ghostwhite" : "#f8f8ff",
"gold" : "#ffd700",
"goldenrod" : "#daa520",
"gray" : "#808080",
"green" : "#008000",
"greenyellow" : "#adff2f",
"honeydew" : "#f0fff0",
"hotpink" : "#ff69b4",
"indianred " : "#cd5c5c",
"indigo" : "#4b0082",
"ivory" : "#fffff0",
"khaki" : "#f0e68c",
"lavender" : "#e6e6fa",
"lavenderblush" : "#fff0f5",
"lawngreen" : "#7cfc00",
"lemonchiffon" : "#fffacd",
"lightblue" : "#add8e6",
"lightcoral" : "#f08080",
"lightcyan" : "#e0ffff",
"lightgoldenrodyellow" : "#fafad2",
"lightgrey" : "#d3d3d3",
"lightgreen" : "#90ee90",
"lightpink" : "#ffb6c1",
"lightsalmon" : "#ffa07a",
"lightseagreen" : "#20b2aa",
"lightskyblue" : "#87cefa",
"lightslategray" : "#778899",
"lightsteelblue" : "#b0c4de",
"lightyellow" : "#ffffe0",
"lime" : "#00ff00",
"limegreen" : "#32cd32",
"linen" : "#faf0e6",
"magenta" : "#ff00ff",
"maroon" : "#800000",
"mediumaquamarine" : "#66cdaa",
"mediumblue" : "#0000cd",
"mediumorchid" : "#ba55d3",
"mediumpurple" : "#9370d8",
"mediumseagreen" : "#3cb371",
"mediumslateblue" : "#7b68ee",
"mediumspringgreen" : "#00fa9a",
"mediumturquoise" : "#48d1cc",
"mediumvioletred" : "#c71585",
"midnightblue" : "#191970",
"mintcream" : "#f5fffa",
"mistyrose" : "#ffe4e1",
"moccasin" : "#ffe4b5",
"navajowhite" : "#ffdead",
"navy" : "#000080",
"oldlace" : "#fdf5e6",
"olive" : "#808000",
"olivedrab" : "#6b8e23",
"orange" : "#ffa500",
"orangered" : "#ff4500",
"orchid" : "#da70d6",
"palegoldenrod" : "#eee8aa",
"palegreen" : "#98fb98",
"paleturquoise" : "#afeeee",
"palevioletred" : "#d87093",
"papayawhip" : "#ffefd5",
"peachpuff" : "#ffdab9",
"peru" : "#cd853f",
"pink" : "#ffc0cb",
"plum" : "#dda0dd",
"powderblue" : "#b0e0e6",
"purple" : "#800080",
"red" : "#ff0000",
"rosybrown" : "#bc8f8f",
"royalblue" : "#4169e1",
"saddlebrown" : "#8b4513",
"salmon" : "#fa8072",
"sandybrown" : "#f4a460",
"seagreen" : "#2e8b57",
"seashell" : "#fff5ee",
"sienna" : "#a0522d",
"silver" : "#c0c0c0",
"skyblue" : "#87ceeb",
"slateblue" : "#6a5acd",
"slategray" : "#708090",
"snow" : "#fffafa",
"springgreen" : "#00ff7f",
"steelblue" : "#4682b4",
"tan" : "#d2b48c",
"teal" : "#008080",
"thistle" : "#d8bfd8",
"tomato" : "#ff6347",
"turquoise" : "#40e0d0",
"violet" : "#ee82ee",
"wheat" : "#f5deb3",
"white" : "#ffffff",
"whitesmoke" : "#f5f5f5",
"yellow" : "#ffff00",
"yellowgreen" : "#9acd32"
};
CssColors.colorNameToHex = function(color) {
color = color.toLowerCase();
if (typeof this._colorsTable[color] != 'undefined')
return this._colorsTable[color];
return false;
};</code></pre>
</article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.2</a> on Sat Oct 08 2016 21:42:26 GMT+0100 (BST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/linenumber.js"></script>
</body>
</html>

View File

@ -0,0 +1,168 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>libs/html2pdf.js - Documentation</title>
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="FontObject.html">FontObject</a></li><li><a href="jsPDF.html">jsPDF</a></li><li><a href="PubSub.html">PubSub</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addFont">addFont</a></li><li><a href="global.html#addMetadata">addMetadata</a></li><li><a href="global.html#addPage">addPage</a></li><li><a href="global.html#CapJoinStyles">CapJoinStyles</a></li><li><a href="global.html#circle">circle</a></li><li><a href="global.html#CssColors">CssColors</a></li><li><a href="global.html#ellipse">ellipse</a></li><li><a href="global.html#getFontList">getFontList</a></li><li><a href="global.html#html2pdf">html2pdf</a></li><li><a href="global.html#http">http</a></li><li><a href="global.html#lines">lines</a></li><li><a href="global.html#lstext">lstext</a></li><li><a href="global.html#output">output</a></li><li><a href="global.html#rect">rect</a></li><li><a href="global.html#requirejs">requirejs</a></li><li><a href="global.html#reset">reset</a></li><li><a href="global.html#roundedRect">roundedRect</a></li><li><a href="global.html#save">save</a></li><li><a href="global.html#setDisplayMode">setDisplayMode</a></li><li><a href="global.html#setDrawColor">setDrawColor</a></li><li><a href="global.html#setFillColor">setFillColor</a></li><li><a href="global.html#setFont">setFont</a></li><li><a href="global.html#setFontSize">setFontSize</a></li><li><a href="global.html#setFontStyle">setFontStyle</a></li><li><a href="global.html#setLineCap">setLineCap</a></li><li><a href="global.html#setLineJoin">setLineJoin</a></li><li><a href="global.html#setLineWidth">setLineWidth</a></li><li><a href="global.html#setPage">setPage</a></li><li><a href="global.html#setProperties">setProperties</a></li><li><a href="global.html#setTextColor">setTextColor</a></li><li><a href="global.html#text">text</a></li><li><a href="global.html#toUrl">toUrl</a></li><li><a href="global.html#triangle">triangle</a></li><li><a href="global.html#triggerEvent">triggerEvent</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">libs/html2pdf.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>/**
* html2pdf.js
* Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv
*
* Licensed under the MIT License.
* http://opensource.org/licenses/mit-license
*/
function html2pdf (html,pdf,callback) {
var canvas = pdf.canvas;
if (!canvas) {
alert('jsPDF canvas plugin not installed');
return;
}
canvas.pdf = pdf;
pdf.annotations = {
_nameMap : [],
createAnnotation : function(href,bounds) {
var x = pdf.context2d._wrapX(bounds.left);
var y = pdf.context2d._wrapY(bounds.top);
var page = pdf.context2d._page(bounds.top);
var options;
var index = href.indexOf('#');
if (index >= 0) {
options = {
name : href.substring(index + 1)
};
} else {
options = {
url : href
};
}
pdf.link(x, y, bounds.right - bounds.left, bounds.bottom - bounds.top, options);
},
setName : function(name,bounds) {
var x = pdf.context2d._wrapX(bounds.left);
var y = pdf.context2d._wrapY(bounds.top);
var page = pdf.context2d._page(bounds.top);
this._nameMap[name] = {
page : page,
x : x,
y : y
};
}
};
canvas.annotations = pdf.annotations;
pdf.context2d._pageBreakAt = function(y) {
this.pageBreaks.push(y);
};
pdf.context2d._gotoPage = function(pageOneBased) {
while (pdf.internal.getNumberOfPages() &lt; pageOneBased) {
pdf.addPage();
}
pdf.setPage(pageOneBased);
}
if (typeof html === 'string') {
// remove all scripts
html = html.replace(/&lt;script\b[^&lt;]*(?:(?!&lt;\/script>)&lt;[^&lt;]*)*&lt;\/script>/gi, '');
var iframe = document.createElement('iframe');
//iframe.style.width = canvas.width;
//iframe.src = "";
//iframe.document.domain =
document.body.appendChild(iframe);
var doc;
doc = iframe.contentDocument;
if (doc == undefined || doc == null) {
doc = iframe.contentWindow.document;
}
//iframe.setAttribute('style', 'position:absolute;right:0; top:0; bottom:0; height:100%; width:500px');
doc.open();
doc.write(html);
doc.close();
var promise = html2canvas(doc.body, {
canvas : canvas,
onrendered : function(canvas) {
if (callback) {
if (iframe) {
iframe.parentElement.removeChild(iframe);
}
callback(pdf);
}
}
});
} else {
var body = html;
var promise = html2canvas(body, {
canvas : canvas,
onrendered : function(canvas) {
if (callback) {
if (iframe) {
iframe.parentElement.removeChild(iframe);
}
callback(pdf);
}
}
});
}
}
</code></pre>
</article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.2</a> on Sat Oct 08 2016 21:42:26 GMT+0100 (BST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/linenumber.js"></script>
</body>
</html>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,175 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>plugins/addhtml.js - Documentation</title>
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="jsPDF.html">jsPDF</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addFont">addFont</a></li><li><a href="global.html#addHTML">addHTML</a></li><li><a href="global.html#addMetadata">addMetadata</a></li><li><a href="global.html#addPage">addPage</a></li><li><a href="global.html#autoPrint">autoPrint</a></li><li><a href="global.html#CapJoinStyles">CapJoinStyles</a></li><li><a href="global.html#circle">circle</a></li><li><a href="global.html#ellipse">ellipse</a></li><li><a href="global.html#getFontList">getFontList</a></li><li><a href="global.html#lines">lines</a></li><li><a href="global.html#lstext">lstext</a></li><li><a href="global.html#output">output</a></li><li><a href="global.html#rect">rect</a></li><li><a href="global.html#roundedRect">roundedRect</a></li><li><a href="global.html#save">save</a></li><li><a href="global.html#setDisplayMode">setDisplayMode</a></li><li><a href="global.html#setDrawColor">setDrawColor</a></li><li><a href="global.html#setFillColor">setFillColor</a></li><li><a href="global.html#setFont">setFont</a></li><li><a href="global.html#setFontSize">setFontSize</a></li><li><a href="global.html#setFontStyle">setFontStyle</a></li><li><a href="global.html#setLineCap">setLineCap</a></li><li><a href="global.html#setLineJoin">setLineJoin</a></li><li><a href="global.html#setLineWidth">setLineWidth</a></li><li><a href="global.html#setPage">setPage</a></li><li><a href="global.html#setProperties">setProperties</a></li><li><a href="global.html#setTextColor">setTextColor</a></li><li><a href="global.html#text">text</a></li><li><a href="global.html#triangle">triangle</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">plugins/addhtml.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>/**
* jsPDF addHTML PlugIn
* Copyright (c) 2014 Diego Casorran
*
* Licensed under the MIT License.
* http://opensource.org/licenses/mit-license
*/
(function (jsPDFAPI) {
'use strict';
/**
* Renders an HTML element to canvas object which added to the PDF
*
* This feature requires [html2canvas](https://github.com/niklasvh/html2canvas)
* or [rasterizeHTML](https://github.com/cburgmer/rasterizeHTML.js)
*
* @returns {jsPDF}
* @name addHTML
* @param element {Mixed} HTML Element, or anything supported by html2canvas.
* @param x {Number} starting X coordinate in jsPDF instance's declared units.
* @param y {Number} starting Y coordinate in jsPDF instance's declared units.
* @param options {Object} Additional options, check the code below.
* @param callback {Function} to call when the rendering has finished.
* NOTE: Every parameter is optional except 'element' and 'callback', in such
* case the image is positioned at 0x0 covering the whole PDF document
* size. Ie, to easily take screenshots of webpages saving them to PDF.
* @deprecated This is being replace with a vector-supporting API. See
* [this link](https://cdn.rawgit.com/MrRio/jsPDF/master/examples/html2pdf/showcase_supported_html.html)
*/
jsPDFAPI.addHTML = function (element, x, y, options, callback) {
'use strict';
if(typeof html2canvas === 'undefined' &amp;&amp; typeof rasterizeHTML === 'undefined')
throw new Error('You need either '
+'https://github.com/niklasvh/html2canvas'
+' or https://github.com/cburgmer/rasterizeHTML.js');
if(typeof x !== 'number') {
options = x;
callback = y;
}
if(typeof options === 'function') {
callback = options;
options = null;
}
var I = this.internal, K = I.scaleFactor, W = I.pageSize.width, H = I.pageSize.height;
options = options || {};
options.onrendered = function(obj) {
x = parseInt(x) || 0;
y = parseInt(y) || 0;
var dim = options.dim || {};
var h = dim.h || 0;
var w = dim.w || Math.min(W,obj.width/K) - x;
var format = 'JPEG';
if(options.format)
format = options.format;
if(obj.height > H &amp;&amp; options.pagesplit) {
var crop = function() {
var cy = 0;
while(1) {
var canvas = document.createElement('canvas');
canvas.width = Math.min(W*K,obj.width);
canvas.height = Math.min(H*K,obj.height-cy);
var ctx = canvas.getContext('2d');
ctx.drawImage(obj,0,cy,obj.width,canvas.height,0,0,canvas.width,canvas.height);
var args = [canvas, x,cy?0:y,canvas.width/K,canvas.height/K, format,null,'SLOW'];
this.addImage.apply(this, args);
cy += canvas.height;
if(cy >= obj.height) break;
this.addPage();
}
callback(w,cy,null,args);
}.bind(this);
if(obj.nodeName === 'CANVAS') {
var img = new Image();
img.onload = crop;
img.src = obj.toDataURL("image/png");
obj = img;
} else {
crop();
}
} else {
var alias = Math.random().toString(35);
var args = [obj, x,y,w,h, format,alias,'SLOW'];
this.addImage.apply(this, args);
callback(w,h,alias,args);
}
}.bind(this);
if(typeof html2canvas !== 'undefined' &amp;&amp; !options.rstz) {
return html2canvas(element, options);
}
if(typeof rasterizeHTML !== 'undefined') {
var meth = 'drawDocument';
if(typeof element === 'string') {
meth = /^http/.test(element) ? 'drawURL' : 'drawHTML';
}
options.width = options.width || (W*K);
return rasterizeHTML[meth](element, void 0, options).then(function(r) {
options.onrendered(r.image);
}, function(e) {
callback(null,e);
});
}
return null;
};
})(jsPDF.API);
</code></pre>
</article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.3</a> on Sat Jul 29 2017 10:16:38 GMT+0100 (BST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/linenumber.js"></script>
</body>
</html>

View File

@ -0,0 +1,790 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>plugins/addimage.js - Documentation</title>
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="jsPDF.html">jsPDF</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addFont">addFont</a></li><li><a href="global.html#addHTML">addHTML</a></li><li><a href="global.html#addMetadata">addMetadata</a></li><li><a href="global.html#addPage">addPage</a></li><li><a href="global.html#autoPrint">autoPrint</a></li><li><a href="global.html#CapJoinStyles">CapJoinStyles</a></li><li><a href="global.html#circle">circle</a></li><li><a href="global.html#ellipse">ellipse</a></li><li><a href="global.html#getFontList">getFontList</a></li><li><a href="global.html#lines">lines</a></li><li><a href="global.html#lstext">lstext</a></li><li><a href="global.html#output">output</a></li><li><a href="global.html#rect">rect</a></li><li><a href="global.html#roundedRect">roundedRect</a></li><li><a href="global.html#save">save</a></li><li><a href="global.html#setDisplayMode">setDisplayMode</a></li><li><a href="global.html#setDrawColor">setDrawColor</a></li><li><a href="global.html#setFillColor">setFillColor</a></li><li><a href="global.html#setFont">setFont</a></li><li><a href="global.html#setFontSize">setFontSize</a></li><li><a href="global.html#setFontStyle">setFontStyle</a></li><li><a href="global.html#setLineCap">setLineCap</a></li><li><a href="global.html#setLineJoin">setLineJoin</a></li><li><a href="global.html#setLineWidth">setLineWidth</a></li><li><a href="global.html#setPage">setPage</a></li><li><a href="global.html#setProperties">setProperties</a></li><li><a href="global.html#setTextColor">setTextColor</a></li><li><a href="global.html#text">text</a></li><li><a href="global.html#triangle">triangle</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">plugins/addimage.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>/** @preserve
* jsPDF addImage plugin
* Copyright (c) 2012 Jason Siefken, https://github.com/siefkenj/
* 2013 Chris Dowling, https://github.com/gingerchris
* 2013 Trinh Ho, https://github.com/ineedfat
* 2013 Edwin Alejandro Perez, https://github.com/eaparango
* 2013 Norah Smith, https://github.com/burnburnrocket
* 2014 Diego Casorran, https://github.com/diegocr
* 2014 James Robb, https://github.com/jamesbrobb
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
;(function(jsPDFAPI) {
'use strict'
var namespace = 'addImage_',
supported_image_types = ['jpeg', 'jpg', 'png'];
// Image functionality ported from pdf.js
var putImage = function(img) {
var objectNumber = this.internal.newObject()
, out = this.internal.write
, putStream = this.internal.putStream
img['n'] = objectNumber
out('&lt;&lt;/Type /XObject')
out('/Subtype /Image')
out('/Width ' + img['w'])
out('/Height ' + img['h'])
if (img['cs'] === this.color_spaces.INDEXED) {
out('/ColorSpace [/Indexed /DeviceRGB '
// if an indexed png defines more than one colour with transparency, we've created a smask
+ (img['pal'].length / 3 - 1) + ' ' + ('smask' in img ? objectNumber + 2 : objectNumber + 1)
+ ' 0 R]');
} else {
out('/ColorSpace /' + img['cs']);
if (img['cs'] === this.color_spaces.DEVICE_CMYK) {
out('/Decode [1 0 1 0 1 0 1 0]');
}
}
out('/BitsPerComponent ' + img['bpc']);
if ('f' in img) {
out('/Filter /' + img['f']);
}
if ('dp' in img) {
out('/DecodeParms &lt;&lt;' + img['dp'] + '>>');
}
if ('trns' in img &amp;&amp; img['trns'].constructor == Array) {
var trns = '',
i = 0,
len = img['trns'].length;
for (; i &lt; len; i++)
trns += (img['trns'][i] + ' ' + img['trns'][i] + ' ');
out('/Mask [' + trns + ']');
}
if ('smask' in img) {
out('/SMask ' + (objectNumber + 1) + ' 0 R');
}
out('/Length ' + img['data'].length + '>>');
putStream(img['data']);
out('endobj');
// Soft mask
if ('smask' in img) {
var dp = '/Predictor '+ img['p'] +' /Colors 1 /BitsPerComponent ' + img['bpc'] + ' /Columns ' + img['w'];
var smask = {'w': img['w'], 'h': img['h'], 'cs': 'DeviceGray', 'bpc': img['bpc'], 'dp': dp, 'data': img['smask']};
if ('f' in img)
smask.f = img['f'];
putImage.call(this, smask);
}
//Palette
if (img['cs'] === this.color_spaces.INDEXED) {
this.internal.newObject();
//out('&lt;&lt; /Filter / ' + img['f'] +' /Length ' + img['pal'].length + '>>');
//putStream(zlib.compress(img['pal']));
out('&lt;&lt; /Length ' + img['pal'].length + '>>');
putStream(this.arrayBufferToBinaryString(new Uint8Array(img['pal'])));
out('endobj');
}
}
, putResourcesCallback = function() {
var images = this.internal.collections[namespace + 'images']
for ( var i in images ) {
putImage.call(this, images[i])
}
}
, putXObjectsDictCallback = function(){
var images = this.internal.collections[namespace + 'images']
, out = this.internal.write
, image
for (var i in images) {
image = images[i]
out(
'/I' + image['i']
, image['n']
, '0'
, 'R'
)
}
}
, checkCompressValue = function(value) {
if(value &amp;&amp; typeof value === 'string')
value = value.toUpperCase();
return value in jsPDFAPI.image_compression ? value : jsPDFAPI.image_compression.NONE;
}
, getImages = function() {
var images = this.internal.collections[namespace + 'images'];
//first run, so initialise stuff
if(!images) {
this.internal.collections[namespace + 'images'] = images = {};
this.internal.events.subscribe('putResources', putResourcesCallback);
this.internal.events.subscribe('putXobjectDict', putXObjectsDictCallback);
}
return images;
}
, getImageIndex = function(images) {
var imageIndex = 0;
if (images){
// this is NOT the first time this method is ran on this instance of jsPDF object.
imageIndex = Object.keys ?
Object.keys(images).length :
(function(o){
var i = 0
for (var e in o){if(o.hasOwnProperty(e)){ i++ }}
return i
})(images)
}
return imageIndex;
}
, notDefined = function(value) {
return typeof value === 'undefined' || value === null;
}
, generateAliasFromData = function(data) {
return typeof data === 'string' &amp;&amp; jsPDFAPI.sHashCode(data);
}
, doesNotSupportImageType = function(type) {
return supported_image_types.indexOf(type) === -1;
}
, processMethodNotEnabled = function(type) {
return typeof jsPDFAPI['process' + type.toUpperCase()] !== 'function';
}
, isDOMElement = function(object) {
return typeof object === 'object' &amp;&amp; object.nodeType === 1;
}
, createDataURIFromElement = function(element, format, angle) {
//if element is an image which uses data url definition, just return the dataurl
if (element.nodeName === 'IMG' &amp;&amp; element.hasAttribute('src')) {
var src = ''+element.getAttribute('src');
if (!angle &amp;&amp; src.indexOf('data:image/') === 0) return src;
// only if the user doesn't care about a format
if (!format &amp;&amp; /\.png(?:[?#].*)?$/i.test(src)) format = 'png';
}
if(element.nodeName === 'CANVAS') {
var canvas = element;
} else {
var canvas = document.createElement('canvas');
canvas.width = element.clientWidth || element.width;
canvas.height = element.clientHeight || element.height;
var ctx = canvas.getContext('2d');
if (!ctx) {
throw ('addImage requires canvas to be supported by browser.');
}
if (angle) {
var x, y, b, c, s, w, h, to_radians = Math.PI/180, angleInRadians;
if (typeof angle === 'object') {
x = angle.x;
y = angle.y;
b = angle.bg;
angle = angle.angle;
}
angleInRadians = angle*to_radians;
c = Math.abs(Math.cos(angleInRadians));
s = Math.abs(Math.sin(angleInRadians));
w = canvas.width;
h = canvas.height;
canvas.width = h * s + w * c;
canvas.height = h * c + w * s;
if (isNaN(x)) x = canvas.width / 2;
if (isNaN(y)) y = canvas.height / 2;
ctx.clearRect(0,0,canvas.width, canvas.height);
ctx.fillStyle = b || 'white';
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.save();
ctx.translate(x, y);
ctx.rotate(angleInRadians);
ctx.drawImage(element, -(w/2), -(h/2));
ctx.rotate(-angleInRadians);
ctx.translate(-x, -y);
ctx.restore();
} else {
ctx.drawImage(element, 0, 0, canvas.width, canvas.height);
}
}
return canvas.toDataURL((''+format).toLowerCase() == 'png' ? 'image/png' : 'image/jpeg');
}
,checkImagesForAlias = function(alias, images) {
var cached_info;
if(images) {
for(var e in images) {
if(alias === images[e].alias) {
cached_info = images[e];
break;
}
}
}
return cached_info;
}
,determineWidthAndHeight = function(w, h, info) {
if (!w &amp;&amp; !h) {
w = -96;
h = -96;
}
if (w &lt; 0) {
w = (-1) * info['w'] * 72 / w / this.internal.scaleFactor;
}
if (h &lt; 0) {
h = (-1) * info['h'] * 72 / h / this.internal.scaleFactor;
}
if (w === 0) {
w = h * info['w'] / info['h'];
}
if (h === 0) {
h = w * info['h'] / info['w'];
}
return [w, h];
}
, writeImageToPDF = function(x, y, w, h, info, index, images) {
var dims = determineWidthAndHeight.call(this, w, h, info),
coord = this.internal.getCoordinateString,
vcoord = this.internal.getVerticalCoordinateString;
w = dims[0];
h = dims[1];
images[index] = info;
this.internal.write(
'q'
, coord(w)
, '0 0'
, coord(h) // TODO: check if this should be shifted by vcoord
, coord(x)
, vcoord(y + h)
, 'cm /I'+info['i']
, 'Do Q'
)
};
/**
* COLOR SPACES
*/
jsPDFAPI.color_spaces = {
DEVICE_RGB:'DeviceRGB',
DEVICE_GRAY:'DeviceGray',
DEVICE_CMYK:'DeviceCMYK',
CAL_GREY:'CalGray',
CAL_RGB:'CalRGB',
LAB:'Lab',
ICC_BASED:'ICCBased',
INDEXED:'Indexed',
PATTERN:'Pattern',
SEPARATION:'Separation',
DEVICE_N:'DeviceN'
};
/**
* DECODE METHODS
*/
jsPDFAPI.decode = {
DCT_DECODE:'DCTDecode',
FLATE_DECODE:'FlateDecode',
LZW_DECODE:'LZWDecode',
JPX_DECODE:'JPXDecode',
JBIG2_DECODE:'JBIG2Decode',
ASCII85_DECODE:'ASCII85Decode',
ASCII_HEX_DECODE:'ASCIIHexDecode',
RUN_LENGTH_DECODE:'RunLengthDecode',
CCITT_FAX_DECODE:'CCITTFaxDecode'
};
/**
* IMAGE COMPRESSION TYPES
*/
jsPDFAPI.image_compression = {
NONE: 'NONE',
FAST: 'FAST',
MEDIUM: 'MEDIUM',
SLOW: 'SLOW'
};
jsPDFAPI.sHashCode = function(str) {
return Array.prototype.reduce &amp;&amp; str.split("").reduce(function(a,b){a=((a&lt;&lt;5)-a)+b.charCodeAt(0);return a&amp;a},0);
};
jsPDFAPI.isString = function(object) {
return typeof object === 'string';
};
/**
* Strips out and returns info from a valid base64 data URI
* @param {String[dataURI]} a valid data URI of format 'data:[&lt;MIME-type>][;base64],&lt;data>'
* @returns an Array containing the following
* [0] the complete data URI
* [1] &lt;MIME-type>
* [2] format - the second part of the mime-type i.e 'png' in 'image/png'
* [4] &lt;data>
*/
jsPDFAPI.extractInfoFromBase64DataURI = function(dataURI) {
return /^data:([\w]+?\/([\w]+?));base64,(.+?)$/g.exec(dataURI);
};
/**
* Check to see if ArrayBuffer is supported
*/
jsPDFAPI.supportsArrayBuffer = function() {
return typeof ArrayBuffer !== 'undefined' &amp;&amp; typeof Uint8Array !== 'undefined';
};
/**
* Tests supplied object to determine if ArrayBuffer
* @param {Object[object]}
*/
jsPDFAPI.isArrayBuffer = function(object) {
if(!this.supportsArrayBuffer())
return false;
return object instanceof ArrayBuffer;
};
/**
* Tests supplied object to determine if it implements the ArrayBufferView (TypedArray) interface
* @param {Object[object]}
*/
jsPDFAPI.isArrayBufferView = function(object) {
if(!this.supportsArrayBuffer())
return false;
if(typeof Uint32Array === 'undefined')
return false;
return (object instanceof Int8Array ||
object instanceof Uint8Array ||
(typeof Uint8ClampedArray !== 'undefined' &amp;&amp; object instanceof Uint8ClampedArray) ||
object instanceof Int16Array ||
object instanceof Uint16Array ||
object instanceof Int32Array ||
object instanceof Uint32Array ||
object instanceof Float32Array ||
object instanceof Float64Array );
};
/**
* Exactly what it says on the tin
*/
jsPDFAPI.binaryStringToUint8Array = function(binary_string) {
/*
* not sure how efficient this will be will bigger files. Is there a native method?
*/
var len = binary_string.length;
var bytes = new Uint8Array( len );
for (var i = 0; i &lt; len; i++) {
bytes[i] = binary_string.charCodeAt(i);
}
return bytes;
};
/**
* @see this discussion
* http://stackoverflow.com/questions/6965107/converting-between-strings-and-arraybuffers
*
* As stated, i imagine the method below is highly inefficent for large files.
*
* Also of note from Mozilla,
*
* "However, this is slow and error-prone, due to the need for multiple conversions (especially if the binary data is not actually byte-format data, but, for example, 32-bit integers or floats)."
*
* https://developer.mozilla.org/en-US/Add-ons/Code_snippets/StringView
*
* Although i'm strugglig to see how StringView solves this issue? Doesn't appear to be a direct method for conversion?
*
* Async method using Blob and FileReader could be best, but i'm not sure how to fit it into the flow?
*/
jsPDFAPI.arrayBufferToBinaryString = function(buffer) {
/*if('TextDecoder' in window){
var decoder = new TextDecoder('ascii');
return decoder.decode(buffer);
}*/
if(this.isArrayBuffer(buffer))
buffer = new Uint8Array(buffer);
var binary_string = '';
var len = buffer.byteLength;
for (var i = 0; i &lt; len; i++) {
binary_string += String.fromCharCode(buffer[i]);
}
return binary_string;
/*
* Another solution is the method below - convert array buffer straight to base64 and then use atob
*/
//return atob(this.arrayBufferToBase64(buffer));
};
/**
* Converts an ArrayBuffer directly to base64
*
* Taken from here
*
* http://jsperf.com/encoding-xhr-image-data/31
*
* Need to test if this is a better solution for larger files
*
*/
jsPDFAPI.arrayBufferToBase64 = function(arrayBuffer) {
var base64 = ''
var encodings = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
var bytes = new Uint8Array(arrayBuffer)
var byteLength = bytes.byteLength
var byteRemainder = byteLength % 3
var mainLength = byteLength - byteRemainder
var a, b, c, d
var chunk
// Main loop deals with bytes in chunks of 3
for (var i = 0; i &lt; mainLength; i = i + 3) {
// Combine the three bytes into a single integer
chunk = (bytes[i] &lt;&lt; 16) | (bytes[i + 1] &lt;&lt; 8) | bytes[i + 2]
// Use bitmasks to extract 6-bit segments from the triplet
a = (chunk &amp; 16515072) >> 18 // 16515072 = (2^6 - 1) &lt;&lt; 18
b = (chunk &amp; 258048) >> 12 // 258048 = (2^6 - 1) &lt;&lt; 12
c = (chunk &amp; 4032) >> 6 // 4032 = (2^6 - 1) &lt;&lt; 6
d = chunk &amp; 63 // 63 = 2^6 - 1
// Convert the raw binary segments to the appropriate ASCII encoding
base64 += encodings[a] + encodings[b] + encodings[c] + encodings[d]
}
// Deal with the remaining bytes and padding
if (byteRemainder == 1) {
chunk = bytes[mainLength]
a = (chunk &amp; 252) >> 2 // 252 = (2^6 - 1) &lt;&lt; 2
// Set the 4 least significant bits to zero
b = (chunk &amp; 3) &lt;&lt; 4 // 3 = 2^2 - 1
base64 += encodings[a] + encodings[b] + '=='
} else if (byteRemainder == 2) {
chunk = (bytes[mainLength] &lt;&lt; 8) | bytes[mainLength + 1]
a = (chunk &amp; 64512) >> 10 // 64512 = (2^6 - 1) &lt;&lt; 10
b = (chunk &amp; 1008) >> 4 // 1008 = (2^6 - 1) &lt;&lt; 4
// Set the 2 least significant bits to zero
c = (chunk &amp; 15) &lt;&lt; 2 // 15 = 2^4 - 1
base64 += encodings[a] + encodings[b] + encodings[c] + '='
}
return base64
};
jsPDFAPI.createImageInfo = function(data, wd, ht, cs, bpc, f, imageIndex, alias, dp, trns, pal, smask, p) {
var info = {
alias:alias,
w : wd,
h : ht,
cs : cs,
bpc : bpc,
i : imageIndex,
data : data
// n: objectNumber will be added by putImage code
};
if(f) info.f = f;
if(dp) info.dp = dp;
if(trns) info.trns = trns;
if(pal) info.pal = pal;
if(smask) info.smask = smask;
if(p) info.p = p;// predictor parameter for PNG compression
return info;
};
jsPDFAPI.addImage = function(imageData, format, x, y, w, h, alias, compression, rotation) {
'use strict'
if(typeof format !== 'string') {
var tmp = h;
h = w;
w = y;
y = x;
x = format;
format = tmp;
}
if (typeof imageData === 'object' &amp;&amp; !isDOMElement(imageData) &amp;&amp; "imageData" in imageData) {
var options = imageData;
imageData = options.imageData;
format = options.format || format;
x = options.x || x || 0;
y = options.y || y || 0;
w = options.w || w;
h = options.h || h;
alias = options.alias || alias;
compression = options.compression || compression;
rotation = options.rotation || options.angle || rotation;
}
if (isNaN(x) || isNaN(y))
{
console.error('jsPDF.addImage: Invalid coordinates', arguments);
throw new Error('Invalid coordinates passed to jsPDF.addImage');
}
var images = getImages.call(this), info;
if (!(info = checkImagesForAlias(imageData, images))) {
var dataAsBinaryString;
if(isDOMElement(imageData))
imageData = createDataURIFromElement(imageData, format, rotation);
if(notDefined(alias))
alias = generateAliasFromData(imageData);
if (!(info = checkImagesForAlias(alias, images))) {
if(this.isString(imageData)) {
var base64Info = this.extractInfoFromBase64DataURI(imageData);
if(base64Info) {
format = base64Info[2];
imageData = atob(base64Info[3]);//convert to binary string
} else {
if (imageData.charCodeAt(0) === 0x89 &amp;&amp;
imageData.charCodeAt(1) === 0x50 &amp;&amp;
imageData.charCodeAt(2) === 0x4e &amp;&amp;
imageData.charCodeAt(3) === 0x47 ) format = 'png';
}
}
format = (format || 'JPEG').toLowerCase();
if(doesNotSupportImageType(format))
throw new Error('addImage currently only supports formats ' + supported_image_types + ', not \''+format+'\'');
if(processMethodNotEnabled(format))
throw new Error('please ensure that the plugin for \''+format+'\' support is added');
/**
* need to test if it's more efficient to convert all binary strings
* to TypedArray - or should we just leave and process as string?
*/
if(this.supportsArrayBuffer()) {
// no need to convert if imageData is already uint8array
if(!(imageData instanceof Uint8Array)){
dataAsBinaryString = imageData;
imageData = this.binaryStringToUint8Array(imageData);
}
}
info = this['process' + format.toUpperCase()](
imageData,
getImageIndex(images),
alias,
checkCompressValue(compression),
dataAsBinaryString
);
if(!info)
throw new Error('An unkwown error occurred whilst processing the image');
}
}
writeImageToPDF.call(this, x, y, w, h, info, info.i, images);
return this
};
/**
* JPEG SUPPORT
**/
//takes a string imgData containing the raw bytes of
//a jpeg image and returns [width, height]
//Algorithm from: http://www.64lines.com/jpeg-width-height
var getJpegSize = function(imgData) {
'use strict'
var width, height, numcomponents;
// Verify we have a valid jpeg header 0xff,0xd8,0xff,0xe0,?,?,'J','F','I','F',0x00
if (!imgData.charCodeAt(0) === 0xff ||
!imgData.charCodeAt(1) === 0xd8 ||
!imgData.charCodeAt(2) === 0xff ||
!imgData.charCodeAt(3) === 0xe0 ||
!imgData.charCodeAt(6) === 'J'.charCodeAt(0) ||
!imgData.charCodeAt(7) === 'F'.charCodeAt(0) ||
!imgData.charCodeAt(8) === 'I'.charCodeAt(0) ||
!imgData.charCodeAt(9) === 'F'.charCodeAt(0) ||
!imgData.charCodeAt(10) === 0x00) {
throw new Error('getJpegSize requires a binary string jpeg file')
}
var blockLength = imgData.charCodeAt(4)*256 + imgData.charCodeAt(5);
var i = 4, len = imgData.length;
while ( i &lt; len ) {
i += blockLength;
if (imgData.charCodeAt(i) !== 0xff) {
throw new Error('getJpegSize could not find the size of the image');
}
if (imgData.charCodeAt(i+1) === 0xc0 || //(SOF) Huffman - Baseline DCT
imgData.charCodeAt(i+1) === 0xc1 || //(SOF) Huffman - Extended sequential DCT
imgData.charCodeAt(i+1) === 0xc2 || // Progressive DCT (SOF2)
imgData.charCodeAt(i+1) === 0xc3 || // Spatial (sequential) lossless (SOF3)
imgData.charCodeAt(i+1) === 0xc4 || // Differential sequential DCT (SOF5)
imgData.charCodeAt(i+1) === 0xc5 || // Differential progressive DCT (SOF6)
imgData.charCodeAt(i+1) === 0xc6 || // Differential spatial (SOF7)
imgData.charCodeAt(i+1) === 0xc7) {
height = imgData.charCodeAt(i+5)*256 + imgData.charCodeAt(i+6);
width = imgData.charCodeAt(i+7)*256 + imgData.charCodeAt(i+8);
numcomponents = imgData.charCodeAt(i+9);
return [width, height, numcomponents];
} else {
i += 2;
blockLength = imgData.charCodeAt(i)*256 + imgData.charCodeAt(i+1)
}
}
}
, getJpegSizeFromBytes = function(data) {
var hdr = (data[0] &lt;&lt; 8) | data[1];
if(hdr !== 0xFFD8)
throw new Error('Supplied data is not a JPEG');
var len = data.length,
block = (data[4] &lt;&lt; 8) + data[5],
pos = 4,
bytes, width, height, numcomponents;
while(pos &lt; len) {
pos += block;
bytes = readBytes(data, pos);
block = (bytes[2] &lt;&lt; 8) + bytes[3];
if((bytes[1] === 0xC0 || bytes[1] === 0xC2) &amp;&amp; bytes[0] === 0xFF &amp;&amp; block > 7) {
bytes = readBytes(data, pos + 5);
width = (bytes[2] &lt;&lt; 8) + bytes[3];
height = (bytes[0] &lt;&lt; 8) + bytes[1];
numcomponents = bytes[4];
return {width:width, height:height, numcomponents: numcomponents};
}
pos+=2;
}
throw new Error('getJpegSizeFromBytes could not find the size of the image');
}
, readBytes = function(data, offset) {
return data.subarray(offset, offset+ 5);
};
jsPDFAPI.processJPEG = function(data, index, alias, compression, dataAsBinaryString) {
'use strict'
var colorSpace = this.color_spaces.DEVICE_RGB,
filter = this.decode.DCT_DECODE,
bpc = 8,
dims;
if(this.isString(data)) {
dims = getJpegSize(data);
return this.createImageInfo(data, dims[0], dims[1], dims[3] == 1 ? this.color_spaces.DEVICE_GRAY:colorSpace, bpc, filter, index, alias);
}
if(this.isArrayBuffer(data))
data = new Uint8Array(data);
if(this.isArrayBufferView(data)) {
dims = getJpegSizeFromBytes(data);
// if we already have a stored binary string rep use that
data = dataAsBinaryString || this.arrayBufferToBinaryString(data);
return this.createImageInfo(data, dims.width, dims.height, dims.numcomponents == 1 ? this.color_spaces.DEVICE_GRAY:colorSpace, bpc, filter, index, alias);
}
return null;
};
jsPDFAPI.processJPG = function(/*data, index, alias, compression, dataAsBinaryString*/) {
return this.processJPEG.apply(this, arguments);
}
})(jsPDF.API);
</code></pre>
</article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.3</a> on Sat Jul 29 2017 10:16:38 GMT+0100 (BST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/linenumber.js"></script>
</body>
</html>

View File

@ -0,0 +1,330 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>plugins/annotations.js - Documentation</title>
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="jsPDF.html">jsPDF</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addFont">addFont</a></li><li><a href="global.html#addHTML">addHTML</a></li><li><a href="global.html#addMetadata">addMetadata</a></li><li><a href="global.html#addPage">addPage</a></li><li><a href="global.html#autoPrint">autoPrint</a></li><li><a href="global.html#CapJoinStyles">CapJoinStyles</a></li><li><a href="global.html#circle">circle</a></li><li><a href="global.html#ellipse">ellipse</a></li><li><a href="global.html#getFontList">getFontList</a></li><li><a href="global.html#lines">lines</a></li><li><a href="global.html#lstext">lstext</a></li><li><a href="global.html#output">output</a></li><li><a href="global.html#rect">rect</a></li><li><a href="global.html#roundedRect">roundedRect</a></li><li><a href="global.html#save">save</a></li><li><a href="global.html#setDisplayMode">setDisplayMode</a></li><li><a href="global.html#setDrawColor">setDrawColor</a></li><li><a href="global.html#setFillColor">setFillColor</a></li><li><a href="global.html#setFont">setFont</a></li><li><a href="global.html#setFontSize">setFontSize</a></li><li><a href="global.html#setFontStyle">setFontStyle</a></li><li><a href="global.html#setLineCap">setLineCap</a></li><li><a href="global.html#setLineJoin">setLineJoin</a></li><li><a href="global.html#setLineWidth">setLineWidth</a></li><li><a href="global.html#setPage">setPage</a></li><li><a href="global.html#setProperties">setProperties</a></li><li><a href="global.html#setTextColor">setTextColor</a></li><li><a href="global.html#text">text</a></li><li><a href="global.html#triangle">triangle</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">plugins/annotations.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>/**
* jsPDF Annotations PlugIn
* Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv
*
* Licensed under the MIT License.
* http://opensource.org/licenses/mit-license
*/
/**
* There are many types of annotations in a PDF document. Annotations are placed
* on a page at a particular location. They are not 'attached' to an object.
* &lt;br />
* This plugin current supports &lt;br />
* &lt;li> Goto Page (set pageNumber and top in options)
* &lt;li> Goto Name (set name and top in options)
* &lt;li> Goto URL (set url in options)
* &lt;p>
* The destination magnification factor can also be specified when goto is a page number or a named destination. (see documentation below)
* (set magFactor in options). XYZ is the default.
* &lt;/p>
* &lt;p>
* Links, Text, Popup, and FreeText are supported.
* &lt;/p>
* &lt;p>
* Options In PDF spec Not Implemented Yet
* &lt;li> link border
* &lt;li> named target
* &lt;li> page coordinates
* &lt;li> destination page scaling and layout
* &lt;li> actions other than URL and GotoPage
* &lt;li> background / hover actions
* &lt;/p>
*/
/*
Destination Magnification Factors
See PDF 1.3 Page 386 for meanings and options
[supported]
XYZ (options; left top zoom)
Fit (no options)
FitH (options: top)
FitV (options: left)
[not supported]
FitR
FitB
FitBH
FitBV
*/
(function(jsPDFAPI) {
'use strict';
var annotationPlugin = {
/**
* An array of arrays, indexed by &lt;em>pageNumber&lt;/em>.
*/
annotations : [],
f2 : function(number) {
return number.toFixed(2);
},
notEmpty : function(obj) {
if (typeof obj != 'undefined') {
if (obj != '') {
return true;
}
}
}
};
jsPDF.API.annotationPlugin = annotationPlugin;
jsPDF.API.events.push([ 'addPage', function(info) {
this.annotationPlugin.annotations[info.pageNumber] = [];
} ]);
jsPDFAPI.events.push([ 'putPage', function(info) {
//TODO store annotations in pageContext so reorder/remove will not affect them.
var pageAnnos = this.annotationPlugin.annotations[info.pageNumber];
var found = false;
for (var a = 0; a &lt; pageAnnos.length &amp;&amp; !found; a++) {
var anno = pageAnnos[a];
switch (anno.type) {
case 'link':
if (annotationPlugin.notEmpty(anno.options.url) || annotationPlugin.notEmpty(anno.options.pageNumber)) {
found = true;
break;
}
case 'reference':
case 'text':
case 'freetext':
found = true;
break;
}
}
if (found == false) {
return;
}
this.internal.write("/Annots [");
var f2 = this.annotationPlugin.f2;
var k = this.internal.scaleFactor;
var pageHeight = this.internal.pageSize.height;
var pageInfo = this.internal.getPageInfo(info.pageNumber);
for (var a = 0; a &lt; pageAnnos.length; a++) {
var anno = pageAnnos[a];
switch (anno.type) {
case 'reference':
// References to Widget Anotations (for AcroForm Fields)
this.internal.write(' ' + anno.object.objId + ' 0 R ');
break;
case 'text':
// Create a an object for both the text and the popup
var objText = this.internal.newAdditionalObject();
var objPopup = this.internal.newAdditionalObject();
var title = anno.title || 'Note';
var rect = "/Rect [" + f2(anno.bounds.x * k) + " " + f2(pageHeight - (anno.bounds.y + anno.bounds.h) * k) + " " + f2((anno.bounds.x + anno.bounds.w) * k) + " " + f2((pageHeight - anno.bounds.y) * k) + "] ";
line = '&lt;&lt;/Type /Annot /Subtype /' + 'Text' + ' ' + rect + '/Contents (' + anno.contents + ')';
line += ' /Popup ' + objPopup.objId + " 0 R";
line += ' /P ' + pageInfo.objId + " 0 R";
line += ' /T (' + title + ') >>';
objText.content = line;
var parent = objText.objId + ' 0 R';
var popoff = 30;
var rect = "/Rect [" + f2((anno.bounds.x + popoff) * k) + " " + f2(pageHeight - (anno.bounds.y + anno.bounds.h) * k) + " " + f2((anno.bounds.x + anno.bounds.w + popoff) * k) + " " + f2((pageHeight - anno.bounds.y) * k) + "] ";
//var rect2 = "/Rect [" + f2(anno.bounds.x * k) + " " + f2((pageHeight - anno.bounds.y) * k) + " " + f2(anno.bounds.x + anno.bounds.w * k) + " " + f2(pageHeight - (anno.bounds.y + anno.bounds.h) * k) + "] ";
line = '&lt;&lt;/Type /Annot /Subtype /' + 'Popup' + ' ' + rect + ' /Parent ' + parent;
if (anno.open) {
line += ' /Open true';
}
line += ' >>';
objPopup.content = line;
this.internal.write(objText.objId, '0 R', objPopup.objId, '0 R');
break;
case 'freetext':
var rect = "/Rect [" + f2(anno.bounds.x * k) + " " + f2((pageHeight - anno.bounds.y) * k) + " " + f2(anno.bounds.x + anno.bounds.w * k) + " " + f2(pageHeight - (anno.bounds.y + anno.bounds.h) * k) + "] ";
var color = anno.color || '#000000';
line = '&lt;&lt;/Type /Annot /Subtype /' + 'FreeText' + ' ' + rect + '/Contents (' + anno.contents + ')';
line += ' /DS(font: Helvetica,sans-serif 12.0pt; text-align:left; color:#' + color + ')';
line += ' /Border [0 0 0]';
line += ' >>';
this.internal.write(line);
break;
case 'link':
if (anno.options.name) {
var loc = this.annotations._nameMap[anno.options.name];
anno.options.pageNumber = loc.page;
anno.options.top = loc.y;
} else {
if (!anno.options.top) {
anno.options.top = 0;
}
}
var rect = "/Rect [" + f2(anno.x * k) + " " + f2((pageHeight - anno.y) * k) + " " + f2((anno.x + anno.w) * k) + " " + f2((pageHeight - (anno.y + anno.h)) * k) + "] ";
var line = '';
if (anno.options.url) {
line = '&lt;&lt;/Type /Annot /Subtype /Link ' + rect + '/Border [0 0 0] /A &lt;&lt;/S /URI /URI (' + anno.options.url + ') >>';
} else if (anno.options.pageNumber) {
// first page is 0
var info = this.internal.getPageInfo(anno.options.pageNumber);
line = '&lt;&lt;/Type /Annot /Subtype /Link ' + rect + '/Border [0 0 0] /Dest [' + info.objId + " 0 R";
anno.options.magFactor = anno.options.magFactor || "XYZ";
switch (anno.options.magFactor) {
case 'Fit':
line += ' /Fit]';
break;
case 'FitH':
//anno.options.top = anno.options.top || f2(pageHeight * k);
line += ' /FitH ' + anno.options.top + ']';
break;
case 'FitV':
anno.options.left = anno.options.left || 0;
line += ' /FitV ' + anno.options.left + ']';
break;
case 'XYZ':
default:
var top = f2((pageHeight - anno.options.top) * k);// || f2(pageHeight * k);
anno.options.left = anno.options.left || 0;
// 0 or null zoom will not change zoom factor
if (typeof anno.options.zoom === 'undefined') {
anno.options.zoom = 0;
}
line += ' /XYZ ' + anno.options.left + ' ' + top + ' ' + anno.options.zoom + ']';
break;
}
} else {
// TODO error - should not be here
}
if (line != '') {
line += " >>";
this.internal.write(line);
}
break;
}
}
this.internal.write("]");
} ]);
jsPDFAPI.createAnnotation = function(options) {
switch (options.type) {
case 'link':
this.link(options.bounds.x, options.bounds.y, options.bounds.w, options.bounds.h, options);
break;
case 'text':
case 'freetext':
this.annotationPlugin.annotations[this.internal.getCurrentPageInfo().pageNumber].push(options);
break;
}
}
/**
* valid options
* &lt;li> pageNumber or url [required]
* &lt;p>If pageNumber is specified, top and zoom may also be specified&lt;/p>
*/
jsPDFAPI.link = function(x,y,w,h,options) {
'use strict';
this.annotationPlugin.annotations[this.internal.getCurrentPageInfo().pageNumber].push({
x : x,
y : y,
w : w,
h : h,
options : options,
type : 'link'
});
};
/**
* Currently only supports single line text.
* Returns the width of the text/link
*/
jsPDFAPI.textWithLink = function(text,x,y,options) {
'use strict';
var width = this.getTextWidth(text);
var height = this.internal.getLineHeight() / this.internal.scaleFactor;
this.text(text, x, y);
//TODO We really need the text baseline height to do this correctly.
// Or ability to draw text on top, bottom, center, or baseline.
y += height * .2;
this.link(x, y - height, width, height, options);
return width;
};
//TODO move into external library
jsPDFAPI.getTextWidth = function(text) {
'use strict';
var fontSize = this.internal.getFontSize();
var txtWidth = this.getStringUnitWidth(text) * fontSize / this.internal.scaleFactor;
return txtWidth;
};
//TODO move into external library
jsPDFAPI.getLineHeight = function() {
return this.internal.getLineHeight();
};
return this;
})(jsPDF.API);
</code></pre>
</article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.3</a> on Sat Jul 29 2017 10:16:38 GMT+0100 (BST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/linenumber.js"></script>
</body>
</html>

View File

@ -0,0 +1,96 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>plugins/autoprint.js - Documentation</title>
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="jsPDF.html">jsPDF</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addFont">addFont</a></li><li><a href="global.html#addHTML">addHTML</a></li><li><a href="global.html#addMetadata">addMetadata</a></li><li><a href="global.html#addPage">addPage</a></li><li><a href="global.html#autoPrint">autoPrint</a></li><li><a href="global.html#CapJoinStyles">CapJoinStyles</a></li><li><a href="global.html#circle">circle</a></li><li><a href="global.html#ellipse">ellipse</a></li><li><a href="global.html#getFontList">getFontList</a></li><li><a href="global.html#lines">lines</a></li><li><a href="global.html#lstext">lstext</a></li><li><a href="global.html#output">output</a></li><li><a href="global.html#rect">rect</a></li><li><a href="global.html#roundedRect">roundedRect</a></li><li><a href="global.html#save">save</a></li><li><a href="global.html#setDisplayMode">setDisplayMode</a></li><li><a href="global.html#setDrawColor">setDrawColor</a></li><li><a href="global.html#setFillColor">setFillColor</a></li><li><a href="global.html#setFont">setFont</a></li><li><a href="global.html#setFontSize">setFontSize</a></li><li><a href="global.html#setFontStyle">setFontStyle</a></li><li><a href="global.html#setLineCap">setLineCap</a></li><li><a href="global.html#setLineJoin">setLineJoin</a></li><li><a href="global.html#setLineWidth">setLineWidth</a></li><li><a href="global.html#setPage">setPage</a></li><li><a href="global.html#setProperties">setProperties</a></li><li><a href="global.html#setTextColor">setTextColor</a></li><li><a href="global.html#text">text</a></li><li><a href="global.html#triangle">triangle</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">plugins/autoprint.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>/**
* jsPDF Autoprint Plugin
*
* Licensed under the MIT License.
* http://opensource.org/licenses/mit-license
*/
/**
* Makes the PDF automatically print. This works in Chrome, Firefox, Acrobat
* Reader.
*
* @returns {jsPDF}
* @name autoPrint
* @example
* var doc = new jsPDF()
* doc.text(10, 10, 'This is a test')
* doc.autoPrint()
* doc.save('autoprint.pdf')
*/
(function (jsPDFAPI) {
'use strict';
jsPDFAPI.autoPrint = function () {
'use strict'
var refAutoPrintTag;
this.internal.events.subscribe('postPutResources', function () {
refAutoPrintTag = this.internal.newObject()
this.internal.write("&lt;&lt; /S/Named /Type/Action /N/Print >>", "endobj");
});
this.internal.events.subscribe("putCatalog", function () {
this.internal.write("/OpenAction " + refAutoPrintTag + " 0" + " R");
});
return this;
};
})(jsPDF.API);
</code></pre>
</article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.3</a> on Sat Jul 29 2017 10:16:38 GMT+0100 (BST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/linenumber.js"></script>
</body>
</html>

View File

@ -0,0 +1,470 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>plugins/cell.js - Documentation</title>
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="jsPDF.html">jsPDF</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addFont">addFont</a></li><li><a href="global.html#addHTML">addHTML</a></li><li><a href="global.html#addMetadata">addMetadata</a></li><li><a href="global.html#addPage">addPage</a></li><li><a href="global.html#autoPrint">autoPrint</a></li><li><a href="global.html#CapJoinStyles">CapJoinStyles</a></li><li><a href="global.html#circle">circle</a></li><li><a href="global.html#ellipse">ellipse</a></li><li><a href="global.html#getFontList">getFontList</a></li><li><a href="global.html#lines">lines</a></li><li><a href="global.html#lstext">lstext</a></li><li><a href="global.html#output">output</a></li><li><a href="global.html#rect">rect</a></li><li><a href="global.html#roundedRect">roundedRect</a></li><li><a href="global.html#save">save</a></li><li><a href="global.html#setDisplayMode">setDisplayMode</a></li><li><a href="global.html#setDrawColor">setDrawColor</a></li><li><a href="global.html#setFillColor">setFillColor</a></li><li><a href="global.html#setFont">setFont</a></li><li><a href="global.html#setFontSize">setFontSize</a></li><li><a href="global.html#setFontStyle">setFontStyle</a></li><li><a href="global.html#setLineCap">setLineCap</a></li><li><a href="global.html#setLineJoin">setLineJoin</a></li><li><a href="global.html#setLineWidth">setLineWidth</a></li><li><a href="global.html#setPage">setPage</a></li><li><a href="global.html#setProperties">setProperties</a></li><li><a href="global.html#setTextColor">setTextColor</a></li><li><a href="global.html#text">text</a></li><li><a href="global.html#triangle">triangle</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">plugins/cell.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>/** ====================================================================
* jsPDF Cell plugin
* Copyright (c) 2013 Youssef Beddad, youssef.beddad@gmail.com
* 2013 Eduardo Menezes de Morais, eduardo.morais@usp.br
* 2013 Lee Driscoll, https://github.com/lsdriscoll
* 2014 Juan Pablo Gaviria, https://github.com/juanpgaviria
* 2014 James Hall, james@parall.ax
* 2014 Diego Casorran, https://github.com/diegocr
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* ====================================================================
*/
(function (jsPDFAPI) {
'use strict';
/*jslint browser:true */
/*global document: false, jsPDF */
var fontName,
fontSize,
fontStyle,
padding = 3,
margin = 13,
headerFunction,
lastCellPos = { x: undefined, y: undefined, w: undefined, h: undefined, ln: undefined },
pages = 1,
setLastCellPosition = function (x, y, w, h, ln) {
lastCellPos = { 'x': x, 'y': y, 'w': w, 'h': h, 'ln': ln };
},
getLastCellPosition = function () {
return lastCellPos;
},
NO_MARGINS = {left:0, top:0, bottom: 0};
jsPDFAPI.setHeaderFunction = function (func) {
headerFunction = func;
};
jsPDFAPI.getTextDimensions = function (txt) {
fontName = this.internal.getFont().fontName;
fontSize = this.table_font_size || this.internal.getFontSize();
fontStyle = this.internal.getFont().fontStyle;
// 1 pixel = 0.264583 mm and 1 mm = 72/25.4 point
var px2pt = 0.264583 * 72 / 25.4,
dimensions,
text;
text = document.createElement('font');
text.id = "jsPDFCell";
try {
text.style.fontStyle = fontStyle;
} catch(e) {
text.style.fontWeight = fontStyle;
}
text.style.fontName = fontName;
text.style.fontSize = fontSize + 'pt';
try {
text.textContent = txt;
} catch(e) {
text.innerText = txt;
}
document.body.appendChild(text);
dimensions = { w: (text.offsetWidth + 1) * px2pt, h: (text.offsetHeight + 1) * px2pt};
document.body.removeChild(text);
return dimensions;
};
jsPDFAPI.cellAddPage = function () {
var margins = this.margins || NO_MARGINS;
this.addPage();
setLastCellPosition(margins.left, margins.top, undefined, undefined);
//setLastCellPosition(undefined, undefined, undefined, undefined, undefined);
pages += 1;
};
jsPDFAPI.cellInitialize = function () {
lastCellPos = { x: undefined, y: undefined, w: undefined, h: undefined, ln: undefined };
pages = 1;
};
jsPDFAPI.cell = function (x, y, w, h, txt, ln, align) {
var curCell = getLastCellPosition();
var pgAdded = false;
// If this is not the first cell, we must change its position
if (curCell.ln !== undefined) {
if (curCell.ln === ln) {
//Same line
x = curCell.x + curCell.w;
y = curCell.y;
} else {
//New line
var margins = this.margins || NO_MARGINS;
if ((curCell.y + curCell.h + h + margin) >= this.internal.pageSize.height - margins.bottom) {
this.cellAddPage();
pgAdded = true;
if (this.printHeaders &amp;&amp; this.tableHeaderRow) {
this.printHeaderRow(ln, true);
}
}
//We ignore the passed y: the lines may have different heights
y = (getLastCellPosition().y + getLastCellPosition().h);
if (pgAdded) y = margin + 10;
}
}
if (txt[0] !== undefined) {
if (this.printingHeaderRow) {
this.rect(x, y, w, h, 'FD');
} else {
this.rect(x, y, w, h);
}
if (align === 'right') {
if (!(txt instanceof Array)) {
txt = [txt];
}
for (var i = 0; i &lt; txt.length; i++) {
var currentLine = txt[i];
var textSize = this.getStringUnitWidth(currentLine) * this.internal.getFontSize();
this.text(currentLine, x + w - textSize - padding, y + this.internal.getLineHeight()*(i+1));
}
} else {
this.text(txt, x + padding, y + this.internal.getLineHeight());
}
}
setLastCellPosition(x, y, w, h, ln);
return this;
};
/**
* Return the maximum value from an array
* @param array
* @param comparisonFn
* @returns {*}
*/
jsPDFAPI.arrayMax = function (array, comparisonFn) {
var max = array[0],
i,
ln,
item;
for (i = 0, ln = array.length; i &lt; ln; i += 1) {
item = array[i];
if (comparisonFn) {
if (comparisonFn(max, item) === -1) {
max = item;
}
} else {
if (item > max) {
max = item;
}
}
}
return max;
};
/**
* Create a table from a set of data.
* @param {Integer} [x] : left-position for top-left corner of table
* @param {Integer} [y] top-position for top-left corner of table
* @param {Object[]} [data] As array of objects containing key-value pairs corresponding to a row of data.
* @param {String[]} [headers] Omit or null to auto-generate headers at a performance cost
* @param {Object} [config.printHeaders] True to print column headers at the top of every page
* @param {Object} [config.autoSize] True to dynamically set the column widths to match the widest cell value
* @param {Object} [config.margins] margin values for left, top, bottom, and width
* @param {Object} [config.fontSize] Integer fontSize to use (optional)
*/
jsPDFAPI.table = function (x,y, data, headers, config) {
if (!data) {
throw 'No data for PDF table';
}
var headerNames = [],
headerPrompts = [],
header,
i,
ln,
cln,
columnMatrix = {},
columnWidths = {},
columnData,
column,
columnMinWidths = [],
j,
tableHeaderConfigs = [],
model,
jln,
func,
//set up defaults. If a value is provided in config, defaults will be overwritten:
autoSize = false,
printHeaders = true,
fontSize = 12,
margins = NO_MARGINS;
margins.width = this.internal.pageSize.width;
if (config) {
//override config defaults if the user has specified non-default behavior:
if(config.autoSize === true) {
autoSize = true;
}
if(config.printHeaders === false) {
printHeaders = false;
}
if(config.fontSize){
fontSize = config.fontSize;
}
if (config.css &amp;&amp; typeof(config.css['font-size']) !== "undefined") {
fontSize = config.css['font-size'] * 16;
}
if(config.margins){
margins = config.margins;
}
}
/**
* @property {Number} lnMod
* Keep track of the current line number modifier used when creating cells
*/
this.lnMod = 0;
lastCellPos = { x: undefined, y: undefined, w: undefined, h: undefined, ln: undefined },
pages = 1;
this.printHeaders = printHeaders;
this.margins = margins;
this.setFontSize(fontSize);
this.table_font_size = fontSize;
// Set header values
if (headers === undefined || (headers === null)) {
// No headers defined so we derive from data
headerNames = Object.keys(data[0]);
} else if (headers[0] &amp;&amp; (typeof headers[0] !== 'string')) {
var px2pt = 0.264583 * 72 / 25.4;
// Split header configs into names and prompts
for (i = 0, ln = headers.length; i &lt; ln; i += 1) {
header = headers[i];
headerNames.push(header.name);
headerPrompts.push(header.prompt);
columnWidths[header.name] = header.width *px2pt;
}
} else {
headerNames = headers;
}
if (autoSize) {
// Create a matrix of columns e.g., {column_title: [row1_Record, row2_Record]}
func = function (rec) {
return rec[header];
};
for (i = 0, ln = headerNames.length; i &lt; ln; i += 1) {
header = headerNames[i];
columnMatrix[header] = data.map(
func
);
// get header width
columnMinWidths.push(this.getTextDimensions(headerPrompts[i] || header).w);
column = columnMatrix[header];
// get cell widths
for (j = 0, cln = column.length; j &lt; cln; j += 1) {
columnData = column[j];
columnMinWidths.push(this.getTextDimensions(columnData).w);
}
// get final column width
columnWidths[header] = jsPDFAPI.arrayMax(columnMinWidths);
//have to reset
columnMinWidths = [];
}
}
// -- Construct the table
if (printHeaders) {
var lineHeight = this.calculateLineHeight(headerNames, columnWidths, headerPrompts.length?headerPrompts:headerNames);
// Construct the header row
for (i = 0, ln = headerNames.length; i &lt; ln; i += 1) {
header = headerNames[i];
tableHeaderConfigs.push([x, y, columnWidths[header], lineHeight, String(headerPrompts.length ? headerPrompts[i] : header)]);
}
// Store the table header config
this.setTableHeaderRow(tableHeaderConfigs);
// Print the header for the start of the table
this.printHeaderRow(1, false);
}
// Construct the data rows
for (i = 0, ln = data.length; i &lt; ln; i += 1) {
var lineHeight;
model = data[i];
lineHeight = this.calculateLineHeight(headerNames, columnWidths, model);
for (j = 0, jln = headerNames.length; j &lt; jln; j += 1) {
header = headerNames[j];
this.cell(x, y, columnWidths[header], lineHeight, model[header], i + 2, header.align);
}
}
this.lastCellPos = lastCellPos;
this.table_x = x;
this.table_y = y;
return this;
};
/**
* Calculate the height for containing the highest column
* @param {String[]} headerNames is the header, used as keys to the data
* @param {Integer[]} columnWidths is size of each column
* @param {Object[]} model is the line of data we want to calculate the height of
*/
jsPDFAPI.calculateLineHeight = function (headerNames, columnWidths, model) {
var header, lineHeight = 0;
for (var j = 0; j &lt; headerNames.length; j++) {
header = headerNames[j];
model[header] = this.splitTextToSize(String(model[header]), columnWidths[header] - padding);
var h = this.internal.getLineHeight() * model[header].length + padding;
if (h > lineHeight)
lineHeight = h;
}
return lineHeight;
};
/**
* Store the config for outputting a table header
* @param {Object[]} config
* An array of cell configs that would define a header row: Each config matches the config used by jsPDFAPI.cell
* except the ln parameter is excluded
*/
jsPDFAPI.setTableHeaderRow = function (config) {
this.tableHeaderRow = config;
};
/**
* Output the store header row
* @param lineNumber The line number to output the header at
*/
jsPDFAPI.printHeaderRow = function (lineNumber, new_page) {
if (!this.tableHeaderRow) {
throw 'Property tableHeaderRow does not exist.';
}
var tableHeaderCell,
tmpArray,
i,
ln;
this.printingHeaderRow = true;
if (headerFunction !== undefined) {
var position = headerFunction(this, pages);
setLastCellPosition(position[0], position[1], position[2], position[3], -1);
}
this.setFontStyle('bold');
var tempHeaderConf = [];
for (i = 0, ln = this.tableHeaderRow.length; i &lt; ln; i += 1) {
this.setFillColor(200,200,200);
tableHeaderCell = this.tableHeaderRow[i];
if (new_page) {
this.margins.top = margin;
tableHeaderCell[1] = this.margins &amp;&amp; this.margins.top || 0;
tempHeaderConf.push(tableHeaderCell);
}
tmpArray = [].concat(tableHeaderCell);
this.cell.apply(this, tmpArray.concat(lineNumber));
}
if (tempHeaderConf.length > 0){
this.setTableHeaderRow(tempHeaderConf);
}
this.setFontStyle('normal');
this.printingHeaderRow = false;
};
})(jsPDF.API);
</code></pre>
</article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.3</a> on Sat Jul 29 2017 10:16:38 GMT+0100 (BST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/linenumber.js"></script>
</body>
</html>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,300 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>plugins/outline.js - Documentation</title>
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="jsPDF.html">jsPDF</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addFont">addFont</a></li><li><a href="global.html#addHTML">addHTML</a></li><li><a href="global.html#addMetadata">addMetadata</a></li><li><a href="global.html#addPage">addPage</a></li><li><a href="global.html#autoPrint">autoPrint</a></li><li><a href="global.html#CapJoinStyles">CapJoinStyles</a></li><li><a href="global.html#circle">circle</a></li><li><a href="global.html#ellipse">ellipse</a></li><li><a href="global.html#getFontList">getFontList</a></li><li><a href="global.html#lines">lines</a></li><li><a href="global.html#lstext">lstext</a></li><li><a href="global.html#output">output</a></li><li><a href="global.html#rect">rect</a></li><li><a href="global.html#roundedRect">roundedRect</a></li><li><a href="global.html#save">save</a></li><li><a href="global.html#setDisplayMode">setDisplayMode</a></li><li><a href="global.html#setDrawColor">setDrawColor</a></li><li><a href="global.html#setFillColor">setFillColor</a></li><li><a href="global.html#setFont">setFont</a></li><li><a href="global.html#setFontSize">setFontSize</a></li><li><a href="global.html#setFontStyle">setFontStyle</a></li><li><a href="global.html#setLineCap">setLineCap</a></li><li><a href="global.html#setLineJoin">setLineJoin</a></li><li><a href="global.html#setLineWidth">setLineWidth</a></li><li><a href="global.html#setPage">setPage</a></li><li><a href="global.html#setProperties">setProperties</a></li><li><a href="global.html#setTextColor">setTextColor</a></li><li><a href="global.html#text">text</a></li><li><a href="global.html#triangle">triangle</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">plugins/outline.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>/**
* jsPDF Outline PlugIn
* Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv
*
* Licensed under the MIT License.
* http://opensource.org/licenses/mit-license
*/
/**
* Generates a PDF Outline
*/
;
(function(jsPDFAPI) {
'use strict';
jsPDFAPI.events.push([
'postPutResources', function() {
var pdf = this;
var rx = /^(\d+) 0 obj$/;
// Write action goto objects for each page
// this.outline.destsGoto = [];
// for (var i = 0; i &lt; totalPages; i++) {
// var id = pdf.internal.newObject();
// this.outline.destsGoto.push(id);
// pdf.internal.write("&lt;&lt;/D[" + (i * 2 + 3) + " 0 R /XYZ null
// null null]/S/GoTo>> endobj");
// }
//
// for (var i = 0; i &lt; dests.length; i++) {
// pdf.internal.write("(page_" + (i + 1) + ")" + dests[i] + " 0
// R");
// }
//
if (this.outline.root.children.length > 0) {
var lines = pdf.outline.render().split(/\r\n/);
for (var i = 0; i &lt; lines.length; i++) {
var line = lines[i];
var m = rx.exec(line);
if (m != null) {
var oid = m[1];
pdf.internal.newObjectDeferredBegin(oid);
}
pdf.internal.write(line);
}
}
// This code will write named destination for each page reference
// (page_1, etc)
if (this.outline.createNamedDestinations) {
var totalPages = this.internal.pages.length;
// WARNING: this assumes jsPDF starts on page 3 and pageIDs
// follow 5, 7, 9, etc
// Write destination objects for each page
var dests = [];
for (var i = 0; i &lt; totalPages; i++) {
var id = pdf.internal.newObject();
dests.push(id);
var info = pdf.internal.getPageInfo(i+1);
pdf.internal.write("&lt;&lt; /D[" + info.objId + " 0 R /XYZ null null null]>> endobj");
}
// assign a name for each destination
var names2Oid = pdf.internal.newObject();
pdf.internal.write('&lt;&lt; /Names [ ');
for (var i = 0; i &lt; dests.length; i++) {
pdf.internal.write("(page_" + (i + 1) + ")" + dests[i] + " 0 R");
}
pdf.internal.write(' ] >>', 'endobj');
// var kids = pdf.internal.newObject();
// pdf.internal.write('&lt;&lt; /Kids [ ' + names2Oid + ' 0 R');
// pdf.internal.write(' ] >>', 'endobj');
var namesOid = pdf.internal.newObject();
pdf.internal.write('&lt;&lt; /Dests ' + names2Oid + " 0 R");
pdf.internal.write('>>', 'endobj');
}
}
]);
jsPDFAPI.events.push([
'putCatalog', function() {
var pdf = this;
if (pdf.outline.root.children.length > 0) {
pdf.internal.write("/Outlines", this.outline.makeRef(this.outline.root));
if (this.outline.createNamedDestinations) {
pdf.internal.write("/Names " + namesOid + " 0 R");
}
// Open with Bookmarks showing
// pdf.internal.write("/PageMode /UseOutlines");
}
}
]);
jsPDFAPI.events.push([
'initialized', function() {
var pdf = this;
pdf.outline = {
createNamedDestinations : false,
root : {
children : []
}
};
var namesOid;
var destsGoto = [];
/**
* Options: pageNumber
*/
pdf.outline.add = function(parent,title,options) {
var item = {
title : title,
options : options,
children : []
};
if (parent == null) {
parent = this.root;
}
parent.children.push(item);
return item;
}
pdf.outline.render = function() {
this.ctx = {};
this.ctx.val = '';
this.ctx.pdf = pdf;
this.genIds_r(this.root);
this.renderRoot(this.root);
this.renderItems(this.root);
return this.ctx.val;
};
pdf.outline.genIds_r = function(node) {
node.id = pdf.internal.newObjectDeferred();
for (var i = 0; i &lt; node.children.length; i++) {
this.genIds_r(node.children[i]);
}
};
pdf.outline.renderRoot = function(node) {
this.objStart(node);
this.line('/Type /Outlines');
if (node.children.length > 0) {
this.line('/First ' + this.makeRef(node.children[0]));
this.line('/Last ' + this.makeRef(node.children[node.children.length - 1]));
}
this.line('/Count ' + this.count_r({
count : 0
}, node));
this.objEnd();
};
pdf.outline.renderItems = function(node) {
for (var i = 0; i &lt; node.children.length; i++) {
var item = node.children[i];
this.objStart(item);
this.line('/Title ' + this.makeString(item.title));
this.line('/Parent ' + this.makeRef(node));
if (i > 0) {
this.line('/Prev ' + this.makeRef(node.children[i - 1]));
}
if (i &lt; node.children.length - 1) {
this.line('/Next ' + this.makeRef(node.children[i + 1]));
}
if (item.children.length > 0) {
this.line('/First ' + this.makeRef(item.children[0]));
this.line('/Last ' + this.makeRef(item.children[item.children.length - 1]));
}
var count = this.count = this.count_r({
count : 0
}, item);
if (count > 0) {
this.line('/Count ' + count);
}
if (item.options) {
if (item.options.pageNumber) {
// Explicit Destination
//WARNING this assumes page ids are 3,5,7, etc.
var info = pdf.internal.getPageInfo(item.options.pageNumber)
this.line('/Dest ' + '[' + info.objId + ' 0 R /XYZ 0 ' + this.ctx.pdf.internal.pageSize.height + ' 0]');
// this line does not work on all clients (pageNumber instead of page ref)
//this.line('/Dest ' + '[' + (item.options.pageNumber - 1) + ' /XYZ 0 ' + this.ctx.pdf.internal.pageSize.height + ' 0]');
// Named Destination
// this.line('/Dest (page_' + (item.options.pageNumber) + ')');
// Action Destination
// var id = pdf.internal.newObject();
// pdf.internal.write('&lt;&lt;/D[' + (item.options.pageNumber - 1) + ' /XYZ null null null]/S/GoTo>> endobj');
// this.line('/A ' + id + ' 0 R' );
}
}
this.objEnd();
}
for (var i = 0; i &lt; node.children.length; i++) {
var item = node.children[i];
this.renderItems(item);
}
};
pdf.outline.line = function(text) {
this.ctx.val += text + '\r\n';
};
pdf.outline.makeRef = function(node) {
return node.id + ' 0 R';
};
pdf.outline.makeString = function(val) {
return '(' + pdf.internal.pdfEscape(val) + ')';
};
pdf.outline.objStart = function(node) {
this.ctx.val += '\r\n' + node.id + ' 0 obj' + '\r\n&lt;&lt;\r\n';
};
pdf.outline.objEnd = function(node) {
this.ctx.val += '>> \r\n' + 'endobj' + '\r\n';
};
pdf.outline.count_r = function(ctx,node) {
for (var i = 0; i &lt; node.children.length; i++) {
ctx.count++;
this.count_r(ctx, node.children[i]);
}
return ctx.count;
};
}
]);
return this;
})(jsPDF.API);
</code></pre>
</article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.3</a> on Sat Jul 29 2017 10:16:38 GMT+0100 (BST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/linenumber.js"></script>
</body>
</html>

View File

@ -0,0 +1,383 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>plugins/split_text_to_size.js - Documentation</title>
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="jsPDF.html">jsPDF</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addFont">addFont</a></li><li><a href="global.html#addHTML">addHTML</a></li><li><a href="global.html#addMetadata">addMetadata</a></li><li><a href="global.html#addPage">addPage</a></li><li><a href="global.html#autoPrint">autoPrint</a></li><li><a href="global.html#CapJoinStyles">CapJoinStyles</a></li><li><a href="global.html#circle">circle</a></li><li><a href="global.html#ellipse">ellipse</a></li><li><a href="global.html#getFontList">getFontList</a></li><li><a href="global.html#lines">lines</a></li><li><a href="global.html#lstext">lstext</a></li><li><a href="global.html#output">output</a></li><li><a href="global.html#rect">rect</a></li><li><a href="global.html#roundedRect">roundedRect</a></li><li><a href="global.html#save">save</a></li><li><a href="global.html#setDisplayMode">setDisplayMode</a></li><li><a href="global.html#setDrawColor">setDrawColor</a></li><li><a href="global.html#setFillColor">setFillColor</a></li><li><a href="global.html#setFont">setFont</a></li><li><a href="global.html#setFontSize">setFontSize</a></li><li><a href="global.html#setFontStyle">setFontStyle</a></li><li><a href="global.html#setLineCap">setLineCap</a></li><li><a href="global.html#setLineJoin">setLineJoin</a></li><li><a href="global.html#setLineWidth">setLineWidth</a></li><li><a href="global.html#setPage">setPage</a></li><li><a href="global.html#setProperties">setProperties</a></li><li><a href="global.html#setTextColor">setTextColor</a></li><li><a href="global.html#text">text</a></li><li><a href="global.html#triangle">triangle</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">plugins/split_text_to_size.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>/** @preserve
* jsPDF split_text_to_size plugin - MIT license.
* Copyright (c) 2012 Willow Systems Corporation, willow-systems.com
* 2014 Diego Casorran, https://github.com/diegocr
*/
/**
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* ====================================================================
*/
;(function(API) {
'use strict'
/**
Returns an array of length matching length of the 'word' string, with each
cell ocupied by the width of the char in that position.
@function
@param word {String}
@param widths {Object}
@param kerning {Object}
@returns {Array}
*/
var getCharWidthsArray = API.getCharWidthsArray = function(text, options){
if (!options) {
options = {}
}
var widths = options.widths ? options.widths : this.internal.getFont().metadata.Unicode.widths
, widthsFractionOf = widths.fof ? widths.fof : 1
, kerning = options.kerning ? options.kerning : this.internal.getFont().metadata.Unicode.kerning
, kerningFractionOf = kerning.fof ? kerning.fof : 1
// console.log("widths, kergnings", widths, kerning)
var i, l
, char_code
, prior_char_code = 0 // for kerning
, default_char_width = widths[0] || widthsFractionOf
, output = []
for (i = 0, l = text.length; i &lt; l; i++) {
char_code = text.charCodeAt(i)
output.push(
( widths[char_code] || default_char_width ) / widthsFractionOf +
( kerning[char_code] &amp;&amp; kerning[char_code][prior_char_code] || 0 ) / kerningFractionOf
)
prior_char_code = char_code
}
return output
}
var getArraySum = function(array){
var i = array.length
, output = 0
while(i){
;i--;
output += array[i]
}
return output
}
/**
Returns a widths of string in a given font, if the font size is set as 1 point.
In other words, this is "proportional" value. For 1 unit of font size, the length
of the string will be that much.
Multiply by font size to get actual width in *points*
Then divide by 72 to get inches or divide by (72/25.6) to get 'mm' etc.
@public
@function
@param
@returns {Type}
*/
var getStringUnitWidth = API.getStringUnitWidth = function(text, options) {
return getArraySum(getCharWidthsArray.call(this, text, options))
}
/**
returns array of lines
*/
var splitLongWord = function(word, widths_array, firstLineMaxLen, maxLen){
var answer = []
// 1st, chop off the piece that can fit on the hanging line.
var i = 0
, l = word.length
, workingLen = 0
while (i !== l &amp;&amp; workingLen + widths_array[i] &lt; firstLineMaxLen){
workingLen += widths_array[i]
;i++;
}
// this is first line.
answer.push(word.slice(0, i))
// 2nd. Split the rest into maxLen pieces.
var startOfLine = i
workingLen = 0
while (i !== l){
if (workingLen + widths_array[i] > maxLen) {
answer.push(word.slice(startOfLine, i))
workingLen = 0
startOfLine = i
}
workingLen += widths_array[i]
;i++;
}
if (startOfLine !== i) {
answer.push(word.slice(startOfLine, i))
}
return answer
}
// Note, all sizing inputs for this function must be in "font measurement units"
// By default, for PDF, it's "point".
var splitParagraphIntoLines = function(text, maxlen, options){
// at this time works only on Western scripts, ones with space char
// separating the words. Feel free to expand.
if (!options) {
options = {}
}
var line = []
, lines = [line]
, line_length = options.textIndent || 0
, separator_length = 0
, current_word_length = 0
, word
, widths_array
, words = text.split(' ')
, spaceCharWidth = getCharWidthsArray(' ', options)[0]
, i, l, tmp, lineIndent
if(options.lineIndent === -1) {
lineIndent = words[0].length +2;
} else {
lineIndent = options.lineIndent || 0;
}
if(lineIndent) {
var pad = Array(lineIndent).join(" "), wrds = [];
words.map(function(wrd) {
wrd = wrd.split(/\s*\n/);
if(wrd.length > 1) {
wrds = wrds.concat(wrd.map(function(wrd, idx) {
return (idx &amp;&amp; wrd.length ? "\n":"") + wrd;
}));
} else {
wrds.push(wrd[0]);
}
});
words = wrds;
lineIndent = getStringUnitWidth(pad, options);
}
for (i = 0, l = words.length; i &lt; l; i++) {
var force = 0;
word = words[i]
if(lineIndent &amp;&amp; word[0] == "\n") {
word = word.substr(1);
force = 1;
}
widths_array = getCharWidthsArray(word, options)
current_word_length = getArraySum(widths_array)
if (line_length + separator_length + current_word_length > maxlen || force) {
if (current_word_length > maxlen) {
// this happens when you have space-less long URLs for example.
// we just chop these to size. We do NOT insert hiphens
tmp = splitLongWord(word, widths_array, maxlen - (line_length + separator_length), maxlen)
// first line we add to existing line object
line.push(tmp.shift()) // it's ok to have extra space indicator there
// last line we make into new line object
line = [tmp.pop()]
// lines in the middle we apped to lines object as whole lines
while(tmp.length){
lines.push([tmp.shift()]) // single fragment occupies whole line
}
current_word_length = getArraySum( widths_array.slice(word.length - line[0].length) )
} else {
// just put it on a new line
line = [word]
}
// now we attach new line to lines
lines.push(line)
line_length = current_word_length + lineIndent
separator_length = spaceCharWidth
} else {
line.push(word)
line_length += separator_length + current_word_length
separator_length = spaceCharWidth
}
}
if(lineIndent) {
var postProcess = function(ln, idx) {
return (idx ? pad : '') + ln.join(" ");
};
} else {
var postProcess = function(ln) { return ln.join(" ")};
}
return lines.map(postProcess);
}
/**
Splits a given string into an array of strings. Uses 'size' value
(in measurement units declared as default for the jsPDF instance)
and the font's "widths" and "Kerning" tables, where available, to
determine display length of a given string for a given font.
We use character's 100% of unit size (height) as width when Width
table or other default width is not available.
@public
@function
@param text {String} Unencoded, regular JavaScript (Unicode, UTF-16 / UCS-2) string.
@param size {Number} Nominal number, measured in units default to this instance of jsPDF.
@param options {Object} Optional flags needed for chopper to do the right thing.
@returns {Array} with strings chopped to size.
*/
API.splitTextToSize = function(text, maxlen, options) {
'use strict'
if (!options) {
options = {}
}
var fsize = options.fontSize || this.internal.getFontSize()
, newOptions = (function(options){
var widths = {0:1}
, kerning = {}
if (!options.widths || !options.kerning) {
var f = this.internal.getFont(options.fontName, options.fontStyle)
, encoding = 'Unicode'
// NOT UTF8, NOT UTF16BE/LE, NOT UCS2BE/LE
// Actual JavaScript-native String's 16bit char codes used.
// no multi-byte logic here
if (f.metadata[encoding]) {
return {
widths: f.metadata[encoding].widths || widths
, kerning: f.metadata[encoding].kerning || kerning
}
}
} else {
return {
widths: options.widths
, kerning: options.kerning
}
}
// then use default values
return {
widths: widths
, kerning: kerning
}
}).call(this, options)
// first we split on end-of-line chars
var paragraphs
if(Array.isArray(text)) {
paragraphs = text;
} else {
paragraphs = text.split(/\r?\n/);
}
// now we convert size (max length of line) into "font size units"
// at present time, the "font size unit" is always 'point'
// 'proportional' means, "in proportion to font size"
var fontUnit_maxLen = 1.0 * this.internal.scaleFactor * maxlen / fsize
// at this time, fsize is always in "points" regardless of the default measurement unit of the doc.
// this may change in the future?
// until then, proportional_maxlen is likely to be in 'points'
// If first line is to be indented (shorter or longer) than maxLen
// we indicate that by using CSS-style "text-indent" option.
// here it's in font units too (which is likely 'points')
// it can be negative (which makes the first line longer than maxLen)
newOptions.textIndent = options.textIndent ?
options.textIndent * 1.0 * this.internal.scaleFactor / fsize :
0
newOptions.lineIndent = options.lineIndent;
var i, l
, output = []
for (i = 0, l = paragraphs.length; i &lt; l; i++) {
output = output.concat(
splitParagraphIntoLines(
paragraphs[i]
, fontUnit_maxLen
, newOptions
)
)
}
return output
}
})(jsPDF.API);
</code></pre>
</article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.3</a> on Sat Jul 29 2017 10:16:38 GMT+0100 (BST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/linenumber.js"></script>
</body>
</html>

View File

@ -0,0 +1,239 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>plugins/svg.js - Documentation</title>
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="jsPDF.html">jsPDF</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addFont">addFont</a></li><li><a href="global.html#addHTML">addHTML</a></li><li><a href="global.html#addMetadata">addMetadata</a></li><li><a href="global.html#addPage">addPage</a></li><li><a href="global.html#autoPrint">autoPrint</a></li><li><a href="global.html#CapJoinStyles">CapJoinStyles</a></li><li><a href="global.html#circle">circle</a></li><li><a href="global.html#ellipse">ellipse</a></li><li><a href="global.html#getFontList">getFontList</a></li><li><a href="global.html#lines">lines</a></li><li><a href="global.html#lstext">lstext</a></li><li><a href="global.html#output">output</a></li><li><a href="global.html#rect">rect</a></li><li><a href="global.html#roundedRect">roundedRect</a></li><li><a href="global.html#save">save</a></li><li><a href="global.html#setDisplayMode">setDisplayMode</a></li><li><a href="global.html#setDrawColor">setDrawColor</a></li><li><a href="global.html#setFillColor">setFillColor</a></li><li><a href="global.html#setFont">setFont</a></li><li><a href="global.html#setFontSize">setFontSize</a></li><li><a href="global.html#setFontStyle">setFontStyle</a></li><li><a href="global.html#setLineCap">setLineCap</a></li><li><a href="global.html#setLineJoin">setLineJoin</a></li><li><a href="global.html#setLineWidth">setLineWidth</a></li><li><a href="global.html#setPage">setPage</a></li><li><a href="global.html#setProperties">setProperties</a></li><li><a href="global.html#setTextColor">setTextColor</a></li><li><a href="global.html#text">text</a></li><li><a href="global.html#triangle">triangle</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">plugins/svg.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>/** @preserve
jsPDF SVG plugin
Copyright (c) 2012 Willow Systems Corporation, willow-systems.com
*/
/**
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* ====================================================================
*/
;(function(jsPDFAPI) {
'use strict'
/**
Parses SVG XML and converts only some of the SVG elements into
PDF elements.
Supports:
paths
@public
@function
@param
@returns {Type}
*/
jsPDFAPI.addSVG = function(svgtext, x, y, w, h) {
// 'this' is _jsPDF object returned when jsPDF is inited (new jsPDF())
var undef
if (x === undef || y === undef) {
throw new Error("addSVG needs values for 'x' and 'y'");
}
function InjectCSS(cssbody, document) {
var styletag = document.createElement('style');
styletag.type = 'text/css';
if (styletag.styleSheet) {
// ie
styletag.styleSheet.cssText = cssbody;
} else {
// others
styletag.appendChild(document.createTextNode(cssbody));
}
document.getElementsByTagName("head")[0].appendChild(styletag);
}
function createWorkerNode(document){
var frameID = 'childframe' // Date.now().toString() + '_' + (Math.random() * 100).toString()
, frame = document.createElement('iframe')
InjectCSS(
'.jsPDF_sillysvg_iframe {display:none;position:absolute;}'
, document
)
frame.name = frameID
frame.setAttribute("width", 0)
frame.setAttribute("height", 0)
frame.setAttribute("frameborder", "0")
frame.setAttribute("scrolling", "no")
frame.setAttribute("seamless", "seamless")
frame.setAttribute("class", "jsPDF_sillysvg_iframe")
document.body.appendChild(frame)
return frame
}
function attachSVGToWorkerNode(svgtext, frame){
var framedoc = ( frame.contentWindow || frame.contentDocument ).document
framedoc.write(svgtext)
framedoc.close()
return framedoc.getElementsByTagName('svg')[0]
}
function convertPathToPDFLinesArgs(path){
'use strict'
// we will use 'lines' method call. it needs:
// - starting coordinate pair
// - array of arrays of vector shifts (2-len for line, 6 len for bezier)
// - scale array [horizontal, vertical] ratios
// - style (stroke, fill, both)
var x = parseFloat(path[1])
, y = parseFloat(path[2])
, vectors = []
, position = 3
, len = path.length
while (position &lt; len){
if (path[position] === 'c'){
vectors.push([
parseFloat(path[position + 1])
, parseFloat(path[position + 2])
, parseFloat(path[position + 3])
, parseFloat(path[position + 4])
, parseFloat(path[position + 5])
, parseFloat(path[position + 6])
])
position += 7
} else if (path[position] === 'l') {
vectors.push([
parseFloat(path[position + 1])
, parseFloat(path[position + 2])
])
position += 3
} else {
position += 1
}
}
return [x,y,vectors]
}
var workernode = createWorkerNode(document)
, svgnode = attachSVGToWorkerNode(svgtext, workernode)
, scale = [1,1]
, svgw = parseFloat(svgnode.getAttribute('width'))
, svgh = parseFloat(svgnode.getAttribute('height'))
if (svgw &amp;&amp; svgh) {
// setting both w and h makes image stretch to size.
// this may distort the image, but fits your demanded size
if (w &amp;&amp; h) {
scale = [w / svgw, h / svgh]
}
// if only one is set, that value is set as max and SVG
// is scaled proportionately.
else if (w) {
scale = [w / svgw, w / svgw]
} else if (h) {
scale = [h / svgh, h / svgh]
}
}
var i, l, tmp
, linesargs
, items = svgnode.childNodes
for (i = 0, l = items.length; i &lt; l; i++) {
tmp = items[i]
if (tmp.tagName &amp;&amp; tmp.tagName.toUpperCase() === 'PATH') {
linesargs = convertPathToPDFLinesArgs( tmp.getAttribute("d").split(' ') )
// path start x coordinate
linesargs[0] = linesargs[0] * scale[0] + x // where x is upper left X of image
// path start y coordinate
linesargs[1] = linesargs[1] * scale[1] + y // where y is upper left Y of image
// the rest of lines are vectors. these will adjust with scale value auto.
this.lines.call(
this
, linesargs[2] // lines
, linesargs[0] // starting x
, linesargs[1] // starting y
, scale
)
}
}
// clean up
// workernode.parentNode.removeChild(workernode)
return this
}
})(jsPDF.API);
</code></pre>
</article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.3</a> on Sat Jul 29 2017 10:16:38 GMT+0100 (BST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/linenumber.js"></script>
</body>
</html>

View File

@ -0,0 +1,146 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>plugins/xmp_metadata.js - Documentation</title>
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="jsPDF.html">jsPDF</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addFont">addFont</a></li><li><a href="global.html#addHTML">addHTML</a></li><li><a href="global.html#addMetadata">addMetadata</a></li><li><a href="global.html#addPage">addPage</a></li><li><a href="global.html#autoPrint">autoPrint</a></li><li><a href="global.html#CapJoinStyles">CapJoinStyles</a></li><li><a href="global.html#circle">circle</a></li><li><a href="global.html#ellipse">ellipse</a></li><li><a href="global.html#getFontList">getFontList</a></li><li><a href="global.html#lines">lines</a></li><li><a href="global.html#lstext">lstext</a></li><li><a href="global.html#output">output</a></li><li><a href="global.html#rect">rect</a></li><li><a href="global.html#roundedRect">roundedRect</a></li><li><a href="global.html#save">save</a></li><li><a href="global.html#setDisplayMode">setDisplayMode</a></li><li><a href="global.html#setDrawColor">setDrawColor</a></li><li><a href="global.html#setFillColor">setFillColor</a></li><li><a href="global.html#setFont">setFont</a></li><li><a href="global.html#setFontSize">setFontSize</a></li><li><a href="global.html#setFontStyle">setFontStyle</a></li><li><a href="global.html#setLineCap">setLineCap</a></li><li><a href="global.html#setLineJoin">setLineJoin</a></li><li><a href="global.html#setLineWidth">setLineWidth</a></li><li><a href="global.html#setPage">setPage</a></li><li><a href="global.html#setProperties">setProperties</a></li><li><a href="global.html#setTextColor">setTextColor</a></li><li><a href="global.html#text">text</a></li><li><a href="global.html#triangle">triangle</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">plugins/xmp_metadata.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>/** ====================================================================
* jsPDF XMP metadata plugin
* Copyright (c) 2016 Jussi Utunen, u-jussi@suomi24.fi
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* ====================================================================
*/
/*global jsPDF */
/**
* Adds XMP formatted metadata to PDF
*
* @param {String} metadata The actual metadata to be added. The metadata shall be stored as XMP simple value. Note that if the metadata string contains XML markup characters "&lt;", ">" or "&amp;", those characters should be written using XML entities.
* @param {String} namespaceuri Sets the namespace URI for the metadata. Last character should be slash or hash.
* @function
* @returns {jsPDF}
* @methodOf jsPDF#
* @name addMetadata
*/
(function (jsPDFAPI) {
'use strict';
var xmpmetadata = "";
var xmpnamespaceuri = "";
var metadata_object_number = "";
jsPDFAPI.addMetadata = function (metadata,namespaceuri) {
xmpnamespaceuri = namespaceuri || "http://jspdf.default.namespaceuri/"; //The namespace URI for an XMP name shall not be empty
xmpmetadata = metadata;
this.internal.events.subscribe(
'postPutResources',
function () {
if(!xmpmetadata)
{
metadata_object_number = "";
}
else
{
var xmpmeta_beginning = '&lt;x:xmpmeta xmlns:x="adobe:ns:meta/">';
var rdf_beginning = '&lt;rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">&lt;rdf:Description rdf:about="" xmlns:jspdf="' + xmpnamespaceuri + '">&lt;jspdf:metadata>';
var rdf_ending = '&lt;/jspdf:metadata>&lt;/rdf:Description>&lt;/rdf:RDF>';
var xmpmeta_ending = '&lt;/x:xmpmeta>';
var utf8_xmpmeta_beginning = unescape(encodeURIComponent(xmpmeta_beginning));
var utf8_rdf_beginning = unescape(encodeURIComponent(rdf_beginning));
var utf8_metadata = unescape(encodeURIComponent(xmpmetadata));
var utf8_rdf_ending = unescape(encodeURIComponent(rdf_ending));
var utf8_xmpmeta_ending = unescape(encodeURIComponent(xmpmeta_ending));
var total_len = utf8_rdf_beginning.length + utf8_metadata.length + utf8_rdf_ending.length + utf8_xmpmeta_beginning.length + utf8_xmpmeta_ending.length;
metadata_object_number = this.internal.newObject();
this.internal.write('&lt;&lt; /Type /Metadata /Subtype /XML /Length ' + total_len + ' >>');
this.internal.write('stream');
this.internal.write(utf8_xmpmeta_beginning + utf8_rdf_beginning + utf8_metadata + utf8_rdf_ending + utf8_xmpmeta_ending);
this.internal.write('endstream');
this.internal.write('endobj');
}
}
);
this.internal.events.subscribe(
'putCatalog',
function () {
if (metadata_object_number) {
this.internal.write('/Metadata ' + metadata_object_number + ' 0 R');
}
}
);
return this;
};
}(jsPDF.API));
</code></pre>
</article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.3</a> on Sat Jul 29 2017 10:16:38 GMT+0100 (BST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/linenumber.js"></script>
</body>
</html>

View File

@ -0,0 +1,25 @@
/*global document */
(function() {
var source = document.getElementsByClassName('prettyprint source linenums');
var i = 0;
var lineNumber = 0;
var lineId;
var lines;
var totalLines;
var anchorHash;
if (source && source[0]) {
anchorHash = document.location.hash.substring(1);
lines = source[0].getElementsByTagName('li');
totalLines = lines.length;
for (; i < totalLines; i++) {
lineNumber++;
lineId = 'line' + lineNumber;
lines[i].id = lineId;
if (lineId === anchorHash) {
lines[i].className += ' selected';
}
}
}
})();

View File

@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -0,0 +1,2 @@
PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\f\r ]+/,null," \t\r\n "]],[["str",/^"(?:[^\n\f\r"\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*"/,null],["str",/^'(?:[^\n\f\r'\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*'/,null],["lang-css-str",/^url\(([^"')]*)\)/i],["kwd",/^(?:url|rgb|!important|@import|@page|@media|@charset|inherit)(?=[^\w-]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*)\s*:/i],["com",/^\/\*[^*]*\*+(?:[^*/][^*]*\*+)*\//],["com",
/^(?:<\!--|--\>)/],["lit",/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],["lit",/^#[\da-f]{3,6}/i],["pln",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i],["pun",/^[^\s\w"']+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[["kwd",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[["str",/^[^"')]+/]]),["css-str"]);

View File

@ -0,0 +1,28 @@
var q=null;window.PR_SHOULD_USE_CONTINUATION=!0;
(function(){function L(a){function m(a){var f=a.charCodeAt(0);if(f!==92)return f;var b=a.charAt(1);return(f=r[b])?f:"0"<=b&&b<="7"?parseInt(a.substring(1),8):b==="u"||b==="x"?parseInt(a.substring(2),16):a.charCodeAt(1)}function e(a){if(a<32)return(a<16?"\\x0":"\\x")+a.toString(16);a=String.fromCharCode(a);if(a==="\\"||a==="-"||a==="["||a==="]")a="\\"+a;return a}function h(a){for(var f=a.substring(1,a.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),a=
[],b=[],o=f[0]==="^",c=o?1:0,i=f.length;c<i;++c){var j=f[c];if(/\\[bdsw]/i.test(j))a.push(j);else{var j=m(j),d;c+2<i&&"-"===f[c+1]?(d=m(f[c+2]),c+=2):d=j;b.push([j,d]);d<65||j>122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;c<b.length;++c)i=b[c],i[0]<=j[1]+1?j[1]=Math.max(j[1],i[1]):f.push(j=i);b=["["];o&&b.push("^");b.push.apply(b,a);for(c=0;c<
f.length;++c)i=f[c],b.push(e(i[0])),i[1]>i[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c<b;++c){var j=f[c];j==="("?++i:"\\"===j.charAt(0)&&(j=+j.substring(1))&&j<=i&&(d[j]=-1)}for(c=1;c<d.length;++c)-1===d[c]&&(d[c]=++t);for(i=c=0;c<b;++c)j=f[c],j==="("?(++i,d[i]===void 0&&(f[c]="(?:")):"\\"===j.charAt(0)&&
(j=+j.substring(1))&&j<=i&&(f[c]="\\"+d[i]);for(i=c=0;c<b;++c)"^"===f[c]&&"^"!==f[c+1]&&(f[c]="");if(a.ignoreCase&&s)for(c=0;c<b;++c)j=f[c],a=j.charAt(0),j.length>=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p<d;++p){var g=a[p];if(g.ignoreCase)l=!0;else if(/[a-z]/i.test(g.source.replace(/\\u[\da-f]{4}|\\x[\da-f]{2}|\\[^UXux]/gi,""))){s=!0;l=!1;break}}for(var r=
{b:8,t:9,n:10,v:11,f:12,r:13},n=[],p=0,d=a.length;p<d;++p){g=a[p];if(g.global||g.multiline)throw Error(""+g);n.push("(?:"+y(g)+")")}return RegExp(n.join("|"),l?"gi":"g")}function M(a){function m(a){switch(a.nodeType){case 1:if(e.test(a.className))break;for(var g=a.firstChild;g;g=g.nextSibling)m(g);g=a.nodeName;if("BR"===g||"LI"===g)h[s]="\n",t[s<<1]=y++,t[s++<<1|1]=a;break;case 3:case 4:g=a.nodeValue,g.length&&(g=p?g.replace(/\r\n?/g,"\n"):g.replace(/[\t\n\r ]+/g," "),h[s]=g,t[s<<1]=y,y+=g.length,
t[s++<<1|1]=a)}}var e=/(?:^|\s)nocode(?:\s|$)/,h=[],y=0,t=[],s=0,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=document.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);m(a);return{a:h.join("").replace(/\n$/,""),c:t}}function B(a,m,e,h){m&&(a={a:m,d:a},e(a),h.push.apply(h,a.e))}function x(a,m){function e(a){for(var l=a.d,p=[l,"pln"],d=0,g=a.a.match(y)||[],r={},n=0,z=g.length;n<z;++n){var f=g[n],b=r[f],o=void 0,c;if(typeof b===
"string")c=!1;else{var i=h[f.charAt(0)];if(i)o=f.match(i[1]),b=i[0];else{for(c=0;c<t;++c)if(i=m[c],o=f.match(i[1])){b=i[0];break}o||(b="pln")}if((c=b.length>=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m),
l=[],p={},d=0,g=e.length;d<g;++d){var r=e[d],n=r[3];if(n)for(var k=n.length;--k>=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/,
q,"'\"`"]):m.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&e.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var h=a.hashComments;h&&(a.cStyleComments?(h>1?m.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):m.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),e.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):m.push(["com",/^#[^\n\r]*/,
q,"#"]));a.cStyleComments&&(e.push(["com",/^\/\/[^\n\r]*/,q]),e.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));a.regexLiterals&&e.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]);(h=a.types)&&e.push(["typ",h]);a=(""+a.keywords).replace(/^ | $/g,
"");a.length&&e.push(["kwd",RegExp("^(?:"+a.replace(/[\s,]+/g,"|")+")\\b"),q]);m.push(["pln",/^\s+/,q," \r\n\t\xa0"]);e.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]);return x(m,e)}function D(a,m){function e(a){switch(a.nodeType){case 1:if(k.test(a.className))break;if("BR"===a.nodeName)h(a),
a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)e(a);break;case 3:case 4:if(p){var b=a.nodeValue,d=b.match(t);if(d){var c=b.substring(0,d.index);a.nodeValue=c;(b=b.substring(d.index+d[0].length))&&a.parentNode.insertBefore(s.createTextNode(b),a.nextSibling);h(a);c||a.parentNode.removeChild(a)}}}}function h(a){function b(a,d){var e=d?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),g=a.nextSibling;f.appendChild(e);for(var h=g;h;h=g)g=h.nextSibling,f.appendChild(h)}return e}
for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),e;(e=a.parentNode)&&e.nodeType===1;)a=e;d.push(a)}var k=/(?:^|\s)nocode(?:\s|$)/,t=/\r\n?|\n/,s=a.ownerDocument,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=s.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);for(l=s.createElement("LI");a.firstChild;)l.appendChild(a.firstChild);for(var d=[l],g=0;g<d.length;++g)e(d[g]);m===(m|0)&&d[0].setAttribute("value",
m);var r=s.createElement("OL");r.className="linenums";for(var n=Math.max(0,m-1|0)||0,g=0,z=d.length;g<z;++g)l=d[g],l.className="L"+(g+n)%10,l.firstChild||l.appendChild(s.createTextNode("\xa0")),r.appendChild(l);a.appendChild(r)}function k(a,m){for(var e=m.length;--e>=0;){var h=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}function C(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*</.test(m)?"default-markup":"default-code";return A[a]}function E(a){var m=
a.g;try{var e=M(a.h),h=e.a;a.a=h;a.c=e.c;a.d=0;C(m,h)(a);var k=/\bMSIE\b/.test(navigator.userAgent),m=/\n/g,t=a.a,s=t.length,e=0,l=a.c,p=l.length,h=0,d=a.e,g=d.length,a=0;d[g]=s;var r,n;for(n=r=0;n<g;)d[n]!==d[n+2]?(d[r++]=d[n++],d[r++]=d[n++]):n+=2;g=r;for(n=r=0;n<g;){for(var z=d[n],f=d[n+1],b=n+2;b+2<=g&&d[b+1]===f;)b+=2;d[r++]=z;d[r++]=f;n=b}for(d.length=r;h<p;){var o=l[h+2]||s,c=d[a+2]||s,b=Math.min(o,c),i=l[h+1],j;if(i.nodeType!==1&&(j=t.substring(e,b))){k&&(j=j.replace(m,"\r"));i.nodeValue=
j;var u=i.ownerDocument,v=u.createElement("SPAN");v.className=d[a+1];var x=i.parentNode;x.replaceChild(v,i);v.appendChild(i);e<o&&(l[h+1]=i=u.createTextNode(t.substring(b,o)),x.insertBefore(i,v.nextSibling))}e=b;e>=o&&(h+=2);e>=c&&(a+=2)}}catch(w){"console"in window&&console.log(w&&w.stack?w.stack:w)}}var v=["break,continue,do,else,for,if,return,while"],w=[[v,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],
"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],F=[w,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],G=[w,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"],
H=[G,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],w=[w,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],I=[v,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],
J=[v,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=[v,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],K=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,N=/\S/,O=u({keywords:[F,H,w,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+
I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),A={};k(O,["default-code"]);k(x([],[["pln",/^[^<?]+/],["dec",/^<!\w[^>]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^<xmp\b[^>]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),
["default-markup","htm","html","mxml","xhtml","xml","xsl"]);k(x([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/],["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css",
/^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);k(x([],[["atv",/^[\S\s]+/]]),["uq.val"]);k(u({keywords:F,hashComments:!0,cStyleComments:!0,types:K}),["c","cc","cpp","cxx","cyc","m"]);k(u({keywords:"null,true,false"}),["json"]);k(u({keywords:H,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:K}),["cs"]);k(u({keywords:G,cStyleComments:!0}),["java"]);k(u({keywords:v,hashComments:!0,multiLineStrings:!0}),["bsh","csh","sh"]);k(u({keywords:I,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),
["cv","py"]);k(u({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["perl","pl","pm"]);k(u({keywords:J,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb"]);k(u({keywords:w,cStyleComments:!0,regexLiterals:!0}),["js"]);k(u({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes",
hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);k(x([],[["str",/^[\S\s]+/]]),["regex"]);window.prettyPrintOne=function(a,m,e){var h=document.createElement("PRE");h.innerHTML=a;e&&D(h,e);E({g:m,i:e,h:h});return h.innerHTML};window.prettyPrint=function(a){function m(){for(var e=window.PR_SHOULD_USE_CONTINUATION?l.now()+250:Infinity;p<h.length&&l.now()<e;p++){var n=h[p],k=n.className;if(k.indexOf("prettyprint")>=0){var k=k.match(g),f,b;if(b=
!k){b=n;for(var o=void 0,c=b.firstChild;c;c=c.nextSibling)var i=c.nodeType,o=i===1?o?b:c:i===3?N.test(c.nodeValue)?b:o:o;b=(f=o===b?void 0:o)&&"CODE"===f.tagName}b&&(k=f.className.match(g));k&&(k=k[1]);b=!1;for(o=n.parentNode;o;o=o.parentNode)if((o.tagName==="pre"||o.tagName==="code"||o.tagName==="xmp")&&o.className&&o.className.indexOf("prettyprint")>=0){b=!0;break}b||((b=(b=n.className.match(/\blinenums\b(?::(\d+))?/))?b[1]&&b[1].length?+b[1]:!0:!1)&&D(n,b),d={g:k,h:n,i:b},E(d))}}p<h.length?setTimeout(m,
250):a&&a()}for(var e=[document.getElementsByTagName("pre"),document.getElementsByTagName("code"),document.getElementsByTagName("xmp")],h=[],k=0;k<e.length;++k)for(var t=0,s=e[k].length;t<s;++t)h.push(e[k][t]);var e=q,l=Date;l.now||(l={now:function(){return+new Date}});var p=0,d,g=/\blang(?:uage)?-([\w.]+)(?!\S)/;m()};window.PR={createSimpleLexer:x,registerLangHandler:k,sourceDecorator:u,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:"com",PR_DECLARATION:"dec",PR_KEYWORD:"kwd",PR_LITERAL:"lit",
PR_NOCODE:"nocode",PR_PLAIN:"pln",PR_PUNCTUATION:"pun",PR_SOURCE:"src",PR_STRING:"str",PR_TAG:"tag",PR_TYPE:"typ"}})();

View File

@ -0,0 +1,104 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>specs/utils/compare.js - Documentation</title>
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="jsPDF.html">jsPDF</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addFont">addFont</a></li><li><a href="global.html#addMetadata">addMetadata</a></li><li><a href="global.html#addPage">addPage</a></li><li><a href="global.html#CapJoinStyles">CapJoinStyles</a></li><li><a href="global.html#circle">circle</a></li><li><a href="global.html#ellipse">ellipse</a></li><li><a href="global.html#getFontList">getFontList</a></li><li><a href="global.html#http">http</a></li><li><a href="global.html#lines">lines</a></li><li><a href="global.html#lstext">lstext</a></li><li><a href="global.html#output">output</a></li><li><a href="global.html#rect">rect</a></li><li><a href="global.html#roundedRect">roundedRect</a></li><li><a href="global.html#save">save</a></li><li><a href="global.html#setDisplayMode">setDisplayMode</a></li><li><a href="global.html#setDrawColor">setDrawColor</a></li><li><a href="global.html#setFillColor">setFillColor</a></li><li><a href="global.html#setFont">setFont</a></li><li><a href="global.html#setFontSize">setFontSize</a></li><li><a href="global.html#setFontStyle">setFontStyle</a></li><li><a href="global.html#setLineCap">setLineCap</a></li><li><a href="global.html#setLineJoin">setLineJoin</a></li><li><a href="global.html#setLineWidth">setLineWidth</a></li><li><a href="global.html#setPage">setPage</a></li><li><a href="global.html#setProperties">setProperties</a></li><li><a href="global.html#setTextColor">setTextColor</a></li><li><a href="global.html#text">text</a></li><li><a href="global.html#triangle">triangle</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">specs/utils/compare.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>/* global XMLHttpRequest, expect */
function loadBinaryResource (url) {
const req = new XMLHttpRequest()
req.open('GET', url, false)
// XHR binary charset opt by Marcus Granado 2006 [http://mgran.blogspot.com]
req.overrideMimeType('text\/plain; charset=x-user-defined')
req.send(null)
if (req.status !== 200) {
throw new Error('Unable to load file')
}
return req.responseText
}
function sendReference (filename, data) {
const req = new XMLHttpRequest()
req.open('POST', `http://localhost:9090/${filename}`, true)
req.onload = e => {
console.log(e)
}
req.send(data)
}
const resetCreationDate = input =>
input.replace(
/\/CreationDate \(D:(.*?)\)/,
'/CreationDate (D:19871210000000+00\'00\'\)'
)
/**
* Find a better way to set this
* @type {Boolean}
*/
window.comparePdf = (actual, expectedFile, suite) => {
let pdf
try {
pdf = loadBinaryResource(`/base/specs/${suite}/reference/${expectedFile}`)
} catch (error) {
sendReference(`/specs/${suite}/reference/${expectedFile}`, resetCreationDate(actual))
pdf = actual
}
const expected = resetCreationDate(pdf).trim()
actual = resetCreationDate(actual.trim())
expect(actual).toEqual(expected)
}
</code></pre>
</article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.2</a> on Sat Oct 08 2016 21:59:09 GMT+0100 (BST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/linenumber.js"></script>
</body>
</html>

View File

@ -0,0 +1,86 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>specs/utils/reference-server.js - Documentation</title>
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="jsPDF.html">jsPDF</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addFont">addFont</a></li><li><a href="global.html#addMetadata">addMetadata</a></li><li><a href="global.html#addPage">addPage</a></li><li><a href="global.html#CapJoinStyles">CapJoinStyles</a></li><li><a href="global.html#circle">circle</a></li><li><a href="global.html#ellipse">ellipse</a></li><li><a href="global.html#getFontList">getFontList</a></li><li><a href="global.html#http">http</a></li><li><a href="global.html#lines">lines</a></li><li><a href="global.html#lstext">lstext</a></li><li><a href="global.html#output">output</a></li><li><a href="global.html#rect">rect</a></li><li><a href="global.html#roundedRect">roundedRect</a></li><li><a href="global.html#save">save</a></li><li><a href="global.html#setDisplayMode">setDisplayMode</a></li><li><a href="global.html#setDrawColor">setDrawColor</a></li><li><a href="global.html#setFillColor">setFillColor</a></li><li><a href="global.html#setFont">setFont</a></li><li><a href="global.html#setFontSize">setFontSize</a></li><li><a href="global.html#setFontStyle">setFontStyle</a></li><li><a href="global.html#setLineCap">setLineCap</a></li><li><a href="global.html#setLineJoin">setLineJoin</a></li><li><a href="global.html#setLineWidth">setLineWidth</a></li><li><a href="global.html#setPage">setPage</a></li><li><a href="global.html#setProperties">setProperties</a></li><li><a href="global.html#setTextColor">setTextColor</a></li><li><a href="global.html#text">text</a></li><li><a href="global.html#triangle">triangle</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">specs/utils/reference-server.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>'use strict'
/**
* The reference server collects and saves reference PDFs for the tests.
*/
const http = require('http')
const PORT = 9090
const fs = require('fs')
// Create a server
const server = http.createServer((request, response) => {
console.log(request.url)
const wstream = fs.createWriteStream('./' + request.url)
request.on('data', (chunk) => {
console.log(chunk.length)
wstream.write(chunk)
})
request.on('end', () => {
wstream.end()
})
response.end('Test has sent reference PDF for ' + request.url)
})
// Lets start our server
server.listen(PORT, () => {
console.log(`Server listening on: http://localhost:${PORT}`)
})
</code></pre>
</article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.2</a> on Sat Oct 08 2016 21:59:09 GMT+0100 (BST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/linenumber.js"></script>
</body>
</html>

View File

@ -0,0 +1,645 @@
@import url(https://fonts.googleapis.com/css?family=Montserrat:400,700);
* {
box-sizing: border-box
}
html, body {
height: 100%;
width: 100%;
}
body {
color: #4d4e53;
background-color: white;
margin: 0 auto;
padding: 0 20px;
font-family: 'Helvetica Neue', Helvetica, sans-serif;
font-size: 16px;
line-height: 160%;
}
a,
a:active {
color: #606;
text-decoration: none;
}
a:hover {
text-decoration: none;
}
article a {
border-bottom: 1px solid #ddd;
}
article a:hover, article a:active {
border-bottom-color: #222;
}
p, ul, ol, blockquote {
margin-bottom: 1em;
}
h1, h2, h3, h4, h5, h6 {
font-family: 'Montserrat', sans-serif;
}
h1, h2, h3, h4, h5, h6 {
color: #000;
font-weight: 400;
margin: 0;
}
h1 {
font-weight: 300;
font-size: 48px;
margin: 1em 0 .5em;
}
h1.page-title {
font-size: 48px;
margin: 1em 30px;
}
h2 {
font-size: 24px;
margin: 1.5em 0 .3em;
}
h3 {
font-size: 24px;
margin: 1.2em 0 .3em;
}
h4 {
font-size: 18px;
margin: 1em 0 .2em;
color: #4d4e53;
}
h4.name {
color: #fff;
background: #6d426d;
box-shadow: 0 .25em .5em #d3d3d3;
border-top: 1px solid #d3d3d3;
border-bottom: 1px solid #d3d3d3;
margin: 1.5em 0 0.5em;
padding: .75em 0 .75em 10px;
}
h4.name a {
color: #fc83ff;
}
h4.name a:hover {
border-bottom-color: #fc83ff;
}
h5, .container-overview .subsection-title {
font-size: 120%;
letter-spacing: -0.01em;
margin: 8px 0 3px 0;
}
h6 {
font-size: 100%;
letter-spacing: -0.01em;
margin: 6px 0 3px 0;
font-style: italic;
}
tt, code, kbd, samp {
font-family: Consolas, Monaco, 'Andale Mono', monospace;
background: #f4f4f4;
padding: 1px 5px;
}
.class-description {
font-size: 130%;
line-height: 140%;
margin-bottom: 1em;
margin-top: 1em;
}
.class-description:empty {
margin: 0
}
#main {
float: right;
min-width: 360px;
width: calc(100% - 240px);
}
header {
display: block
}
section {
display: block;
background-color: #fff;
padding: 0 0 0 30px;
}
.variation {
display: none
}
.signature-attributes {
font-size: 60%;
color: #eee;
font-style: italic;
font-weight: lighter;
}
nav {
float: left;
display: block;
width: 250px;
background: #fff;
overflow: auto;
position: fixed;
height: 100%;
}
nav h3 {
margin-top: 12px;
font-size: 13px;
text-transform: uppercase;
letter-spacing: 1px;
font-weight: 700;
line-height: 24px;
margin: 15px 0 10px;
padding: 0;
color: #000;
}
nav ul {
font-family: 'Lucida Grande', 'Lucida Sans Unicode', arial, sans-serif;
font-size: 100%;
line-height: 17px;
padding: 0;
margin: 0;
list-style-type: none;
}
nav ul a,
nav ul a:active {
font-family: 'Montserrat', sans-serif;
line-height: 18px;
padding: 0;
display: block;
font-size: 12px;
}
nav a:hover,
nav a:active {
color: #606;
}
nav > ul {
padding: 0 10px;
}
nav > ul > li > a {
color: #606;
}
nav ul ul {
margin-bottom: 10px
}
nav ul ul + ul {
margin-top: -10px;
}
nav ul ul a {
color: hsl(207, 1%, 60%);
border-left: 1px solid hsl(207, 10%, 86%);
}
nav ul ul a,
nav ul ul a:active {
padding-left: 20px
}
nav h2 {
font-size: 12px;
margin: 0;
padding: 0;
}
nav > h2 > a {
display: block;
margin: 10px 0 -10px;
color: #606 !important;
}
footer {
color: hsl(0, 0%, 28%);
margin-left: 250px;
display: block;
padding: 15px;
font-style: italic;
font-size: 90%;
}
.ancestors {
color: #999
}
.ancestors a {
color: #999 !important;
}
.clear {
clear: both
}
.important {
font-weight: bold;
color: #950B02;
}
.yes-def {
text-indent: -1000px
}
.type-signature {
color: #CA79CA
}
.type-signature:last-child {
color: #eee;
}
.name, .signature {
font-family: Consolas, Monaco, 'Andale Mono', monospace
}
.signature {
color: #fc83ff;
}
.details {
margin-top: 6px;
border-left: 2px solid #DDD;
line-height: 20px;
font-size: 14px;
}
.details dt {
width: 120px;
float: left;
padding-left: 10px;
}
.details dd {
margin-left: 70px;
margin-top: 6px;
margin-bottom: 6px;
}
.details ul {
margin: 0
}
.details ul {
list-style-type: none
}
.details pre.prettyprint {
margin: 0
}
.details .object-value {
padding-top: 0
}
.description {
margin-bottom: 1em;
margin-top: 1em;
}
.code-caption {
font-style: italic;
font-size: 107%;
margin: 0;
}
.prettyprint {
font-size: 14px;
overflow: auto;
}
.prettyprint.source {
width: inherit;
line-height: 18px;
display: block;
background-color: #0d152a;
color: #aeaeae;
}
.prettyprint code {
line-height: 18px;
display: block;
background-color: #0d152a;
color: #4D4E53;
}
.prettyprint > code {
padding: 15px;
}
.prettyprint .linenums code {
padding: 0 15px
}
.prettyprint .linenums li:first-of-type code {
padding-top: 15px
}
.prettyprint code span.line {
display: inline-block
}
.prettyprint.linenums {
padding-left: 70px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.prettyprint.linenums ol {
padding-left: 0
}
.prettyprint.linenums li {
border-left: 3px #34446B solid;
}
.prettyprint.linenums li.selected, .prettyprint.linenums li.selected * {
background-color: #34446B;
}
.prettyprint.linenums li * {
-webkit-user-select: text;
-moz-user-select: text;
-ms-user-select: text;
user-select: text;
}
.params, .props {
border-spacing: 0;
border: 1px solid #ddd;
border-collapse: collapse;
border-radius: 3px;
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
width: 100%;
font-size: 14px;
margin: 1em 0;
}
.params .type {
white-space: nowrap;
}
.params code {
white-space: pre;
}
.params td, .params .name, .props .name, .name code {
color: #4D4E53;
font-family: Consolas, Monaco, 'Andale Mono', monospace;
font-size: 100%;
}
.params td, .params th, .props td, .props th {
margin: 0px;
text-align: left;
vertical-align: top;
padding: 10px;
display: table-cell;
}
.params td {
border-top: 1px solid #eee
}
.params thead tr, .props thead tr {
background-color: #fff;
font-weight: bold;
}
.params .params thead tr, .props .props thead tr {
background-color: #fff;
font-weight: bold;
}
.params td.description > p:first-child, .props td.description > p:first-child {
margin-top: 0;
padding-top: 0;
}
.params td.description > p:last-child, .props td.description > p:last-child {
margin-bottom: 0;
padding-bottom: 0;
}
span.param-type, .params td .param-type, .param-type dd {
color: #606;
font-family: Consolas, Monaco, 'Andale Mono', monospace
}
.param-type dt, .param-type dd {
display: inline-block
}
.param-type {
margin: 14px 0;
}
.disabled {
color: #454545
}
/* navicon button */
.navicon-button {
display: none;
position: relative;
padding: 2.0625rem 1.5rem;
transition: 0.25s;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
opacity: .8;
}
.navicon-button .navicon:before, .navicon-button .navicon:after {
transition: 0.25s;
}
.navicon-button:hover {
transition: 0.5s;
opacity: 1;
}
.navicon-button:hover .navicon:before, .navicon-button:hover .navicon:after {
transition: 0.25s;
}
.navicon-button:hover .navicon:before {
top: .825rem;
}
.navicon-button:hover .navicon:after {
top: -.825rem;
}
/* navicon */
.navicon {
position: relative;
width: 2.5em;
height: .3125rem;
background: #000;
transition: 0.3s;
border-radius: 2.5rem;
}
.navicon:before, .navicon:after {
display: block;
content: "";
height: .3125rem;
width: 2.5rem;
background: #000;
position: absolute;
z-index: -1;
transition: 0.3s 0.25s;
border-radius: 1rem;
}
.navicon:before {
top: .625rem;
}
.navicon:after {
top: -.625rem;
}
/* open */
.nav-trigger:checked + label:not(.steps) .navicon:before,
.nav-trigger:checked + label:not(.steps) .navicon:after {
top: 0 !important;
}
.nav-trigger:checked + label .navicon:before,
.nav-trigger:checked + label .navicon:after {
transition: 0.5s;
}
/* Minus */
.nav-trigger:checked + label {
-webkit-transform: scale(0.75);
transform: scale(0.75);
}
/* × and + */
.nav-trigger:checked + label.plus .navicon,
.nav-trigger:checked + label.x .navicon {
background: transparent;
}
.nav-trigger:checked + label.plus .navicon:before,
.nav-trigger:checked + label.x .navicon:before {
-webkit-transform: rotate(-45deg);
transform: rotate(-45deg);
background: #FFF;
}
.nav-trigger:checked + label.plus .navicon:after,
.nav-trigger:checked + label.x .navicon:after {
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
background: #FFF;
}
.nav-trigger:checked + label.plus {
-webkit-transform: scale(0.75) rotate(45deg);
transform: scale(0.75) rotate(45deg);
}
.nav-trigger:checked ~ nav {
left: 0 !important;
}
.nav-trigger:checked ~ .overlay {
display: block;
}
.nav-trigger {
position: fixed;
top: 0;
clip: rect(0, 0, 0, 0);
}
.overlay {
display: none;
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
width: 100%;
height: 100%;
background: hsla(0, 0%, 0%, 0.5);
z-index: 1;
}
@media only screen and (min-width: 320px) and (max-width: 680px) {
body {
overflow-x: hidden;
}
nav {
background: #FFF;
width: 250px;
height: 100%;
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: -250px;
z-index: 3;
padding: 0 10px;
transition: left 0.2s;
}
.navicon-button {
display: inline-block;
position: fixed;
top: 1.5em;
right: 0;
z-index: 2;
}
#main {
width: 100%;
min-width: 360px;
}
#main h1.page-title {
margin: 1em 0;
}
#main section {
padding: 0;
}
footer {
margin-left: 0;
}
}
/** Add a '#' to static members */
[data-type="member"] a::before {
content: '#';
display: inline-block;
margin-left: -14px;
margin-right: 5px;
}

View File

@ -0,0 +1,79 @@
.pln {
color: #ddd;
}
/* string content */
.str {
color: #61ce3c;
}
/* a keyword */
.kwd {
color: #fbde2d;
}
/* a comment */
.com {
color: #aeaeae;
}
/* a type name */
.typ {
color: #8da6ce;
}
/* a literal value */
.lit {
color: #fbde2d;
}
/* punctuation */
.pun {
color: #ddd;
}
/* lisp open bracket */
.opn {
color: #000000;
}
/* lisp close bracket */
.clo {
color: #000000;
}
/* a markup tag name */
.tag {
color: #8da6ce;
}
/* a markup attribute name */
.atn {
color: #fbde2d;
}
/* a markup attribute value */
.atv {
color: #ddd;
}
/* a declaration */
.dec {
color: #EF5050;
}
/* a variable name */
.var {
color: #c82829;
}
/* a function name */
.fun {
color: #4271ae;
}
/* Specify class=linenums on a pre to get line numbering */
ol.linenums {
margin-top: 0;
margin-bottom: 0;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,940 @@
%PDF-1.3
3 0 obj
<</Type /Page
/Parent 1 0 R
/Resources 2 0 R
/MediaBox [0 0 612.00 792.00]
/Contents 4 0 R
/Annots [
<</Type /Annot /Subtype /Link /Rect [20.00 749.92 70.24 731.52] /Border [0 0 0] /Dest [5 0 R /XYZ 0 792.00 0] >>
<</Type /Annot /Subtype /Link /Rect [20.00 731.52 74.08 713.12] /Border [0 0 0] /Dest [5 0 R /XYZ 0 792.00 1] >>
<</Type /Annot /Subtype /Link /Rect [74.08 731.52 128.16 713.12] /Border [0 0 0] /Dest [5 0 R /XYZ 0 792.00 2] >>
<</Type /Annot /Subtype /Link /Rect [128.16 731.52 173.44 713.12] /Border [0 0 0] /Dest [5 0 R /XYZ 0 792.00 0.5] >>
<</Type /Annot /Subtype /Link /Rect [173.44 731.52 204.64 713.12] /Border [0 0 0] /Dest [5 0 R /Fit] >>
<</Type /Annot /Subtype /Link /Rect [204.64 731.52 247.36 713.12] /Border [0 0 0] /Dest [5 0 R /FitH 792.00] >>
<</Type /Annot /Subtype /Link /Rect [247.36 731.52 289.12 713.12] /Border [0 0 0] /Dest [5 0 R /FitV 0] >>
<</Type /Annot /Subtype /Link /Rect [20.00 713.12 70.24 694.72] /Border [0 0 0] /Dest [7 0 R /XYZ 0 792.00 0] >>
<</Type /Annot /Subtype /Link /Rect [20.00 694.72 74.08 676.32] /Border [0 0 0] /Dest [7 0 R /XYZ 0 792.00 1] >>
<</Type /Annot /Subtype /Link /Rect [74.08 694.72 128.16 676.32] /Border [0 0 0] /Dest [7 0 R /XYZ 0 792.00 2] >>
<</Type /Annot /Subtype /Link /Rect [128.16 694.72 173.44 676.32] /Border [0 0 0] /Dest [7 0 R /XYZ 0 792.00 0.5] >>
<</Type /Annot /Subtype /Link /Rect [173.44 694.72 204.64 676.32] /Border [0 0 0] /Dest [7 0 R /Fit] >>
<</Type /Annot /Subtype /Link /Rect [204.64 694.72 247.36 676.32] /Border [0 0 0] /Dest [7 0 R /FitH 792.00] >>
<</Type /Annot /Subtype /Link /Rect [247.36 694.72 289.12 676.32] /Border [0 0 0] /Dest [7 0 R /FitV 0] >>
<</Type /Annot /Subtype /Link /Rect [20.00 676.32 70.24 657.92] /Border [0 0 0] /Dest [9 0 R /XYZ 0 792.00 0] >>
<</Type /Annot /Subtype /Link /Rect [20.00 657.92 74.08 639.52] /Border [0 0 0] /Dest [9 0 R /XYZ 0 792.00 1] >>
<</Type /Annot /Subtype /Link /Rect [74.08 657.92 128.16 639.52] /Border [0 0 0] /Dest [9 0 R /XYZ 0 792.00 2] >>
<</Type /Annot /Subtype /Link /Rect [128.16 657.92 173.44 639.52] /Border [0 0 0] /Dest [9 0 R /XYZ 0 792.00 0.5] >>
<</Type /Annot /Subtype /Link /Rect [173.44 657.92 204.64 639.52] /Border [0 0 0] /Dest [9 0 R /Fit] >>
<</Type /Annot /Subtype /Link /Rect [204.64 657.92 247.36 639.52] /Border [0 0 0] /Dest [9 0 R /FitH 792.00] >>
<</Type /Annot /Subtype /Link /Rect [247.36 657.92 289.12 639.52] /Border [0 0 0] /Dest [9 0 R /FitV 0] >>
<</Type /Annot /Subtype /Link /Rect [20.00 639.52 70.24 621.12] /Border [0 0 0] /Dest [11 0 R /XYZ 0 792.00 0] >>
<</Type /Annot /Subtype /Link /Rect [20.00 621.12 74.08 602.72] /Border [0 0 0] /Dest [11 0 R /XYZ 0 792.00 1] >>
<</Type /Annot /Subtype /Link /Rect [74.08 621.12 128.16 602.72] /Border [0 0 0] /Dest [11 0 R /XYZ 0 792.00 2] >>
<</Type /Annot /Subtype /Link /Rect [128.16 621.12 173.44 602.72] /Border [0 0 0] /Dest [11 0 R /XYZ 0 792.00 0.5] >>
<</Type /Annot /Subtype /Link /Rect [173.44 621.12 204.64 602.72] /Border [0 0 0] /Dest [11 0 R /Fit] >>
<</Type /Annot /Subtype /Link /Rect [204.64 621.12 247.36 602.72] /Border [0 0 0] /Dest [11 0 R /FitH 792.00] >>
<</Type /Annot /Subtype /Link /Rect [247.36 621.12 289.12 602.72] /Border [0 0 0] /Dest [11 0 R /FitV 0] >>
<</Type /Annot /Subtype /Link /Rect [20.00 602.72 70.24 584.32] /Border [0 0 0] /Dest [13 0 R /XYZ 0 792.00 0] >>
<</Type /Annot /Subtype /Link /Rect [20.00 584.32 74.08 565.92] /Border [0 0 0] /Dest [13 0 R /XYZ 0 792.00 1] >>
<</Type /Annot /Subtype /Link /Rect [74.08 584.32 128.16 565.92] /Border [0 0 0] /Dest [13 0 R /XYZ 0 792.00 2] >>
<</Type /Annot /Subtype /Link /Rect [128.16 584.32 173.44 565.92] /Border [0 0 0] /Dest [13 0 R /XYZ 0 792.00 0.5] >>
<</Type /Annot /Subtype /Link /Rect [173.44 584.32 204.64 565.92] /Border [0 0 0] /Dest [13 0 R /Fit] >>
<</Type /Annot /Subtype /Link /Rect [204.64 584.32 247.36 565.92] /Border [0 0 0] /Dest [13 0 R /FitH 792.00] >>
<</Type /Annot /Subtype /Link /Rect [247.36 584.32 289.12 565.92] /Border [0 0 0] /Dest [13 0 R /FitV 0] >>
<</Type /Annot /Subtype /Link /Rect [20.00 565.92 70.24 547.52] /Border [0 0 0] /Dest [15 0 R /XYZ 0 792.00 0] >>
<</Type /Annot /Subtype /Link /Rect [20.00 547.52 74.08 529.12] /Border [0 0 0] /Dest [15 0 R /XYZ 0 792.00 1] >>
<</Type /Annot /Subtype /Link /Rect [74.08 547.52 128.16 529.12] /Border [0 0 0] /Dest [15 0 R /XYZ 0 792.00 2] >>
<</Type /Annot /Subtype /Link /Rect [128.16 547.52 173.44 529.12] /Border [0 0 0] /Dest [15 0 R /XYZ 0 792.00 0.5] >>
<</Type /Annot /Subtype /Link /Rect [173.44 547.52 204.64 529.12] /Border [0 0 0] /Dest [15 0 R /Fit] >>
<</Type /Annot /Subtype /Link /Rect [204.64 547.52 247.36 529.12] /Border [0 0 0] /Dest [15 0 R /FitH 792.00] >>
<</Type /Annot /Subtype /Link /Rect [247.36 547.52 289.12 529.12] /Border [0 0 0] /Dest [15 0 R /FitV 0] >>
<</Type /Annot /Subtype /Link /Rect [20.00 529.12 70.24 510.72] /Border [0 0 0] /Dest [17 0 R /XYZ 0 792.00 0] >>
<</Type /Annot /Subtype /Link /Rect [20.00 510.72 74.08 492.32] /Border [0 0 0] /Dest [17 0 R /XYZ 0 792.00 1] >>
<</Type /Annot /Subtype /Link /Rect [74.08 510.72 128.16 492.32] /Border [0 0 0] /Dest [17 0 R /XYZ 0 792.00 2] >>
<</Type /Annot /Subtype /Link /Rect [128.16 510.72 173.44 492.32] /Border [0 0 0] /Dest [17 0 R /XYZ 0 792.00 0.5] >>
<</Type /Annot /Subtype /Link /Rect [173.44 510.72 204.64 492.32] /Border [0 0 0] /Dest [17 0 R /Fit] >>
<</Type /Annot /Subtype /Link /Rect [204.64 510.72 247.36 492.32] /Border [0 0 0] /Dest [17 0 R /FitH 792.00] >>
<</Type /Annot /Subtype /Link /Rect [247.36 510.72 289.12 492.32] /Border [0 0 0] /Dest [17 0 R /FitV 0] >>
<</Type /Annot /Subtype /Link /Rect [20.00 492.32 70.24 473.92] /Border [0 0 0] /Dest [19 0 R /XYZ 0 792.00 0] >>
<</Type /Annot /Subtype /Link /Rect [20.00 473.92 74.08 455.52] /Border [0 0 0] /Dest [19 0 R /XYZ 0 792.00 1] >>
<</Type /Annot /Subtype /Link /Rect [74.08 473.92 128.16 455.52] /Border [0 0 0] /Dest [19 0 R /XYZ 0 792.00 2] >>
<</Type /Annot /Subtype /Link /Rect [128.16 473.92 173.44 455.52] /Border [0 0 0] /Dest [19 0 R /XYZ 0 792.00 0.5] >>
<</Type /Annot /Subtype /Link /Rect [173.44 473.92 204.64 455.52] /Border [0 0 0] /Dest [19 0 R /Fit] >>
<</Type /Annot /Subtype /Link /Rect [204.64 473.92 247.36 455.52] /Border [0 0 0] /Dest [19 0 R /FitH 792.00] >>
<</Type /Annot /Subtype /Link /Rect [247.36 473.92 289.12 455.52] /Border [0 0 0] /Dest [19 0 R /FitV 0] >>
]
>>
endobj
4 0 obj
<</Length 3277>>
stream
0.20 w
0 G
BT
/F1 16 Tf
18.4 TL
0 g
20.00 772.00 Td
(Table of Contents) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 735.20 Td
(Page 2) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 716.80 Td
( [100%]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
74.08 716.80 Td
( [200%]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
128.16 716.80 Td
( [50%]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
173.44 716.80 Td
( [Fit]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
204.64 716.80 Td
( [FitH]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
247.36 716.80 Td
( [FitV]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 698.40 Td
(Page 3) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 680.00 Td
( [100%]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
74.08 680.00 Td
( [200%]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
128.16 680.00 Td
( [50%]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
173.44 680.00 Td
( [Fit]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
204.64 680.00 Td
( [FitH]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
247.36 680.00 Td
( [FitV]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 661.60 Td
(Page 4) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 643.20 Td
( [100%]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
74.08 643.20 Td
( [200%]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
128.16 643.20 Td
( [50%]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
173.44 643.20 Td
( [Fit]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
204.64 643.20 Td
( [FitH]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
247.36 643.20 Td
( [FitV]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 624.80 Td
(Page 5) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 606.40 Td
( [100%]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
74.08 606.40 Td
( [200%]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
128.16 606.40 Td
( [50%]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
173.44 606.40 Td
( [Fit]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
204.64 606.40 Td
( [FitH]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
247.36 606.40 Td
( [FitV]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 588.00 Td
(Page 6) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 569.60 Td
( [100%]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
74.08 569.60 Td
( [200%]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
128.16 569.60 Td
( [50%]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
173.44 569.60 Td
( [Fit]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
204.64 569.60 Td
( [FitH]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
247.36 569.60 Td
( [FitV]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 551.20 Td
(Page 7) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 532.80 Td
( [100%]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
74.08 532.80 Td
( [200%]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
128.16 532.80 Td
( [50%]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
173.44 532.80 Td
( [Fit]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
204.64 532.80 Td
( [FitH]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
247.36 532.80 Td
( [FitV]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 514.40 Td
(Page 8) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 496.00 Td
( [100%]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
74.08 496.00 Td
( [200%]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
128.16 496.00 Td
( [50%]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
173.44 496.00 Td
( [Fit]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
204.64 496.00 Td
( [FitH]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
247.36 496.00 Td
( [FitV]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 477.60 Td
(Page 9) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 459.20 Td
( [100%]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
74.08 459.20 Td
( [200%]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
128.16 459.20 Td
( [50%]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
173.44 459.20 Td
( [Fit]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
204.64 459.20 Td
( [FitH]) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
247.36 459.20 Td
( [FitV]) Tj
ET
endstream
endobj
5 0 obj
<</Type /Page
/Parent 1 0 R
/Resources 2 0 R
/MediaBox [0 0 612.00 792.00]
/Contents 6 0 R
/Annots [
<</Type /Annot /Subtype /Link /Rect [20.00 749.92 131.52 731.52] /Border [0 0 0] /Dest [3 0 R /XYZ 0 792.00 0] >>
<</Type /Annot /Subtype /Link /Rect [20.00 731.52 153.60 713.12] /Border [0 0 0] /A <</S /URI /URI (http://www.twelvetone.tv) >> >>
]
>>
endobj
6 0 obj
<</Length 198>>
stream
0.20 w
0 G
BT
/F1 16 Tf
18.4 TL
0 g
20.00 772.00 Td
(Page 2) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 735.20 Td
(Goto First Page) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 716.80 Td
(Goto External URL) Tj
ET
endstream
endobj
7 0 obj
<</Type /Page
/Parent 1 0 R
/Resources 2 0 R
/MediaBox [0 0 612.00 792.00]
/Contents 8 0 R
/Annots [
<</Type /Annot /Subtype /Link /Rect [20.00 749.92 131.52 731.52] /Border [0 0 0] /Dest [3 0 R /XYZ 0 792.00 0] >>
<</Type /Annot /Subtype /Link /Rect [20.00 731.52 153.60 713.12] /Border [0 0 0] /A <</S /URI /URI (http://www.twelvetone.tv) >> >>
]
>>
endobj
8 0 obj
<</Length 198>>
stream
0.20 w
0 G
BT
/F1 16 Tf
18.4 TL
0 g
20.00 772.00 Td
(Page 3) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 735.20 Td
(Goto First Page) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 716.80 Td
(Goto External URL) Tj
ET
endstream
endobj
9 0 obj
<</Type /Page
/Parent 1 0 R
/Resources 2 0 R
/MediaBox [0 0 612.00 792.00]
/Contents 10 0 R
/Annots [
<</Type /Annot /Subtype /Link /Rect [20.00 749.92 131.52 731.52] /Border [0 0 0] /Dest [3 0 R /XYZ 0 792.00 0] >>
<</Type /Annot /Subtype /Link /Rect [20.00 731.52 153.60 713.12] /Border [0 0 0] /A <</S /URI /URI (http://www.twelvetone.tv) >> >>
]
>>
endobj
10 0 obj
<</Length 198>>
stream
0.20 w
0 G
BT
/F1 16 Tf
18.4 TL
0 g
20.00 772.00 Td
(Page 4) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 735.20 Td
(Goto First Page) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 716.80 Td
(Goto External URL) Tj
ET
endstream
endobj
11 0 obj
<</Type /Page
/Parent 1 0 R
/Resources 2 0 R
/MediaBox [0 0 612.00 792.00]
/Contents 12 0 R
/Annots [
<</Type /Annot /Subtype /Link /Rect [20.00 749.92 131.52 731.52] /Border [0 0 0] /Dest [3 0 R /XYZ 0 792.00 0] >>
<</Type /Annot /Subtype /Link /Rect [20.00 731.52 153.60 713.12] /Border [0 0 0] /A <</S /URI /URI (http://www.twelvetone.tv) >> >>
]
>>
endobj
12 0 obj
<</Length 198>>
stream
0.20 w
0 G
BT
/F1 16 Tf
18.4 TL
0 g
20.00 772.00 Td
(Page 5) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 735.20 Td
(Goto First Page) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 716.80 Td
(Goto External URL) Tj
ET
endstream
endobj
13 0 obj
<</Type /Page
/Parent 1 0 R
/Resources 2 0 R
/MediaBox [0 0 612.00 792.00]
/Contents 14 0 R
/Annots [
<</Type /Annot /Subtype /Link /Rect [20.00 749.92 131.52 731.52] /Border [0 0 0] /Dest [3 0 R /XYZ 0 792.00 0] >>
<</Type /Annot /Subtype /Link /Rect [20.00 731.52 153.60 713.12] /Border [0 0 0] /A <</S /URI /URI (http://www.twelvetone.tv) >> >>
]
>>
endobj
14 0 obj
<</Length 198>>
stream
0.20 w
0 G
BT
/F1 16 Tf
18.4 TL
0 g
20.00 772.00 Td
(Page 6) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 735.20 Td
(Goto First Page) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 716.80 Td
(Goto External URL) Tj
ET
endstream
endobj
15 0 obj
<</Type /Page
/Parent 1 0 R
/Resources 2 0 R
/MediaBox [0 0 612.00 792.00]
/Contents 16 0 R
/Annots [
<</Type /Annot /Subtype /Link /Rect [20.00 749.92 131.52 731.52] /Border [0 0 0] /Dest [3 0 R /XYZ 0 792.00 0] >>
<</Type /Annot /Subtype /Link /Rect [20.00 731.52 153.60 713.12] /Border [0 0 0] /A <</S /URI /URI (http://www.twelvetone.tv) >> >>
]
>>
endobj
16 0 obj
<</Length 198>>
stream
0.20 w
0 G
BT
/F1 16 Tf
18.4 TL
0 g
20.00 772.00 Td
(Page 7) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 735.20 Td
(Goto First Page) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 716.80 Td
(Goto External URL) Tj
ET
endstream
endobj
17 0 obj
<</Type /Page
/Parent 1 0 R
/Resources 2 0 R
/MediaBox [0 0 612.00 792.00]
/Contents 18 0 R
/Annots [
<</Type /Annot /Subtype /Link /Rect [20.00 749.92 131.52 731.52] /Border [0 0 0] /Dest [3 0 R /XYZ 0 792.00 0] >>
<</Type /Annot /Subtype /Link /Rect [20.00 731.52 153.60 713.12] /Border [0 0 0] /A <</S /URI /URI (http://www.twelvetone.tv) >> >>
]
>>
endobj
18 0 obj
<</Length 198>>
stream
0.20 w
0 G
BT
/F1 16 Tf
18.4 TL
0 g
20.00 772.00 Td
(Page 8) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 735.20 Td
(Goto First Page) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 716.80 Td
(Goto External URL) Tj
ET
endstream
endobj
19 0 obj
<</Type /Page
/Parent 1 0 R
/Resources 2 0 R
/MediaBox [0 0 612.00 792.00]
/Contents 20 0 R
/Annots [
<</Type /Annot /Subtype /Link /Rect [20.00 749.92 131.52 731.52] /Border [0 0 0] /Dest [3 0 R /XYZ 0 792.00 0] >>
<</Type /Annot /Subtype /Link /Rect [20.00 731.52 153.60 713.12] /Border [0 0 0] /A <</S /URI /URI (http://www.twelvetone.tv) >> >>
]
>>
endobj
20 0 obj
<</Length 198>>
stream
0.20 w
0 G
BT
/F1 16 Tf
18.4 TL
0 g
20.00 772.00 Td
(Page 9) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 735.20 Td
(Goto First Page) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 716.80 Td
(Goto External URL) Tj
ET
endstream
endobj
1 0 obj
<</Type /Pages
/Kids [3 0 R 5 0 R 7 0 R 9 0 R 11 0 R 13 0 R 15 0 R 17 0 R 19 0 R ]
/Count 9
>>
endobj
21 0 obj
<</BaseFont/Helvetica/Type/Font
/Encoding/WinAnsiEncoding
/Subtype/Type1>>
endobj
22 0 obj
<</BaseFont/Helvetica-Bold/Type/Font
/Encoding/WinAnsiEncoding
/Subtype/Type1>>
endobj
23 0 obj
<</BaseFont/Helvetica-Oblique/Type/Font
/Encoding/WinAnsiEncoding
/Subtype/Type1>>
endobj
24 0 obj
<</BaseFont/Helvetica-BoldOblique/Type/Font
/Encoding/WinAnsiEncoding
/Subtype/Type1>>
endobj
25 0 obj
<</BaseFont/Courier/Type/Font
/Encoding/WinAnsiEncoding
/Subtype/Type1>>
endobj
26 0 obj
<</BaseFont/Courier-Bold/Type/Font
/Encoding/WinAnsiEncoding
/Subtype/Type1>>
endobj
27 0 obj
<</BaseFont/Courier-Oblique/Type/Font
/Encoding/WinAnsiEncoding
/Subtype/Type1>>
endobj
28 0 obj
<</BaseFont/Courier-BoldOblique/Type/Font
/Encoding/WinAnsiEncoding
/Subtype/Type1>>
endobj
29 0 obj
<</BaseFont/Times-Roman/Type/Font
/Encoding/WinAnsiEncoding
/Subtype/Type1>>
endobj
30 0 obj
<</BaseFont/Times-Bold/Type/Font
/Encoding/WinAnsiEncoding
/Subtype/Type1>>
endobj
31 0 obj
<</BaseFont/Times-Italic/Type/Font
/Encoding/WinAnsiEncoding
/Subtype/Type1>>
endobj
32 0 obj
<</BaseFont/Times-BoldItalic/Type/Font
/Encoding/WinAnsiEncoding
/Subtype/Type1>>
endobj
2 0 obj
<<
/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
/Font <<
/F1 21 0 R
/F2 22 0 R
/F3 23 0 R
/F4 24 0 R
/F5 25 0 R
/F6 26 0 R
/F7 27 0 R
/F8 28 0 R
/F9 29 0 R
/F10 30 0 R
/F11 31 0 R
/F12 32 0 R
>>
/XObject <<
>>
>>
endobj
33 0 obj
<<
/Producer (jsPDF 1.0.0-trunk)
/CreationDate (D:20141126182401+01'00')
>>
endobj
34 0 obj
<<
/Type /Catalog
/Pages 1 0 R
/OpenAction [3 0 R /FitH null]
/PageLayout /OneColumn
>>
endobj
xref
0 35
0000000000 65535 f
0000014661 00000 n
0000015918 00000 n
0000000009 00000 n
0000006405 00000 n
0000009732 00000 n
0000010099 00000 n
0000010346 00000 n
0000010713 00000 n
0000010960 00000 n
0000011328 00000 n
0000011576 00000 n
0000011945 00000 n
0000012193 00000 n
0000012562 00000 n
0000012810 00000 n
0000013179 00000 n
0000013427 00000 n
0000013796 00000 n
0000014044 00000 n
0000014413 00000 n
0000014771 00000 n
0000014862 00000 n
0000014958 00000 n
0000015057 00000 n
0000015160 00000 n
0000015249 00000 n
0000015343 00000 n
0000015440 00000 n
0000015541 00000 n
0000015634 00000 n
0000015726 00000 n
0000015820 00000 n
0000016147 00000 n
0000016239 00000 n
trailer
<<
/Size 35
/Root 34 0 R
/Info 33 0 R
>>
startxref
16343
%%EOF

View File

@ -0,0 +1,86 @@
<!doctype html>
<!--
/**
* jsPDF Annotations PlugIn
* Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv
*
* Licensed under the MIT License.
* http://opensource.org/licenses/mit-license
*/
-->
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Annotation Test</title>
</head>
<body style='background-color: silver; margin: 0;'>
<script src="../../dist/jspdf.debug.js"></script>
<script src="../js/test_harness.js"></script>
<script>
var pdf = new jsPDF('p', 'pt', 'letter');
// Create pages with a table of contents.
// TOC links to each page
// Each page links back to TOC and to an external URL
// Supported magnification Options are included.
var y = 20;
var text = 'Table of Contents';
pdf.text(text, 20, y);
y += pdf.getLineHeight() * 2;
for (var i = 2; i < 10; i ++) {
text = "Page " + i;
pdf.textWithLink(text, 20, y, {pageNumber:i});
y += pdf.getLineHeight();
var x = 20;
var width = pdf.textWithLink(" [100%]", x, y, {pageNumber:i, magFactor:'XYZ', zoom:1});
x += width;
var width = pdf.textWithLink(" [200%]", x, y, {pageNumber:i, magFactor:'XYZ', zoom:2});
x += width;
var width = pdf.textWithLink(" [50%]", x, y, {pageNumber:i, magFactor:'XYZ', zoom:.5});
x += width;
var width = pdf.textWithLink(" [Fit]", x, y, {pageNumber:i, magFactor:'Fit'});
x += width;
var width = pdf.textWithLink(" [FitH]", x, y, {pageNumber:i, magFactor:'FitH'});
x += width;
var width = pdf.textWithLink(" [FitV]", x, y, {pageNumber:i, magFactor:'FitV'});
y += pdf.getLineHeight();
}
// Create Test Pages
for (var i = 2; i < 10; i++){
pdf.addPage();
y = 20;
var text = 'Page ' + i;
pdf.text(text, 20, y);
y += pdf.getLineHeight() * 2;
text = "Goto First Page";
pdf.textWithLink(text, 20, y, {pageNumber:1});
y += pdf.getLineHeight();
text = "Goto External URL";
pdf.textWithLink(text, 20, y, {
url: 'https://parall.ax/'
});
y += pdf.getLineHeight();
}
var message = 'Chrome default PDF reader currently does not support magFactor links, \
although links still work after manualy changing magFactor. <br /> \
Firefox has a bug displaying annotations after the magFactor changes, but links do work. <br /> \
To test magFactor links [...] without bugs, use Adobe Reader or compatible application.';
pdf_test_harness_init(pdf, message);
</script>
</body>
</html>

View File

@ -0,0 +1,556 @@
%PDF-1.3
3 0 obj
<</Type /Page
/Parent 1 0 R
/Resources 2 0 R
/MediaBox [0 0 612.00 792.00]
/Contents 4 0 R
/Annots [
<</Type /Annot /Subtype /Link /Rect [20.00 749.92 70.24 731.52] /Border [0 0 0] /Dest [5 0 R /XYZ 0 792.00 0] >>
<</Type /Annot /Subtype /Link /Rect [20.00 731.52 70.24 713.12] /Border [0 0 0] /Dest [7 0 R /XYZ 0 792.00 0] >>
<</Type /Annot /Subtype /Link /Rect [20.00 713.12 70.24 694.72] /Border [0 0 0] /Dest [9 0 R /XYZ 0 792.00 0] >>
<</Type /Annot /Subtype /Link /Rect [20.00 694.72 70.24 676.32] /Border [0 0 0] /Dest [11 0 R /XYZ 0 792.00 0] >>
<</Type /Annot /Subtype /Link /Rect [20.00 676.32 70.24 657.92] /Border [0 0 0] /Dest [13 0 R /XYZ 0 792.00 0] >>
<</Type /Annot /Subtype /Link /Rect [20.00 657.92 70.24 639.52] /Border [0 0 0] /Dest [15 0 R /XYZ 0 792.00 0] >>
<</Type /Annot /Subtype /Link /Rect [20.00 639.52 70.24 621.12] /Border [0 0 0] /Dest [17 0 R /XYZ 0 792.00 0] >>
<</Type /Annot /Subtype /Link /Rect [20.00 621.12 70.24 602.72] /Border [0 0 0] /Dest [19 0 R /XYZ 0 792.00 0] >>
]
>>
endobj
4 0 obj
<</Length 525>>
stream
0.20 w
0 G
BT
/F1 16 Tf
18.4 TL
0 g
20.00 772.00 Td
(Table of Contents) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 735.20 Td
(Page 2) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 716.80 Td
(Page 3) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 698.40 Td
(Page 4) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 680.00 Td
(Page 5) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 661.60 Td
(Page 6) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 643.20 Td
(Page 7) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 624.80 Td
(Page 8) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 606.40 Td
(Page 9) Tj
ET
endstream
endobj
5 0 obj
<</Type /Page
/Parent 1 0 R
/Resources 2 0 R
/MediaBox [0 0 612.00 792.00]
/Contents 6 0 R
/Annots [
<</Type /Annot /Subtype /Link /Rect [20.00 749.92 131.52 731.52] /Border [0 0 0] /Dest [3 0 R /XYZ 0 792.00 0] >>
<</Type /Annot /Subtype /Link /Rect [20.00 731.52 153.60 713.12] /Border [0 0 0] /A <</S /URI /URI (http://www.twelvetone.tv) >> >>
]
>>
endobj
6 0 obj
<</Length 198>>
stream
0.20 w
0 G
BT
/F1 16 Tf
18.4 TL
0 g
20.00 772.00 Td
(Page 2) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 735.20 Td
(Goto First Page) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 716.80 Td
(Goto External URL) Tj
ET
endstream
endobj
7 0 obj
<</Type /Page
/Parent 1 0 R
/Resources 2 0 R
/MediaBox [0 0 612.00 792.00]
/Contents 8 0 R
/Annots [
<</Type /Annot /Subtype /Link /Rect [20.00 749.92 131.52 731.52] /Border [0 0 0] /Dest [3 0 R /XYZ 0 792.00 0] >>
<</Type /Annot /Subtype /Link /Rect [20.00 731.52 153.60 713.12] /Border [0 0 0] /A <</S /URI /URI (http://www.twelvetone.tv) >> >>
]
>>
endobj
8 0 obj
<</Length 198>>
stream
0.20 w
0 G
BT
/F1 16 Tf
18.4 TL
0 g
20.00 772.00 Td
(Page 3) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 735.20 Td
(Goto First Page) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 716.80 Td
(Goto External URL) Tj
ET
endstream
endobj
9 0 obj
<</Type /Page
/Parent 1 0 R
/Resources 2 0 R
/MediaBox [0 0 612.00 792.00]
/Contents 10 0 R
/Annots [
<</Type /Annot /Subtype /Link /Rect [20.00 749.92 131.52 731.52] /Border [0 0 0] /Dest [3 0 R /XYZ 0 792.00 0] >>
<</Type /Annot /Subtype /Link /Rect [20.00 731.52 153.60 713.12] /Border [0 0 0] /A <</S /URI /URI (http://www.twelvetone.tv) >> >>
]
>>
endobj
10 0 obj
<</Length 198>>
stream
0.20 w
0 G
BT
/F1 16 Tf
18.4 TL
0 g
20.00 772.00 Td
(Page 4) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 735.20 Td
(Goto First Page) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 716.80 Td
(Goto External URL) Tj
ET
endstream
endobj
11 0 obj
<</Type /Page
/Parent 1 0 R
/Resources 2 0 R
/MediaBox [0 0 612.00 792.00]
/Contents 12 0 R
/Annots [
<</Type /Annot /Subtype /Link /Rect [20.00 749.92 131.52 731.52] /Border [0 0 0] /Dest [3 0 R /XYZ 0 792.00 0] >>
<</Type /Annot /Subtype /Link /Rect [20.00 731.52 153.60 713.12] /Border [0 0 0] /A <</S /URI /URI (http://www.twelvetone.tv) >> >>
]
>>
endobj
12 0 obj
<</Length 198>>
stream
0.20 w
0 G
BT
/F1 16 Tf
18.4 TL
0 g
20.00 772.00 Td
(Page 5) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 735.20 Td
(Goto First Page) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 716.80 Td
(Goto External URL) Tj
ET
endstream
endobj
13 0 obj
<</Type /Page
/Parent 1 0 R
/Resources 2 0 R
/MediaBox [0 0 612.00 792.00]
/Contents 14 0 R
/Annots [
<</Type /Annot /Subtype /Link /Rect [20.00 749.92 131.52 731.52] /Border [0 0 0] /Dest [3 0 R /XYZ 0 792.00 0] >>
<</Type /Annot /Subtype /Link /Rect [20.00 731.52 153.60 713.12] /Border [0 0 0] /A <</S /URI /URI (http://www.twelvetone.tv) >> >>
]
>>
endobj
14 0 obj
<</Length 198>>
stream
0.20 w
0 G
BT
/F1 16 Tf
18.4 TL
0 g
20.00 772.00 Td
(Page 6) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 735.20 Td
(Goto First Page) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 716.80 Td
(Goto External URL) Tj
ET
endstream
endobj
15 0 obj
<</Type /Page
/Parent 1 0 R
/Resources 2 0 R
/MediaBox [0 0 612.00 792.00]
/Contents 16 0 R
/Annots [
<</Type /Annot /Subtype /Link /Rect [20.00 749.92 131.52 731.52] /Border [0 0 0] /Dest [3 0 R /XYZ 0 792.00 0] >>
<</Type /Annot /Subtype /Link /Rect [20.00 731.52 153.60 713.12] /Border [0 0 0] /A <</S /URI /URI (http://www.twelvetone.tv) >> >>
]
>>
endobj
16 0 obj
<</Length 198>>
stream
0.20 w
0 G
BT
/F1 16 Tf
18.4 TL
0 g
20.00 772.00 Td
(Page 7) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 735.20 Td
(Goto First Page) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 716.80 Td
(Goto External URL) Tj
ET
endstream
endobj
17 0 obj
<</Type /Page
/Parent 1 0 R
/Resources 2 0 R
/MediaBox [0 0 612.00 792.00]
/Contents 18 0 R
/Annots [
<</Type /Annot /Subtype /Link /Rect [20.00 749.92 131.52 731.52] /Border [0 0 0] /Dest [3 0 R /XYZ 0 792.00 0] >>
<</Type /Annot /Subtype /Link /Rect [20.00 731.52 153.60 713.12] /Border [0 0 0] /A <</S /URI /URI (http://www.twelvetone.tv) >> >>
]
>>
endobj
18 0 obj
<</Length 198>>
stream
0.20 w
0 G
BT
/F1 16 Tf
18.4 TL
0 g
20.00 772.00 Td
(Page 8) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 735.20 Td
(Goto First Page) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 716.80 Td
(Goto External URL) Tj
ET
endstream
endobj
19 0 obj
<</Type /Page
/Parent 1 0 R
/Resources 2 0 R
/MediaBox [0 0 612.00 792.00]
/Contents 20 0 R
/Annots [
<</Type /Annot /Subtype /Link /Rect [20.00 749.92 131.52 731.52] /Border [0 0 0] /Dest [3 0 R /XYZ 0 792.00 0] >>
<</Type /Annot /Subtype /Link /Rect [20.00 731.52 153.60 713.12] /Border [0 0 0] /A <</S /URI /URI (http://www.twelvetone.tv) >> >>
]
>>
endobj
20 0 obj
<</Length 198>>
stream
0.20 w
0 G
BT
/F1 16 Tf
18.4 TL
0 g
20.00 772.00 Td
(Page 9) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 735.20 Td
(Goto First Page) Tj
ET
BT
/F1 16 Tf
18.4 TL
0 g
20.00 716.80 Td
(Goto External URL) Tj
ET
endstream
endobj
1 0 obj
<</Type /Pages
/Kids [3 0 R 5 0 R 7 0 R 9 0 R 11 0 R 13 0 R 15 0 R 17 0 R 19 0 R ]
/Count 9
>>
endobj
21 0 obj
<</BaseFont/Helvetica/Type/Font
/Encoding/WinAnsiEncoding
/Subtype/Type1>>
endobj
22 0 obj
<</BaseFont/Helvetica-Bold/Type/Font
/Encoding/WinAnsiEncoding
/Subtype/Type1>>
endobj
23 0 obj
<</BaseFont/Helvetica-Oblique/Type/Font
/Encoding/WinAnsiEncoding
/Subtype/Type1>>
endobj
24 0 obj
<</BaseFont/Helvetica-BoldOblique/Type/Font
/Encoding/WinAnsiEncoding
/Subtype/Type1>>
endobj
25 0 obj
<</BaseFont/Courier/Type/Font
/Encoding/WinAnsiEncoding
/Subtype/Type1>>
endobj
26 0 obj
<</BaseFont/Courier-Bold/Type/Font
/Encoding/WinAnsiEncoding
/Subtype/Type1>>
endobj
27 0 obj
<</BaseFont/Courier-Oblique/Type/Font
/Encoding/WinAnsiEncoding
/Subtype/Type1>>
endobj
28 0 obj
<</BaseFont/Courier-BoldOblique/Type/Font
/Encoding/WinAnsiEncoding
/Subtype/Type1>>
endobj
29 0 obj
<</BaseFont/Times-Roman/Type/Font
/Encoding/WinAnsiEncoding
/Subtype/Type1>>
endobj
30 0 obj
<</BaseFont/Times-Bold/Type/Font
/Encoding/WinAnsiEncoding
/Subtype/Type1>>
endobj
31 0 obj
<</BaseFont/Times-Italic/Type/Font
/Encoding/WinAnsiEncoding
/Subtype/Type1>>
endobj
32 0 obj
<</BaseFont/Times-BoldItalic/Type/Font
/Encoding/WinAnsiEncoding
/Subtype/Type1>>
endobj
2 0 obj
<<
/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
/Font <<
/F1 21 0 R
/F2 22 0 R
/F3 23 0 R
/F4 24 0 R
/F5 25 0 R
/F6 26 0 R
/F7 27 0 R
/F8 28 0 R
/F9 29 0 R
/F10 30 0 R
/F11 31 0 R
/F12 32 0 R
>>
/XObject <<
>>
>>
endobj
33 0 obj
<<
/Producer (jsPDF 1.0.0-trunk)
/CreationDate (D:20141126191522+01'00')
>>
endobj
34 0 obj
<<
/Type /Catalog
/Pages 1 0 R
/OpenAction [3 0 R /FitH null]
/PageLayout /OneColumn
>>
endobj
xref
0 35
0000000000 65535 f
0000006542 00000 n
0000007799 00000 n
0000000009 00000 n
0000001039 00000 n
0000001613 00000 n
0000001980 00000 n
0000002227 00000 n
0000002594 00000 n
0000002841 00000 n
0000003209 00000 n
0000003457 00000 n
0000003826 00000 n
0000004074 00000 n
0000004443 00000 n
0000004691 00000 n
0000005060 00000 n
0000005308 00000 n
0000005677 00000 n
0000005925 00000 n
0000006294 00000 n
0000006652 00000 n
0000006743 00000 n
0000006839 00000 n
0000006938 00000 n
0000007041 00000 n
0000007130 00000 n
0000007224 00000 n
0000007321 00000 n
0000007422 00000 n
0000007515 00000 n
0000007607 00000 n
0000007701 00000 n
0000008028 00000 n
0000008120 00000 n
trailer
<<
/Size 35
/Root 34 0 R
/Info 33 0 R
>>
startxref
8224
%%EOF

View File

@ -0,0 +1,84 @@
<!doctype html>
<!--
/**
* jsPDF Annotations PlugIn
* Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv
*
* Licensed under the MIT License.
* http://opensource.org/licenses/mit-license
*/
-->
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Annotation Test - Text</title>
</head>
<body style='background-color: silver; margin: 0;'>
<script src="../../dist/jspdf.debug.js"></script>
<script src="../js/test_harness.js"></script>
<script>
var pdf = new jsPDF('p', 'pt', 'letter');
var y = 20;
var w;
var text = 'Text Annotations';
pdf.text(text, 20, y);
pdf.setFontSize(12);
y += pdf.getLineHeight() * 2;
pdf.text("Text Annotation With Popup (closed)", 20, y);
pdf.createAnnotation({
type : 'text',
title: 'note',
bounds : {
x : 0,
y : y,
w : 200,
h : 80
},
contents : 'This is text annotation (closed by default)',
open : false
});
y += pdf.getLineHeight() * 5;
pdf.text("Text Annotation With Popup (opened)", 20, y);
pdf.createAnnotation({
type : 'text',
title: 'another note',
bounds : {
x : 0,
y : y,
w : 200,
h : 80
},
contents : 'This is a text annotation (opened)',
open : true
});
y += pdf.getLineHeight() * 5;
pdf.text("Free Text Annotation", 20, y);
pdf.createAnnotation({
type : 'freetext',
bounds : {
x : 0,
y : y + 10,
w : 200,
h : 20
},
contents : 'This is a freetext annotation',
color : '#ff0000'
});
var warning = 'Most web browsers do not display annotations. Download the PDF and open in Adobe Reader, etc).'
pdf_test_harness_init(pdf, warning);
</script>
</body>
</html>

View File

@ -0,0 +1,523 @@
<!doctype>
<html>
<head>
<title>jsPDF</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="css/smoothness/jquery-ui-1.8.17.custom.css">
<link rel="stylesheet" type="text/css" href="css/main.css">
<script type="text/javascript" src="js/jquery/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="js/jquery/jquery-ui-1.8.17.custom.min.js"></script>
<script type="text/javascript" src="../dist/jspdf.debug.js"></script>
<script type="text/javascript" src="js/basic.js"></script>
<script>
$(function() {
$("#accordion-basic, #accordion-text, #accordion-graphic").accordion({
autoHeight: false,
navigation: true
});
$( "#tabs" ).tabs();
$(".button").button();
});
</script>
</head>
<body>
<a href="https://github.com/MrRio/jsPDF">
<img style="position: absolute; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" />
</a>
<h1>jsPDF Demos</h1>
<p>Examples for using jsPDF with Data URIs below. Go <a href="https://github.com/MrRio/jsPDF">back to project homepage</a>.</p>
<div id="tabs">
<ul>
<li><a href="#tabs-basic">Basic elements</a></li>
<li><a href="#tabs-text">Text elements</a></li>
<li><a href="#tabs-graphic">Graphic elements</a></li>
</ul>
<div id="tabs-basic">
<div id="accordion-basic">
<h2><a href="#">Simple two-page text document</a></h2>
<div><p><pre>var doc = new jsPDF();
doc.text(20, 20, 'Hello world!');
doc.text(20, 30, 'This is client-side Javascript, pumping out a PDF.');
doc.addPage();
doc.text(20, 20, 'Do you like that?');
doc.save('Test.pdf');</pre>
<a href="javascript:demoTwoPageDocument()" class="button">Run Code</a></p></div>
<h2><a href="#">Landscape document</a></h2>
<div><p><pre>var doc = new jsPDF('landscape');
doc.text(20, 20, 'Hello landscape world!');
doc.save('Test.pdf');</pre>
<a href="javascript:demoLandscape()" class="button">Run Code</a></p></div>
<h2><a href="#">Adding metadata</a></h2>
<div><p><pre>var doc = new jsPDF();
doc.text(20, 20, 'This PDF has a title, subject, author, keywords and a creator.');
// Optional - set properties on the document
doc.setProperties({
title: 'Title',
subject: 'This is the subject',
author: 'James Hall',
keywords: 'generated, javascript, web 2.0, ajax',
creator: 'MEEE'
});
// Output as Data URI
doc.save('Test.pdf');</pre>
<a href="javascript:demoMetadata()" class="button">Run Code</a></p></div>
<h2><a href="#">Example of user input</a></h2>
<div><p><pre>var name = prompt('What is your name?');
var multiplier = prompt('Enter a number:');
multiplier = parseInt(multiplier);
var doc = new jsPDF();
doc.setFontSize(22);
doc.text(20, 20, 'Questions');
doc.setFontSize(16);
doc.text(20, 30, 'This belongs to: ' + name);
for(var i = 1; i <= 12; i ++) {
doc.text(20, 30 + (i * 10), i + ' x ' + multiplier + ' = ___');
}
doc.addPage();
doc.setFontSize(22);
doc.text(20, 20, 'Answers');
doc.setFontSize(16);
for(var i = 1; i <= 12; i ++) {
doc.text(20, 30 + (i * 10), i + ' x ' + multiplier + ' = ' + (i * multiplier));
}
doc.save('Test.pdf');</pre>
<a href="javascript:demoUserInput()" class="button">Run Code</a></p></div>
</div>
</div>
<div id="tabs-text">
<div id="accordion-text">
<h2><a href="#">Different font sizes</a></h2>
<div><p><pre>var doc = new jsPDF();
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.');
doc.save('Test.pdf');</pre>
<a href="javascript:demoFontSizes()" class="button">Run Code</a>
</p></div>
<h2><a href="#">Different font types</a></h2>
<div><p><pre>var doc = new jsPDF();
doc.text(20, 20, 'This is the default font.');
doc.setFont("courier");
doc.text(20, 30, 'This is courier normal.');
doc.setFont("times");
doc.setFontType("italic");
doc.text(20, 40, 'This is times italic.');
doc.setFont("helvetica");
doc.setFontType("bold");
doc.text(20, 50, 'This is helvetica bold.');
doc.setFont("courier");
doc.setFontType("bolditalic");
doc.text(20, 60, 'This is courier bolditalic.');
doc.save('Test.pdf');</pre>
<a href="javascript:demoFontTypes()" class="button">Run Code</a></p></div>
<h2><a href="#">Different text colors</a></h2>
<div><p><pre>var doc = new jsPDF();
doc.setTextColor(100);
doc.text(20, 20, 'This is gray.');
doc.setTextColor(150);
doc.text(20, 30, 'This is light gray.');
doc.setTextColor(255,0,0);
doc.text(20, 40, 'This is red.');
doc.setTextColor(0,255,0);
doc.text(20, 50, 'This is green.');
doc.setTextColor(0,0,255);
doc.text(20, 60, 'This is blue.');
doc.save('Test.pdf');</pre>
<a href="javascript:demoTextColors()" class="button">Run Code</a></p></div>
<h2><a href="#">Font-metrics-based line sizing and split</a></h2>
<div><p><pre>var pdf = new jsPDF('p','in','letter')
, sizes = [12, 16, 20]
, fonts = [['Times','Roman'],['Helvetica',''], ['Times','Italic']]
, font, size, lines
, verticalOffset = 0.5 // inches on a 8.5 x 11 inch sheet.
, loremipsum = 'Lorem ipsum dolor sit amet, ...'
for (var i in fonts){
if (fonts.hasOwnProperty(i)) {
font = fonts[i]
size = sizes[i]
lines = pdf.setFont(font[0], font[1])
.setFontSize(size)
.splitTextToSize(loremipsum, 7.5)
// Don't want to preset font, size to calculate the lines?
// .splitTextToSize(text, maxsize, options)
// allows you to pass an object with any of the following:
// {
// 'fontSize': 12
// , 'fontStyle': 'Italic'
// , 'fontName': 'Times'
// }
// Without these, .splitTextToSize will use current / default
// font Family, Style, Size.
pdf.text(0.5, verticalOffset + size / 72, lines)
verticalOffset += (lines.length + 0.5) * size / 72
}
}
pdf.save('Test.pdf');</pre>
<a href="javascript:demoStringSplitting()" class="button">Run Code</a></p></div>
<h2><a href="#">fromHTML plugin</a></h2>
<div class="to_pdf">
<div><p>This (BETA level. API is subject to change!) plugin allows one to scrape formatted text from an HTML fragment into PDF. Font size, styles are copied. The long-running text is split to stated content width.</p></div>
<div style="border-width: 2px; border-style: dotted; padding: 1em; font-size:120%;line-height: 1.5em;" id="fromHTMLtestdiv">
<h2 style="font-size:120%">Header Two</h2>
<strong><em>Double style span</em></strong>
<span style="font-family:monospace">Monotype span with
carriage return. </span><span style="font-size:300%">a humongous font size span.</span>
Followed by long parent-less text node. asdf qwer asdf zxcv qsasfd qwer qwasfd zcxv sdf qwer qwe sdf wer qwer asdf zxv.
<div <span style="font-family:serif">Serif Inner DIV (bad markup, but testing block detection)</div><span style="font-family:sans-serif"> Sans-serif span with extra spaces </span>
Followed by text node without any wrapping element. <span>And some long long text span attached at the end to test line wrap. qwer asdf qwer lkjh asdf zxvc safd qwer wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww qewr asdf zxcv.</span>
<p style="font-size:120%">This is a <em style="font-size:120%">new</em> paragraph.</p>
This is more wrapping-less text.
<p id="bypassme" style="font-size:120%">This paragraph will <strong style="font-size:120%">NOT</strong> be on resulting PDF because a special attached element handler will be looking for the ID - 'bypassme' - and should bypass rendering it.</p>
<p style="font-size:120%;text-align:center">This is <strong style="font-size:120%">another</strong> paragraph.</p>
<p>I want to hide this particular <span class="hide">word</span></p>
<p style="text-align:justify">
Integer dignissim urna tortor? Cum rhoncus, a lacus ultricies tincidunt, tristique lundium enim urna, magna? Sed, enim penatibus? Lacus pellentesque integer et pulvinar tortor? Dapibus in arcu arcu, vut dolor? Et! Placerat pulvinar cursus, urna ultrices arcu nunc, a ultrices dictumst elementum? Magnis rhoncus pellentesque, egestas enim purus, augue et nascetur sociis enim rhoncus. Adipiscing augue placerat tincidunt pulvinar ridiculus. Porta in sociis arcu et placerat augue sit enim nec hac massa, turpis ridiculus nunc phasellus pulvinar proin sit pulvinar, ultrices aliquet placerat amet? Lorem nunc porttitor etiam risus tempor placerat amet non hac, nunc sed odio augue? Turpis, magnis. Lorem pid, a porttitor tincidunt adipiscing sagittis pellentesque, mattis amet, duis proin, penatibus lectus lorem eros, nisi, tempor phasellus, elit.
</p>
<h2>Image Support</h2>
<p>
NOTES: the img src must be on the same domain or the external domain should allow Cross-origin.
</p>
<img src="https://maps.googleapis.com/maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&zoom=13&size=400x300&scale=1&maptype=roadmap&markers=color:blue%7Clabel:S%7C40.702147,-74.015794&markers=color:green%7Clabel:G%7C40.711614,-74.012318&markers=color:red%7Ccolor:red%7Clabel:C%7C40.718217,-73.998284&sensor=false" width="400" height="300">
<!-- ADD_PAGE -->
<h2>New page added with html comment: ADD_PAGE</h2>
<h2></h2>
<p>HTML Table:</p>
<p>
NOTES: Must set the COLGROUP tag with "with" on each COL tag as %, inspect the table. BTW the css does not have a good style to render the table on the html :P, feel free to the add the CSS.
</p>
<table>
<colgroup>
<col width="60%">
<col width="40%">
</colgroup>
<thead>
<tr>
<th>
Heading1
</th>
<th>
Heading2
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
cell 1,1
</td>
<td>
cell 1,2
</td>
</tr>
<tr>
<td>
cell 2,1
</td>
<td>
cell 2,2
</td>
</tr>
<tr>
<td>
cell 3,1
</td>
<td>
cell 3,2
</td>
</tr>
<tr>
<td>
cell 4,1
</td>
<td>
cell 4,2
</td>
</tr>
</tvody>
</table>
<h2></h2>
<h2></h2>
<p>HTML Lists:</p>
<div style="margin-left:20px">
<ul>
<li>Lorem Ipsum</li>
<li>Dolor Sit amen</li>
<li>Lorem Ipsum</li>
<li>Dolor Sit amen</li>
</ul>
<ol>
<li>Lorem Ipsum</li>
<li>Dolor Sit amen</li>
<li>Lorem Ipsum</li>
<li>Dolor Sit amen</li>
</ol>
</div>
</div>
<div><p><pre>var pdf = new jsPDF('p', 'pt', 'letter')
// source can be HTML-formatted string, or a reference
// to an actual DOM element from which the text will be scraped.
, source = $('#fromHTMLtestdiv')[0]
// we support special element handlers. Register them with jQuery-style
// ID selector for either ID or node name. ("#iAmID", "div", "span" etc.)
// There is no support for any other type of selectors
// (class, of compound) at this time.
, specialElementHandlers = {
// element with id of "bypass" - jQuery style selector
'#bypassme': function(element, renderer){
// true = "handled elsewhere, bypass text extraction"
return true
},
'.hide': function(element, renderer){
// true = "handled elsewhere, bypass text extraction"
return true
}
}
margins = {
top: 80,
bottom: 60,
left: 40,
width: 522
};
// all coords and widths are in jsPDF instance's declared units
// 'inches' in this case
pdf.fromHTML(
source // HTML string or DOM elem ref.
, margins.left // x coord
, margins.top // y coord
, {
'width': margins.width // max width of content on PDF
, 'elementHandlers': specialElementHandlers
},
function (dispose) {
// dispose: object with X, Y of the last line add to the PDF
// this allow the insertion of new lines after html
pdf.save('Test.pdf');
},
margins
)
</pre>
<button onclick="javascript:demoFromHTML()" class="button">Run Code</button></p></div></div>
<h2><a href="#">Text alignment</a></h2>
<div><p><pre>var pdf = new jsPDF('p', 'pt', 'letter');
pdf.text( 'This text is normally\raligned.', 140, 50 );
pdf.text( 'This text is centered\raround\rthis point.', 140, 120, 'center' );
pdf.text( 'This text is rotated\rand centered around\rthis point.', 140, 300, 45, 'center' );
pdf.text( 'This text is\raligned to the\rright.', 140, 400, 'right' );
pdf.text( 'This text is\raligned to the\rright.', 140, 550, 45, 'right' );
pdf.text( 'This single line is centered', 460, 50, 'center' );
pdf.text( 'This right aligned text\r\rhas an empty line.', 460, 200, 'right' );
pdf.save('Test.pdf');</pre>
<a href="javascript:demoTextAlign()" class="button">Run Code</a></p></div>
</div>
</div>
<div id="tabs-graphic">
<div id="accordion-graphic">
<h2><a href="#">Draw example: rectangles / squares</a></h2>
<div><p><pre>var doc = new jsPDF();
doc.rect(20, 20, 10, 10); // empty square
doc.rect(40, 20, 10, 10, 'F'); // filled square
doc.setDrawColor(255,0,0);
doc.rect(60, 20, 10, 10); // empty red square
doc.setDrawColor(255,0,0);
doc.rect(80, 20, 10, 10, 'FD'); // filled square with red borders
doc.setDrawColor(0);
doc.setFillColor(255,0,0);
doc.rect(100, 20, 10, 10, 'F'); // filled red square
doc.setDrawColor(0);
doc.setFillColor(255,0,0);
doc.rect(120, 20, 10, 10, 'FD'); // filled red square with black borders
doc.setDrawColor(0);
doc.setFillColor(255, 255, 255);
doc.roundedRect(140, 20, 10, 10, 3, 3, 'FD'); // Black square with rounded corners
doc.save('Test.pdf');</pre>
<a href="javascript:demoRectangles()" class="button">Run Code</a></p></div>
<h2><a href="#">Draw example: lines</a></h2>
<div><p><pre>var doc = new jsPDF();
doc.line(20, 20, 60, 20); // horizontal line
doc.setLineWidth(0.5);
doc.line(20, 25, 60, 25);
doc.setLineWidth(1);
doc.line(20, 30, 60, 30);
doc.setLineWidth(1.5);
doc.line(20, 35, 60, 35);
doc.setDrawColor(255,0,0); // draw red lines
doc.setLineWidth(0.1);
doc.line(100, 20, 100, 60); // vertical line
doc.setLineWidth(0.5);
doc.line(105, 20, 105, 60);
doc.setLineWidth(1);
doc.line(110, 20, 110, 60);
doc.setLineWidth(1.5);
doc.line(115, 20, 115, 60);
doc.save('Test.pdf');</pre>
<a href="javascript:demoLines()" class="button">Run Code</a></p></div>
<h2><a href="#">Draw example: circles and ellipses</a></h2>
<div><p><pre>var doc = new jsPDF();
doc.ellipse(40, 20, 10, 5);
doc.setFillColor(0,0,255);
doc.ellipse(80, 20, 10, 5, 'F');
doc.setLineWidth(1);
doc.setDrawColor(0);
doc.setFillColor(255,0,0);
doc.circle(120, 20, 5, 'FD');
doc.save('Test.pdf');</pre>
<a href="javascript:demoCircles()" class="button">Run Code</a></p></div>
<h2><a href="#">Draw example: triangles</a></h2>
<div><p><pre>var doc = new jsPDF();
doc.triangle(60, 100, 60, 120, 80, 110, 'FD');
doc.setLineWidth(1);
doc.setDrawColor(255,0,0);
doc.setFillColor(0,0,255);
doc.triangle(100, 100, 110, 100, 120, 130, 'FD');
doc.save('My file.pdf');</pre>
<a href="javascript:demoTriangles()" class="button">Run Code</a></p></div>
<h2><a href="#">Draw example: Images</a></h2>
<div><p><pre>// Because of security restrictions, getImageFromUrl will
// not load images from other domains. Chrome has added
// security restrictions that prevent it from loading images
// when running local files. Run with: chromium --allow-file-access-from-files --allow-file-access
// to temporarily get around this issue.
var getImageFromUrl = function(url, callback) {
var img = new Image();
img.onError = function() {
alert('Cannot load image: "'+url+'"');
};
img.onload = function() {
callback(img);
};
img.src = url;
}
// Since images are loaded asyncronously, we must wait to create
// the pdf until we actually have the image.
// If we already had the jpeg image binary data loaded into
// a string, we create the pdf without delay.
var createPDF = function(imgData) {
var doc = new jsPDF();
// This is a modified addImage example which requires jsPDF 1.0+
// You can check the former one at <em>examples/js/basic.js</em>
doc.addImage(imgData, 'JPEG', 10, 10, 50, 50, 'monkey'); // Cache the image using the alias 'monkey'
doc.addImage('monkey', 70, 10, 100, 120); // use the cached 'monkey' image, JPEG is optional regardless
// As you can guess, using the cached image reduces the generated PDF size by 50%!
// Rotate Image - new feature as of 2014-09-20
doc.addImage({
imageData : imgData,
angle : -20,
x : 10,
y : 78,
w : 45,
h : 58
});
// Output as Data URI
doc.output('datauri');
}
getImageFromUrl('thinking-monkey.jpg', createPDF);
</pre>
<!--a href="javascript:demoImages()" class="button">Run Code</a-->
<!-- I'm lazy, so using eval() directly, sorry ;) [diegocr] -->
<a href="javascript:void(0);" onclick="eval($(this).prev().text())" class="button">Run Code</a>
</p></div>
</div>
</div>
</div>
</div>
</body>
</html>

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,689 @@
<!DOCTYPE html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<title>Bar Graph With Text And Lines</title>
<script type="text/javascript" src="../../libs/canvg_context2d/libs/rgbcolor.js"></script>
<script type="text/javascript" src="../../libs/canvg_context2d/libs/StackBlur.js"></script>
<script type="text/javascript" src="../../libs/canvg_context2d/canvg.js"></script>
<script src="../../dist/jspdf.debug.js"></script>
</head>
<body>
<h1>Bar Graph With Text And Lines</h1>
<button onclick="doRefresh();">Refresh</button>
<iframe id='result' style='width: 100%; height: 400px'></iframe>
<svg id="svg" class="v-m-root" style="left: 600px; top: 600px; display: block; cursor: default" width="1000"
height="500">
<svg class="v-m-root" width="711" height="442"
style="left: 0px; top: 0px; direction: ltr; cursor: default; position: absolute; box-sizing: border-box;">
<rect class="v-eventLayer" x="0" y="0" fill-opacity="0" width="711" height="442"></rect>
<g class="v-backgroundutil">
<rect class="v-background-body viz-plot-background v-morphable-background"
id="background-rect-87f41b63-ea3a-4ba7-b40b-8e8ea24e6ec7" x="0" y="0" width="711" height="442"
style="fill:transparent"></rect>
</g>
<defs></defs>
<g class="v-m-title" transform="translate(0, 0)"></g>
<g class="v-m-legends" transform="translate(589, 24)">
<g class="v-m-legend" transform="translate(0,0)">
<rect class="v-bound" width="98" height="36" fill="transparent"></rect>
<g class="v-content" transform="translate(0,0)">
<g class="v-groups v-label viz-legend-valueLabel" transform="translate(0,0)"
font-family="'Open Sans', Arial, Helvetica, sans-serif" font-size="12px" font-weight="normal"
fill="#000000" font-style="normal">
<g class="v-legend-content">
<rect class="v-indicatedRect v-legend-item v-hovershadow" visibility="hidden" width="108"
x="-5" y="-3" height="18"></rect>
<g class="v-row ID_0" transform="translate(0,0)">
<path class="" fill="#748cb2" stroke-width="0" stroke="transparent" opacity="1"
stroke-opacity="undefined"
d="M0,-6L-3,-6Q-6,-6 -6,-3L-6,3Q-6,6 -3,6L3,6Q6,6 6,3L6,-3Q6,-6 3,-6Z"
transform="translate(6,6)"></path>
<text x="18" y="12">SALES</text>
<rect class="v-eventRect v-legend-item ID_1" height="18" fill="rgba(255, 255, 255, 0)"
transform="translate(0,-3)" width="88"></rect>
</g>
<g class="v-row ID_1" transform="translate(0,18)">
<path class="" fill="#9cc677" stroke-width="0" stroke="transparent" opacity="1"
stroke-opacity="undefined" d="M-6,0 A6,6 0 1,0 6,0 A6,6 0 1,0 -6,0z"
transform="translate(6,6)"></path>
<text x="18" y="12">NET_SALES</text>
<rect class="v-eventRect v-legend-item ID_1" height="18" fill="rgba(255, 255, 255, 0)"
transform="translate(0,-3)" width="88"></rect>
</g>
</g>
</g>
</g>
</g>
</g>
<g class="v-m-main" transform="translate(24, 24)">
<rect class="v-bound" width="557" height="394" visibility="hidden"></rect>
<g class="v-m-background" transform="translate(38.5,7.199999999999999)">
<rect class="v-background-body viz-plot-background v-morphable-background"
id="background-rect-8a3ae954-b76a-4093-b85e-9ca4dad99996" x="0" y="0" width="518.5" height="316.8"
style="fill:transparent"></rect>
<line class="v-background-border viz-plot-background-border" x1="0" y1="0" x2="0" y2="316.8"
shape-rendering="crispEdges" stroke="#d8d8d8" stroke-width="0"></line>
<line class="v-background-border viz-plot-background-border" x1="518.5" y1="0" x2="518.5" y2="316.8"
shape-rendering="crispEdges" stroke="#d8d8d8" stroke-width="0"></line>
<line class="v-background-border viz-plot-background-border" x1="0" y1="0" x2="518.5" y2="0"
shape-rendering="crispEdges" stroke="#d8d8d8" stroke-width="0"></line>
<line class="v-background-border viz-plot-background-border" x1="0" y1="316.8" x2="518.5" y2="316.8"
shape-rendering="crispEdges" stroke="#d8d8d8" stroke-width="0"></line>
</g>
<g class="v-m-xAxis" transform="translate(38.5,324)">
<rect class="v-bound" width="519.5" height="70" fill="transparent"></rect>
<g class="viz-axis v-axis">
<g class="viz-axis-body v-body">
<path class="v-categoryaxisline" d="M0 5L0 0L518.5 0L518.5 5" fill="none" stroke="#96a8c3"
stroke-width="1" shape-rendering="crispEdges"></path>
<line class="v-categoryaxisline" x1="27.289473684210527" x2="27.289473684210527" y1="0" y2="5"
stroke="#96a8c3" stroke-width="1" shape-rendering="crispEdges"></line>
<line class="v-categoryaxisline" x1="54.578947368421055" x2="54.578947368421055" y1="0" y2="5"
stroke="#96a8c3" stroke-width="1" shape-rendering="crispEdges"></line>
<line class="v-categoryaxisline" x1="81.86842105263159" x2="81.86842105263159" y1="0" y2="5"
stroke="#96a8c3" stroke-width="1" shape-rendering="crispEdges"></line>
<line class="v-categoryaxisline" x1="109.15789473684211" x2="109.15789473684211" y1="0" y2="5"
stroke="#96a8c3" stroke-width="1" shape-rendering="crispEdges"></line>
<line class="v-categoryaxisline" x1="136.44736842105263" x2="136.44736842105263" y1="0" y2="5"
stroke="#96a8c3" stroke-width="1" shape-rendering="crispEdges"></line>
<line class="v-categoryaxisline" x1="163.73684210526315" x2="163.73684210526315" y1="0" y2="5"
stroke="#96a8c3" stroke-width="1" shape-rendering="crispEdges"></line>
<line class="v-categoryaxisline" x1="191.02631578947367" x2="191.02631578947367" y1="0" y2="5"
stroke="#96a8c3" stroke-width="1" shape-rendering="crispEdges"></line>
<line class="v-categoryaxisline" x1="218.3157894736842" x2="218.3157894736842" y1="0" y2="5"
stroke="#96a8c3" stroke-width="1" shape-rendering="crispEdges"></line>
<line class="v-categoryaxisline" x1="245.6052631578947" x2="245.6052631578947" y1="0" y2="5"
stroke="#96a8c3" stroke-width="1" shape-rendering="crispEdges"></line>
<line class="v-categoryaxisline" x1="272.89473684210526" x2="272.89473684210526" y1="0" y2="5"
stroke="#96a8c3" stroke-width="1" shape-rendering="crispEdges"></line>
<line class="v-categoryaxisline" x1="300.1842105263158" x2="300.1842105263158" y1="0" y2="5"
stroke="#96a8c3" stroke-width="1" shape-rendering="crispEdges"></line>
<line class="v-categoryaxisline" x1="327.4736842105263" x2="327.4736842105263" y1="0" y2="5"
stroke="#96a8c3" stroke-width="1" shape-rendering="crispEdges"></line>
<line class="v-categoryaxisline" x1="354.7631578947368" x2="354.7631578947368" y1="0" y2="5"
stroke="#96a8c3" stroke-width="1" shape-rendering="crispEdges"></line>
<line class="v-categoryaxisline" x1="382.05263157894734" x2="382.05263157894734" y1="0" y2="5"
stroke="#96a8c3" stroke-width="1" shape-rendering="crispEdges"></line>
<line class="v-categoryaxisline" x1="409.34210526315786" x2="409.34210526315786" y1="0" y2="5"
stroke="#96a8c3" stroke-width="1" shape-rendering="crispEdges"></line>
<line class="v-categoryaxisline" x1="436.6315789473684" x2="436.6315789473684" y1="0" y2="5"
stroke="#96a8c3" stroke-width="1" shape-rendering="crispEdges"></line>
<line class="v-categoryaxisline" x1="463.9210526315789" x2="463.9210526315789" y1="0" y2="5"
stroke="#96a8c3" stroke-width="1" shape-rendering="crispEdges"></line>
<line class="v-categoryaxisline" x1="491.2105263157894" x2="491.2105263157894" y1="0" y2="5"
stroke="#96a8c3" stroke-width="1" shape-rendering="crispEdges"></line>
<rect x="0" y="1" width="27.289473684210527" height="69" opacity="0"
class="v-labelarea v-axis-item" fill="#cccccc"></rect>
<g fill="#333333" class="v-label viz-axis-label v-morphable-label" font-size="12px"
font-weight="normal" font-family="'Open Sans', Arial, Helvetica, sans-serif">
<text pointer-events="none" x="13.644736842105264" y="11" dominant-baseline="middle"
text-anchor="end" transform="rotate( -90 13.644736842105264 11 )">01/05/08
</text>
</g>
<rect x="27.289473684210527" y="1" width="27.289473684210527" height="69" opacity="0"
class="v-labelarea v-axis-item"></rect>
<g fill="#333333" class="v-label viz-axis-label v-morphable-label" font-size="12px"
font-weight="normal" font-family="'Open Sans', Arial, Helvetica, sans-serif">
<text pointer-events="none" x="40.934210526315795" y="11" dominant-baseline="middle"
text-anchor="end" transform="rotate( -90 40.934210526315795 11 )">01/08/08
</text>
</g>
<rect x="54.578947368421055" y="1" width="27.289473684210535" height="69" opacity="0"
class="v-labelarea v-axis-item"></rect>
<g fill="#333333" class="v-label viz-axis-label v-morphable-label" font-size="12px"
font-weight="normal" font-family="'Open Sans', Arial, Helvetica, sans-serif">
<text pointer-events="none" x="68.22368421052633" y="11" dominant-baseline="middle"
text-anchor="end" transform="rotate( -90 68.22368421052633 11 )">02/05/08
</text>
</g>
<rect x="81.86842105263159" y="1" width="27.28947368421052" height="69" opacity="0"
class="v-labelarea v-axis-item"></rect>
<g fill="#333333" class="v-label viz-axis-label v-morphable-label" font-size="12px"
font-weight="normal" font-family="'Open Sans', Arial, Helvetica, sans-serif">
<text pointer-events="none" x="95.51315789473685" y="11" dominant-baseline="middle"
text-anchor="end" transform="rotate( -90 95.51315789473685 11 )">02/06/08
</text>
</g>
<rect x="109.15789473684211" y="1" width="27.28947368421052" height="69" opacity="0"
class="v-labelarea v-axis-item"></rect>
<g fill="#333333" class="v-label viz-axis-label v-morphable-label" font-size="12px"
font-weight="normal" font-family="'Open Sans', Arial, Helvetica, sans-serif">
<text pointer-events="none" x="122.80263157894737" y="11" dominant-baseline="middle"
text-anchor="end" transform="rotate( -90 122.80263157894737 11 )">02/12/08
</text>
</g>
<rect x="136.44736842105263" y="1" width="27.28947368421052" height="69" opacity="0"
class="v-labelarea v-axis-item"></rect>
<g fill="#333333" class="v-label viz-axis-label v-morphable-label" font-size="12px"
font-weight="normal" font-family="'Open Sans', Arial, Helvetica, sans-serif">
<text pointer-events="none" x="150.0921052631579" y="11" dominant-baseline="middle"
text-anchor="end" transform="rotate( -90 150.0921052631579 11 )">03/12/08
</text>
</g>
<rect x="163.73684210526315" y="1" width="27.28947368421052" height="69" opacity="0"
class="v-labelarea v-axis-item"></rect>
<g fill="#333333" class="v-label viz-axis-label v-morphable-label" font-size="12px"
font-weight="normal" font-family="'Open Sans', Arial, Helvetica, sans-serif">
<text pointer-events="none" x="177.3815789473684" y="11" dominant-baseline="middle"
text-anchor="end" transform="rotate( -90 177.3815789473684 11 )">04/02/08
</text>
</g>
<rect x="191.02631578947367" y="1" width="27.28947368421052" height="69" opacity="0"
class="v-labelarea v-axis-item"></rect>
<g fill="#333333" class="v-label viz-axis-label v-morphable-label" font-size="12px"
font-weight="normal" font-family="'Open Sans', Arial, Helvetica, sans-serif">
<text pointer-events="none" x="204.67105263157893" y="11" dominant-baseline="middle"
text-anchor="end" transform="rotate( -90 204.67105263157893 11 )">04/05/08
</text>
</g>
<rect x="218.3157894736842" y="1" width="27.28947368421052" height="69" opacity="0"
class="v-labelarea v-axis-item"></rect>
<g fill="#333333" class="v-label viz-axis-label v-morphable-label" font-size="12px"
font-weight="normal" font-family="'Open Sans', Arial, Helvetica, sans-serif">
<text pointer-events="none" x="231.96052631578945" y="11" dominant-baseline="middle"
text-anchor="end" transform="rotate( -90 231.96052631578945 11 )">04/08/08
</text>
</g>
<rect x="245.6052631578947" y="1" width="27.28947368421055" height="69" opacity="0"
class="v-labelarea v-axis-item"></rect>
<g fill="#333333" class="v-label viz-axis-label v-morphable-label" font-size="12px"
font-weight="normal" font-family="'Open Sans', Arial, Helvetica, sans-serif">
<text pointer-events="none" x="259.25" y="11" dominant-baseline="middle" text-anchor="end"
transform="rotate( -90 259.25 11 )">04/10/08
</text>
</g>
<rect x="272.89473684210526" y="1" width="27.28947368421052" height="69" opacity="0"
class="v-labelarea v-axis-item"></rect>
<g fill="#333333" class="v-label viz-axis-label v-morphable-label" font-size="12px"
font-weight="normal" font-family="'Open Sans', Arial, Helvetica, sans-serif">
<text pointer-events="none" x="286.5394736842105" y="11" dominant-baseline="middle"
text-anchor="end" transform="rotate( -90 286.5394736842105 11 )">05/02/08
</text>
</g>
<rect x="300.1842105263158" y="1" width="27.28947368421052" height="69" opacity="0"
class="v-labelarea v-axis-item"></rect>
<g fill="#333333" class="v-label viz-axis-label v-morphable-label" font-size="12px"
font-weight="normal" font-family="'Open Sans', Arial, Helvetica, sans-serif">
<text pointer-events="none" x="313.82894736842104" y="11" dominant-baseline="middle"
text-anchor="end" transform="rotate( -90 313.82894736842104 11 )">06/06/08
</text>
</g>
<rect x="327.4736842105263" y="1" width="27.28947368421052" height="69" opacity="0"
class="v-labelarea v-axis-item"></rect>
<g fill="#333333" class="v-label viz-axis-label v-morphable-label" font-size="12px"
font-weight="normal" font-family="'Open Sans', Arial, Helvetica, sans-serif">
<text pointer-events="none" x="341.11842105263156" y="11" dominant-baseline="middle"
text-anchor="end" transform="rotate( -90 341.11842105263156 11 )">07/09/08
</text>
</g>
<rect x="354.7631578947368" y="1" width="27.28947368421052" height="69" opacity="0"
class="v-labelarea v-axis-item"></rect>
<g fill="#333333" class="v-label viz-axis-label v-morphable-label" font-size="12px"
font-weight="normal" font-family="'Open Sans', Arial, Helvetica, sans-serif">
<text pointer-events="none" x="368.4078947368421" y="11" dominant-baseline="middle"
text-anchor="end" transform="rotate( -90 368.4078947368421 11 )">08/02/08
</text>
</g>
<rect x="382.05263157894734" y="1" width="27.28947368421052" height="69" opacity="0"
class="v-labelarea v-axis-item"></rect>
<g fill="#333333" class="v-label viz-axis-label v-morphable-label" font-size="12px"
font-weight="normal" font-family="'Open Sans', Arial, Helvetica, sans-serif">
<text pointer-events="none" x="395.6973684210526" y="11" dominant-baseline="middle"
text-anchor="end" transform="rotate( -90 395.6973684210526 11 )">08/11/08
</text>
</g>
<rect x="409.34210526315786" y="1" width="27.28947368421052" height="69" opacity="0"
class="v-labelarea v-axis-item"></rect>
<g fill="#333333" class="v-label viz-axis-label v-morphable-label" font-size="12px"
font-weight="normal" font-family="'Open Sans', Arial, Helvetica, sans-serif">
<text pointer-events="none" x="422.9868421052631" y="11" dominant-baseline="middle"
text-anchor="end" transform="rotate( -90 422.9868421052631 11 )">09/07/08
</text>
</g>
<rect x="436.6315789473684" y="1" width="27.28947368421052" height="69" opacity="0"
class="v-labelarea v-axis-item"></rect>
<g fill="#333333" class="v-label viz-axis-label v-morphable-label" font-size="12px"
font-weight="normal" font-family="'Open Sans', Arial, Helvetica, sans-serif">
<text pointer-events="none" x="450.27631578947364" y="11" dominant-baseline="middle"
text-anchor="end" transform="rotate( -90 450.27631578947364 11 )">10/01/08
</text>
</g>
<rect x="463.9210526315789" y="1" width="27.28947368421052" height="69" opacity="0"
class="v-labelarea v-axis-item"></rect>
<g fill="#333333" class="v-label viz-axis-label v-morphable-label" font-size="12px"
font-weight="normal" font-family="'Open Sans', Arial, Helvetica, sans-serif">
<text pointer-events="none" x="477.56578947368416" y="11" dominant-baseline="middle"
text-anchor="end" transform="rotate( -90 477.56578947368416 11 )">10/05/08
</text>
</g>
<rect x="491.2105263157894" y="1" width="27.289473684210577" height="69" opacity="0"
class="v-labelarea v-axis-item"></rect>
<g fill="#333333" class="v-label viz-axis-label v-morphable-label" font-size="12px"
font-weight="normal" font-family="'Open Sans', Arial, Helvetica, sans-serif">
<text pointer-events="none" x="504.8552631578947" y="11" dominant-baseline="middle"
text-anchor="end" transform="rotate( -90 504.8552631578947 11 )">12/01/08
</text>
</g>
</g>
</g>
</g>
<g class="v-m-yAxis" transform="translate(0,7.199999999999999)">
<rect class="v-bound" width="38.5" height="317.8" fill="transparent"></rect>
<g class="viz-axis v-axis">
<g class="viz-axis-body v-body">
<line class="v-valueaxisline" x1="33" x2="38" y1="0" y2="0" stroke="#96a8c3" stroke-width="1"
shape-rendering="crispEdges"></line>
<g fill="#333333" class="v-label viz-axis-label v-morphable-label" font-size="12px"
font-weight="normal" font-family="'Open Sans', Arial, Helvetica, sans-serif">
<text x="27" y="0" dominant-baseline="middle" text-anchor="end">120</text>
</g>
<line class="v-valueaxisline" x1="33" x2="38" y1="52.79999999999999" y2="52.79999999999999"
stroke="#96a8c3" stroke-width="1" shape-rendering="crispEdges"></line>
<line class="v-gridline" y1="52.79999999999999" y2="52.79999999999999" x1="38" x2="556.5"
stroke="#7f8fa6" stroke-width="1" shape-rendering="crispEdges"></line>
<g fill="#333333" class="v-label viz-axis-label v-morphable-label" font-size="12px"
font-weight="normal" font-family="'Open Sans', Arial, Helvetica, sans-serif">
<text x="27" y="52.79999999999999" dominant-baseline="middle" text-anchor="end">100</text>
</g>
<line class="v-valueaxisline" x1="33" x2="38" y1="105.60000000000001" y2="105.60000000000001"
stroke="#96a8c3" stroke-width="1" shape-rendering="crispEdges"></line>
<line class="v-gridline" y1="105.60000000000001" y2="105.60000000000001" x1="38" x2="556.5"
stroke="#7f8fa6" stroke-width="1" shape-rendering="crispEdges"></line>
<g fill="#333333" class="v-label viz-axis-label v-morphable-label" font-size="12px"
font-weight="normal" font-family="'Open Sans', Arial, Helvetica, sans-serif">
<text x="27" y="105.60000000000001" dominant-baseline="middle" text-anchor="end">80</text>
</g>
<line class="v-valueaxisline" x1="33" x2="38" y1="158.4" y2="158.4" stroke="#96a8c3"
stroke-width="1" shape-rendering="crispEdges"></line>
<line class="v-gridline" y1="158.4" y2="158.4" x1="38" x2="556.5" stroke="#7f8fa6"
stroke-width="1" shape-rendering="crispEdges"></line>
<g fill="#333333" class="v-label viz-axis-label v-morphable-label" font-size="12px"
font-weight="normal" font-family="'Open Sans', Arial, Helvetica, sans-serif">
<text x="27" y="158.4" dominant-baseline="middle" text-anchor="end">60</text>
</g>
<line class="v-valueaxisline" x1="33" x2="38" y1="211.20000000000002" y2="211.20000000000002"
stroke="#96a8c3" stroke-width="1" shape-rendering="crispEdges"></line>
<line class="v-gridline" y1="211.20000000000002" y2="211.20000000000002" x1="38" x2="556.5"
stroke="#7f8fa6" stroke-width="1" shape-rendering="crispEdges"></line>
<g fill="#333333" class="v-label viz-axis-label v-morphable-label" font-size="12px"
font-weight="normal" font-family="'Open Sans', Arial, Helvetica, sans-serif">
<text x="27" y="211.20000000000002" dominant-baseline="middle" text-anchor="end">40</text>
</g>
<line class="v-valueaxisline" x1="33" x2="38" y1="264" y2="264" stroke="#96a8c3"
stroke-width="1" shape-rendering="crispEdges"></line>
<line class="v-gridline" y1="264" y2="264" x1="38" x2="556.5" stroke="#7f8fa6" stroke-width="1"
shape-rendering="crispEdges"></line>
<g fill="#333333" class="v-label viz-axis-label v-morphable-label" font-size="12px"
font-weight="normal" font-family="'Open Sans', Arial, Helvetica, sans-serif">
<text x="27" y="264" dominant-baseline="middle" text-anchor="end">20</text>
</g>
<line class="v-valueaxisline" x1="33" x2="38" y1="316.8" y2="316.8" stroke="#96a8c3"
stroke-width="1" shape-rendering="crispEdges"></line>
<g fill="#333333" class="v-label viz-axis-label v-morphable-label" font-size="12px"
font-weight="normal" font-family="'Open Sans', Arial, Helvetica, sans-serif">
<text x="27" y="316.8" dominant-baseline="middle" text-anchor="end">0</text>
</g>
<path class="v-valueaxisline" d="M38 316.8L38 316.8L38 0L38 0" fill="none" stroke="#96a8c3"
stroke-width="1" shape-rendering="crispEdges"></path>
</g>
</g>
</g>
<g class="v-m-plot" transform="translate(38.5,7.199999999999999)"
clip-path="url(#clip1_26e943ec-3ac9-4d5e-9f24-6a6485dacdd7)">
<clipPath class="v-clippath" id="clip1_26e943ec-3ac9-4d5e-9f24-6a6485dacdd7">
<rect width="518.5" height="316.8"></rect>
</clipPath>
<rect class="v-bound" width="518.5" height="316.8" fill="transparent"></rect>
<g class="v-modules">
<g class="v-module">
<rect class="v-bound" width="518.5" height="316.8" visibility="hidden"></rect>
<defs>
<clipPath id="clipPlot_8813">
<rect width="518.5" height="316.8"></rect>
</clipPath>
</defs>
<defs></defs>
<g class="v-datashapesgroup" fill="none" clip-path="url(#clipPlot_8813)">
<g class="v-column">
<g class="v-datashape" transform="translate(6.822368421052632,134.64000000000001)">
<rect class="v-datapoint v-morphable-datapoint" fill="#748cb2"
shape-rendering="crispEdges" fill-opacity="1" stroke="none"
width="13.644736842105264" height="182.16" y="0" x="0"></rect>
</g>
</g>
<g class="v-column">
<g class="v-datashape" transform="translate(34.11184210526316,200.64)">
<rect class="v-datapoint v-morphable-datapoint" fill="#748cb2"
shape-rendering="crispEdges" fill-opacity="1" stroke="none"
width="13.644736842105264" height="116.16000000000003" y="0" x="0"></rect>
</g>
</g>
<g class="v-column">
<g class="v-datashape" transform="translate(61.401315789473685,213.84000000000003)">
<rect class="v-datapoint v-morphable-datapoint" fill="#748cb2"
shape-rendering="crispEdges" fill-opacity="1" stroke="none"
width="13.644736842105264" height="102.95999999999998" y="0" x="0"></rect>
</g>
</g>
<g class="v-column">
<g class="v-datashape" transform="translate(88.69078947368422,298.32)">
<rect class="v-datapoint v-morphable-datapoint" fill="#748cb2"
shape-rendering="crispEdges" fill-opacity="1" stroke="none"
width="13.644736842105264" height="18.480000000000018" y="0" x="0"></rect>
</g>
</g>
<g class="v-column">
<g class="v-datashape" transform="translate(115.98026315789474,290.4)">
<rect class="v-datapoint v-morphable-datapoint" fill="#748cb2"
shape-rendering="crispEdges" fill-opacity="1" stroke="none"
width="13.644736842105264" height="26.400000000000034" y="0" x="0"></rect>
</g>
</g>
<g class="v-column">
<g class="v-datashape" transform="translate(143.26973684210526,208.56)">
<rect class="v-datapoint v-morphable-datapoint" fill="#748cb2"
shape-rendering="crispEdges" fill-opacity="1" stroke="none"
width="13.644736842105264" height="108.24000000000001" y="0" x="0"></rect>
</g>
</g>
<g class="v-column">
<g class="v-datashape" transform="translate(170.5592105263158,134.64000000000001)">
<rect class="v-datapoint v-morphable-datapoint" fill="#748cb2"
shape-rendering="crispEdges" fill-opacity="1" stroke="none"
width="13.644736842105264" height="182.16" y="0" x="0"></rect>
</g>
</g>
<g class="v-column">
<g class="v-datashape" transform="translate(197.84868421052633,55.44000000000002)">
<rect class="v-datapoint v-morphable-datapoint" fill="#748cb2"
shape-rendering="crispEdges" fill-opacity="1" stroke="none"
width="13.644736842105264" height="261.36" y="0" x="0"></rect>
</g>
</g>
<g class="v-column">
<g class="v-datashape" transform="translate(225.13815789473685,213.84000000000003)">
<rect class="v-datapoint v-morphable-datapoint" fill="#748cb2"
shape-rendering="crispEdges" fill-opacity="1" stroke="none"
width="13.644736842105264" height="102.95999999999998" y="0" x="0"></rect>
</g>
</g>
<g class="v-column">
<g class="v-datashape" transform="translate(252.42763157894737,110.88)">
<rect class="v-datapoint v-morphable-datapoint" fill="#748cb2"
shape-rendering="crispEdges" fill-opacity="1" stroke="none"
width="13.644736842105264" height="205.92000000000002" y="0" x="0"></rect>
</g>
</g>
<g class="v-column">
<g class="v-datashape" transform="translate(279.7171052631579,190.08)">
<rect class="v-datapoint v-morphable-datapoint" fill="#748cb2"
shape-rendering="crispEdges" fill-opacity="1" stroke="none"
width="13.644736842105264" height="126.72" y="0" x="0"></rect>
</g>
</g>
<g class="v-column">
<g class="v-datashape" transform="translate(307.00657894736844,110.88)">
<rect class="v-datapoint v-morphable-datapoint" fill="#748cb2"
shape-rendering="crispEdges" fill-opacity="1" stroke="none"
width="13.644736842105264" height="205.92000000000002" y="0" x="0"></rect>
</g>
</g>
<g class="v-column">
<g class="v-datashape" transform="translate(334.296052631579,311.52)">
<rect class="v-datapoint v-morphable-datapoint" fill="#748cb2"
shape-rendering="crispEdges" fill-opacity="1" stroke="none"
width="13.644736842105264" height="5.28000000000003" y="0" x="0"></rect>
</g>
</g>
<g class="v-column">
<g class="v-datashape" transform="translate(361.58552631578954,219.12)">
<rect class="v-datapoint v-morphable-datapoint" fill="#748cb2"
shape-rendering="crispEdges" fill-opacity="1" stroke="none"
width="13.644736842105264" height="97.68" y="0" x="0"></rect>
</g>
</g>
<g class="v-column">
<g class="v-datashape" transform="translate(388.87500000000006,73.91999999999999)">
<rect class="v-datapoint v-morphable-datapoint" fill="#748cb2"
shape-rendering="crispEdges" fill-opacity="1" stroke="none"
width="13.644736842105264" height="242.88000000000002" y="0" x="0"></rect>
</g>
</g>
<g class="v-column">
<g class="v-datashape" transform="translate(416.1644736842106,87.12)">
<rect class="v-datapoint v-morphable-datapoint" fill="#748cb2"
shape-rendering="crispEdges" fill-opacity="1" stroke="none"
width="13.644736842105264" height="229.68" y="0" x="0"></rect>
</g>
</g>
<g class="v-column">
<g class="v-datashape" transform="translate(443.4539473684211,298.32)">
<rect class="v-datapoint v-morphable-datapoint" fill="#748cb2"
shape-rendering="crispEdges" fill-opacity="1" stroke="none"
width="13.644736842105264" height="18.480000000000018" y="0" x="0"></rect>
</g>
</g>
<g class="v-column">
<g class="v-datashape" transform="translate(470.7434210526316,290.4)">
<rect class="v-datapoint v-morphable-datapoint" fill="#748cb2"
shape-rendering="crispEdges" fill-opacity="1" stroke="none"
width="13.644736842105264" height="26.400000000000034" y="0" x="0"></rect>
</g>
</g>
<g class="v-column">
<g class="v-datashape" transform="translate(498.03289473684214,232.32000000000002)">
<rect class="v-datapoint v-morphable-datapoint" fill="#748cb2"
shape-rendering="crispEdges" fill-opacity="1" stroke="none"
width="13.644736842105264" height="84.47999999999999" y="0" x="0"></rect>
</g>
</g>
</g>
</g>
<g class="v-module">
<rect class="v-bound" width="518.5" height="316.8" visibility="hidden"></rect>
<g>
<g class="v-datalines" opacity="1" fill="none">
<g class="v-axis1">
<path class="v-lines v-morphable-line" stroke-width="2" stroke-linejoin="round"
d="M13.644736842105264,184.79999999999998L40.934210526315795,198L68.22368421052632,237.60000000000002L95.51315789473685,163.67999999999998L122.80263157894737,102.96L150.0921052631579,224.39999999999998L177.38157894736844,134.64000000000001L204.67105263157896,76.56000000000002L231.96052631578948,237.60000000000002L259.25,89.76L286.5394736842105,192.72000000000003L313.82894736842104,171.60000000000002L341.1184210526316,79.2L368.40789473684214,285.12L395.69736842105266,213.84000000000003L422.9868421052632,245.52L450.2763157894737,132L477.5657894736842,279.84L504.85526315789474,248.16"
stroke="#9cc677"></path>
</g>
</g>
<g class="v-lightLines" fill="none"></g>
<g class="v-markers v-datashapesgroup" fill="none">
<g class="v-axis1">
<g class="v-marker">
<g class="v-datashape"
transform="translate(13.644736842105264,184.79999999999998)">
<path class="v-datapoint v-morphable-datapoint v-datapoint-default"
fill="#9cc677" stroke-width="2" stroke="transparent"
stroke-opacity="null" d="M-4,0 A4,4 0 1,0 4,0 A4,4 0 1,0 -4,0z"
fill-opacity="1"></path>
</g>
<g class="v-datashape" transform="translate(40.934210526315795,198)">
<path class="v-datapoint v-morphable-datapoint v-datapoint-default"
fill="#9cc677" stroke-width="2" stroke="transparent"
stroke-opacity="null" d="M-4,0 A4,4 0 1,0 4,0 A4,4 0 1,0 -4,0z"
fill-opacity="1"></path>
</g>
<g class="v-datashape"
transform="translate(68.22368421052632,237.60000000000002)">
<path class="v-datapoint v-morphable-datapoint v-datapoint-default"
fill="#9cc677" stroke-width="2" stroke="transparent"
stroke-opacity="null" d="M-4,0 A4,4 0 1,0 4,0 A4,4 0 1,0 -4,0z"
fill-opacity="1"></path>
</g>
<g class="v-datashape"
transform="translate(95.51315789473685,163.67999999999998)">
<path class="v-datapoint v-morphable-datapoint v-datapoint-default"
fill="#9cc677" stroke-width="2" stroke="transparent"
stroke-opacity="null" d="M-4,0 A4,4 0 1,0 4,0 A4,4 0 1,0 -4,0z"
fill-opacity="1"></path>
</g>
<g class="v-datashape" transform="translate(122.80263157894737,102.96)">
<path class="v-datapoint v-morphable-datapoint v-datapoint-default"
fill="#9cc677" stroke-width="2" stroke="transparent"
stroke-opacity="null" d="M-4,0 A4,4 0 1,0 4,0 A4,4 0 1,0 -4,0z"
fill-opacity="1"></path>
</g>
<g class="v-datashape"
transform="translate(150.0921052631579,224.39999999999998)">
<path class="v-datapoint v-morphable-datapoint v-datapoint-default"
fill="#9cc677" stroke-width="2" stroke="transparent"
stroke-opacity="null" d="M-4,0 A4,4 0 1,0 4,0 A4,4 0 1,0 -4,0z"
fill-opacity="1"></path>
</g>
<g class="v-datashape"
transform="translate(177.38157894736844,134.64000000000001)">
<path class="v-datapoint v-morphable-datapoint v-datapoint-default"
fill="#9cc677" stroke-width="2" stroke="transparent"
stroke-opacity="null" d="M-4,0 A4,4 0 1,0 4,0 A4,4 0 1,0 -4,0z"
fill-opacity="1"></path>
</g>
<g class="v-datashape"
transform="translate(204.67105263157896,76.56000000000002)">
<path class="v-datapoint v-morphable-datapoint v-datapoint-default"
fill="#9cc677" stroke-width="2" stroke="transparent"
stroke-opacity="null" d="M-4,0 A4,4 0 1,0 4,0 A4,4 0 1,0 -4,0z"
fill-opacity="1"></path>
</g>
<g class="v-datashape"
transform="translate(231.96052631578948,237.60000000000002)">
<path class="v-datapoint v-morphable-datapoint v-datapoint-default"
fill="#9cc677" stroke-width="2" stroke="transparent"
stroke-opacity="null" d="M-4,0 A4,4 0 1,0 4,0 A4,4 0 1,0 -4,0z"
fill-opacity="1"></path>
</g>
<g class="v-datashape" transform="translate(259.25,89.76)">
<path class="v-datapoint v-morphable-datapoint v-datapoint-default"
fill="#9cc677" stroke-width="2" stroke="transparent"
stroke-opacity="null" d="M-4,0 A4,4 0 1,0 4,0 A4,4 0 1,0 -4,0z"
fill-opacity="1"></path>
</g>
<g class="v-datashape"
transform="translate(286.5394736842105,192.72000000000003)">
<path class="v-datapoint v-morphable-datapoint v-datapoint-default"
fill="#9cc677" stroke-width="2" stroke="transparent"
stroke-opacity="null" d="M-4,0 A4,4 0 1,0 4,0 A4,4 0 1,0 -4,0z"
fill-opacity="1"></path>
</g>
<g class="v-datashape"
transform="translate(313.82894736842104,171.60000000000002)">
<path class="v-datapoint v-morphable-datapoint v-datapoint-default"
fill="#9cc677" stroke-width="2" stroke="transparent"
stroke-opacity="null" d="M-4,0 A4,4 0 1,0 4,0 A4,4 0 1,0 -4,0z"
fill-opacity="1"></path>
</g>
<g class="v-datashape" transform="translate(341.1184210526316,79.2)">
<path class="v-datapoint v-morphable-datapoint v-datapoint-default"
fill="#9cc677" stroke-width="2" stroke="transparent"
stroke-opacity="null" d="M-4,0 A4,4 0 1,0 4,0 A4,4 0 1,0 -4,0z"
fill-opacity="1"></path>
</g>
<g class="v-datashape" transform="translate(368.40789473684214,285.12)">
<path class="v-datapoint v-morphable-datapoint v-datapoint-default"
fill="#9cc677" stroke-width="2" stroke="transparent"
stroke-opacity="null" d="M-4,0 A4,4 0 1,0 4,0 A4,4 0 1,0 -4,0z"
fill-opacity="1"></path>
</g>
<g class="v-datashape"
transform="translate(395.69736842105266,213.84000000000003)">
<path class="v-datapoint v-morphable-datapoint v-datapoint-default"
fill="#9cc677" stroke-width="2" stroke="transparent"
stroke-opacity="null" d="M-4,0 A4,4 0 1,0 4,0 A4,4 0 1,0 -4,0z"
fill-opacity="1"></path>
</g>
<g class="v-datashape" transform="translate(422.9868421052632,245.52)">
<path class="v-datapoint v-morphable-datapoint v-datapoint-default"
fill="#9cc677" stroke-width="2" stroke="transparent"
stroke-opacity="null" d="M-4,0 A4,4 0 1,0 4,0 A4,4 0 1,0 -4,0z"
fill-opacity="1"></path>
</g>
<g class="v-datashape" transform="translate(450.2763157894737,132)">
<path class="v-datapoint v-morphable-datapoint v-datapoint-default"
fill="#9cc677" stroke-width="2" stroke="transparent"
stroke-opacity="null" d="M-4,0 A4,4 0 1,0 4,0 A4,4 0 1,0 -4,0z"
fill-opacity="1"></path>
</g>
<g class="v-datashape" transform="translate(477.5657894736842,279.84)">
<path class="v-datapoint v-morphable-datapoint v-datapoint-default"
fill="#9cc677" stroke-width="2" stroke="transparent"
stroke-opacity="null" d="M-4,0 A4,4 0 1,0 4,0 A4,4 0 1,0 -4,0z"
fill-opacity="1"></path>
</g>
<g class="v-datashape" transform="translate(504.85526315789474,248.16)">
<path class="v-datapoint v-morphable-datapoint v-datapoint-default"
fill="#9cc677" stroke-width="2" stroke="transparent"
stroke-opacity="null" d="M-4,0 A4,4 0 1,0 4,0 A4,4 0 1,0 -4,0z"
fill-opacity="1"></path>
</g>
</g>
</g>
</g>
</g>
</g>
</g>
</g>
</g>
</svg>
</svg>
<div id="source"></div>
<script type="text/javascript">
// IE does not support outerHTML on SVGElement
if (typeof SVGElement === 'object' && !SVGElement.prototype.outerHTML) {
Object.defineProperty(SVGElement.prototype, 'outerHTML', {
get: function () {
var $node, $temp;
$temp = document.createElement('div');
$node = this.cloneNode(true);
$temp.appendChild($node);
return $temp.innerHTML;
},
enumerable: false,
configurable: true
});
}
window.onload = function () {
doRefresh();
};
var doRefresh = function () {
var makePdf = function () {
var pdf = new jsPDF('p', 'pt', 'c1');
var c = pdf.canvas;
c.width = 1000;
c.height = 500;
var ctx = c.getContext('2d');
ctx.ignoreClearRect = true;
ctx.fillStyle = '#ffffff';
ctx.fillRect(0, 0, 1000, 700);
//load a svg snippet in the canvas with id = 'drawingArea'
canvg(c, document.getElementById('svg').outerHTML, {
ignoreMouse: true,
ignoreAnimation: true,
ignoreDimensions: true
});
return pdf;
};
document.getElementById('result').setAttribute('src', makePdf().output('dataurlstring'));
document.getElementById('source').innerText = makePdf().output();
//makePdf().save();
};
</script>
</body>
</html>

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,47 @@
<!doctype html>
<!--
/**
* jsPDF Context2d PlugIn
* Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv
*
* Licensed under the MIT License.
* http://opensource.org/licenses/mit-license
*/
-->
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Context2D Paths Test</title>
</head>
<body style='background-color: silver; margin: 0;'>
<script src="../../dist/jspdf.min.js"></script>
<script src="../../examples/js/test_harness.js"></script>
<script>
var pdf = new jsPDF('p', 'pt', 'letter');
var context = pdf.context2d;
context.beginPath();
context.arc(150,150,50,0,Math.PI, false);
context.lineTo(300,300);
//context.moveTo(300,150);
//context.rect(5,5,150,150);
//context.arc(150,150,50,0,Math.PI, false);
context.stroke();
context.fillStyle = 'red';
context.fillRect(545,205,50,40);
pdf_test_harness_init(pdf);
</script>
</head>
</body>
</html>

View File

@ -0,0 +1,51 @@
.row-fluid .no-gutter {
margin-left: 0px;
}
footer {
text-align: center;
margin: 30px 0;
}
#editor {
width: 50%;
height: 400px;
float: left;
clear: left;
position: relative;
font-family: "source-code-pro";
font-size: 14px;
border: 1px solid #DDD;
border-radius: 4px;
border-bottom-right-radius: 0px;
}
.preview-pane {
border: 3px solid #ccc;
}
.controls {
float: left;
clear: left;
width: 50%;
padding-top: 10px;
}
#template {
width: 250px;
}
.tweet-buttons {
float: left;
margin-right: 40px;
padding-top: 8px;
}
.source {
font-family: "source-code-pro", Courier;
font-size: 14px;
}
.controls .alert {
float: left;
}

View File

@ -0,0 +1,30 @@
* {
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;
}
p {
margin-bottom: 1em;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 B

Some files were not shown because too many files have changed in this diff Show More