Clean up
Store/serve stylesheet locally. Remove unused function. More to come.
This commit is contained in:
parent
fc451c7cbc
commit
5d3620f687
33 changed files with 1493 additions and 2377 deletions
|
@ -1,70 +0,0 @@
|
|||
var doc = new jsPDF();//{unit: 'px'}
|
||||
|
||||
doc.setFontSize(12);
|
||||
doc.text(10, 105, 'ComboBox:');
|
||||
|
||||
var d = new ComboBox();
|
||||
d.T = "ChoiceField1";
|
||||
d.TI = 1;
|
||||
d.Rect = [50, 100, 30, 10];
|
||||
d.Opt = "[(a)(b)(c)]";
|
||||
d.V = '(b)';
|
||||
d.DV = '(b)';
|
||||
doc.addField(d);
|
||||
|
||||
doc.text(10, 115, 'ListBox:');
|
||||
var d2 = new ListBox();
|
||||
d2.edit = false;
|
||||
d2.T = "ChoiceField2";
|
||||
d2.TI = 2;
|
||||
d2.Rect = [50, 110, 30, 10];
|
||||
d2.Opt = "[(c)(a)(d)(f)(b)(s)]";
|
||||
d2.V = '(s)';
|
||||
d2.BG = [0, 1, 1];
|
||||
doc.addField(d2);
|
||||
|
||||
doc.text(10, 125, 'CheckBox:');
|
||||
var checkBox = new CheckBox();
|
||||
checkBox.T = "CheckBox1";
|
||||
checkBox.Rect = [50, 120, 30, 10];
|
||||
doc.addField(checkBox);
|
||||
|
||||
doc.text(10, 135, 'PushButton:');
|
||||
var pushButton = new PushButton();
|
||||
pushButton.T = "PushButton1";
|
||||
pushButton.Rect = [50, 130, 30, 10];
|
||||
pushButton.BG = [1, 0, 0];
|
||||
doc.addField(pushButton);
|
||||
|
||||
doc.text(10, 145, 'TextField:');
|
||||
var textField = new TextField();
|
||||
textField.Rect = [50, 140, 30, 10];
|
||||
textField.multiline = true;
|
||||
textField.V = "The quick brown fox ate the lazy mouse The quick brown fox ate the lazy mouse The quick brown fox ate the lazy mouse";//
|
||||
textField.T = "TestTextBox";
|
||||
//textField.Q = 2; // Text-Alignment
|
||||
doc.addField(textField);
|
||||
|
||||
doc.text(10, 155, 'Password:');
|
||||
var passwordField = new PasswordField();
|
||||
passwordField.Rect = [50, 150, 30, 10];
|
||||
doc.addField(passwordField);
|
||||
|
||||
doc.text(50, 165, 'RadioGroup:');
|
||||
var radioGroup = new RadioButton();
|
||||
radioGroup.V = "/Test";
|
||||
radioGroup.Subtype = "Form";
|
||||
|
||||
doc.addField(radioGroup);
|
||||
|
||||
var radioButton1 = radioGroup.createOption("Test");
|
||||
radioButton1.Rect = [50, 170, 30, 10];
|
||||
radioButton1.AS = "/Test";
|
||||
|
||||
var radioButton2 = radioGroup.createOption("Test2");
|
||||
radioButton2.Rect = [50, 180, 30, 10];
|
||||
|
||||
var radioButton3 = radioGroup.createOption("Test3");
|
||||
radioButton3.Rect = [50, 190, 20, 10];
|
||||
|
||||
radioGroup.setAppearance(AcroForm.Appearance.RadioButton.Cross);
|
File diff suppressed because one or more lines are too long
382
js/basic.js
382
js/basic.js
|
@ -1,382 +0,0 @@
|
|||
function demoTwoPageDocument() {
|
||||
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?');
|
||||
|
||||
// Save the PDF
|
||||
doc.save('Test.pdf');
|
||||
}
|
||||
|
||||
function demoLandscape() {
|
||||
var doc = new jsPDF('landscape');
|
||||
doc.text(20, 20, 'Hello landscape world!');
|
||||
|
||||
// Save the PDF
|
||||
doc.save('Test.pdf');
|
||||
}
|
||||
|
||||
function demoFontSizes() {
|
||||
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');
|
||||
}
|
||||
|
||||
function demoFontTypes() {
|
||||
var doc = new jsPDF();
|
||||
|
||||
doc.text(20, 20, 'This is the default font.');
|
||||
|
||||
doc.setFont("courier");
|
||||
doc.setFontType("normal");
|
||||
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');
|
||||
}
|
||||
|
||||
function demoTextColors() {
|
||||
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.');
|
||||
|
||||
// Output as Data URI
|
||||
doc.output('datauri');
|
||||
}
|
||||
|
||||
function demoMetadata() {
|
||||
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'
|
||||
});
|
||||
|
||||
doc.save('Test.pdf');
|
||||
}
|
||||
|
||||
function demoUserInput() {
|
||||
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 (i = 1; i <= 12; i ++) {
|
||||
doc.text(20, 30 + (i * 10), i + ' x ' + multiplier + ' = ' + (i * multiplier));
|
||||
}
|
||||
doc.save('Test.pdf');
|
||||
|
||||
}
|
||||
|
||||
function demoRectangles() {
|
||||
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');
|
||||
}
|
||||
|
||||
function demoLines() {
|
||||
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);
|
||||
|
||||
// Output as Data URI
|
||||
doc.output('datauri');
|
||||
}
|
||||
|
||||
function demoCircles() {
|
||||
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');
|
||||
}
|
||||
|
||||
function demoTriangles() {
|
||||
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('Test.pdf');
|
||||
}
|
||||
|
||||
function demoImages() {
|
||||
// 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(), data, ret = {
|
||||
data: null,
|
||||
pending: true
|
||||
};
|
||||
|
||||
img.onError = function() {
|
||||
throw new Error('Cannot load image: "'+url+'"');
|
||||
};
|
||||
img.onload = function() {
|
||||
var canvas = document.createElement('canvas');
|
||||
document.body.appendChild(canvas);
|
||||
canvas.width = img.width;
|
||||
canvas.height = img.height;
|
||||
|
||||
var ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(img, 0, 0);
|
||||
// Grab the image as a jpeg encoded in base64, but only the data
|
||||
data = canvas.toDataURL('image/jpeg').slice('data:image/jpeg;base64,'.length);
|
||||
// Convert the data to binary form
|
||||
data = atob(data);
|
||||
document.body.removeChild(canvas);
|
||||
|
||||
ret['data'] = data;
|
||||
ret['pending'] = false;
|
||||
if (typeof callback === 'function') {
|
||||
callback(data);
|
||||
}
|
||||
};
|
||||
img.src = url;
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
// Since images are loaded asyncronously, we must wait to create
|
||||
// the pdf until we actually have the image data.
|
||||
// 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();
|
||||
|
||||
doc.addImage(imgData, 'JPEG', 10, 10, 50, 50);
|
||||
doc.addImage(imgData, 'JPEG', 70, 10, 100, 120);
|
||||
|
||||
doc.save('output.pdf');
|
||||
|
||||
}
|
||||
|
||||
getImageFromUrl('thinking-monkey.jpg', createPDF);
|
||||
}
|
||||
|
||||
function demoStringSplitting() {
|
||||
|
||||
var pdf = new jsPDF('p','in','letter')
|
||||
, sizes = [12, 16, 20]
|
||||
, fonts = [['Times','Roman'],['Helvetica',''], ['Times','Italic']]
|
||||
, font, size, lines
|
||||
, margin = 0.5 // inches on a 8.5 x 11 inch sheet.
|
||||
, verticalOffset = margin
|
||||
, loremipsum = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus id eros turpis. Vivamus tempor urna vitae sapien mollis molestie. Vestibulum in lectus non enim bibendum laoreet at at libero. Etiam malesuada erat sed sem blandit in varius orci porttitor. Sed at sapien urna. Fusce augue ipsum, molestie et adipiscing at, varius quis enim. Morbi sed magna est, vel vestibulum urna. Sed tempor ipsum vel mi pretium at elementum urna tempor. Nulla faucibus consectetur felis, elementum venenatis mi mollis gravida. Aliquam mi ante, accumsan eu tempus vitae, viverra quis justo.\n\nProin feugiat augue in augue rhoncus eu cursus tellus laoreet. Pellentesque eu sapien at diam porttitor venenatis nec vitae velit. Donec ultrices volutpat lectus eget vehicula. Nam eu erat mi, in pulvinar eros. Mauris viverra porta orci, et vehicula lectus sagittis id. Nullam at magna vitae nunc fringilla posuere. Duis volutpat malesuada ornare. Nulla in eros metus. Vivamus a posuere libero.'
|
||||
|
||||
// Margins:
|
||||
pdf.setDrawColor(0, 255, 0)
|
||||
.setLineWidth(1/72)
|
||||
.line(margin, margin, margin, 11 - margin)
|
||||
.line(8.5 - margin, margin, 8.5-margin, 11-margin)
|
||||
|
||||
// the 3 blocks of text
|
||||
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.
|
||||
console.log(lines);
|
||||
pdf.text(0.5, verticalOffset + size / 72, lines)
|
||||
|
||||
verticalOffset += (lines.length + 0.5) * size / 72
|
||||
}
|
||||
}
|
||||
|
||||
pdf.save('Test.pdf');
|
||||
}
|
||||
|
||||
function demoFromHTML() {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
)
|
||||
}
|
||||
|
||||
function demoTextAlign() {
|
||||
var pdf = new jsPDF('p', 'pt', 'letter');
|
||||
|
||||
pdf.setFillColor(0);
|
||||
pdf.circle( 140, 50, 2, "F" );
|
||||
pdf.text( 'This text is normally\raligned.', 140, 50 );
|
||||
|
||||
pdf.circle( 140, 120, 2, "F" );
|
||||
pdf.text( 'This text is centered\raround\rthis point.', 140, 120, 'center' );
|
||||
|
||||
pdf.circle( 140, 300, 2, "F" );
|
||||
pdf.text( 'This text is rotated\rand centered around\rthis point.', 140, 300, 45, 'center' );
|
||||
|
||||
pdf.circle( 140, 400, 2, "F" );
|
||||
pdf.text( 'This text is\raligned to the\rright.', 140, 400, 'right' );
|
||||
|
||||
pdf.circle( 140, 550, 2, "F" );
|
||||
pdf.text( 'This text is\raligned to the\rright.', 140, 550, 45, 'right' );
|
||||
|
||||
pdf.circle( 460, 50, 2, "F" );
|
||||
pdf.text( 'This single line is centered', 460, 50, 'center' );
|
||||
|
||||
pdf.circle( 460, 200, 2, "F" );
|
||||
pdf.text( 'This right aligned text\r\rhas an empty line.', 460, 200, 'right' );
|
||||
|
||||
|
||||
pdf.save('Test.pdf');
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
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');
|
180
js/editor.js
180
js/editor.js
File diff suppressed because one or more lines are too long
|
@ -1,30 +0,0 @@
|
|||
var doc = new jsPDF();
|
||||
|
||||
doc.text(20, 20, 'This is the default font.');
|
||||
|
||||
doc.setFont("courier");
|
||||
doc.setFontType("normal");
|
||||
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.setFont("times");
|
||||
doc.setFontType("normal");
|
||||
doc.text(105, 80, 'This is centred text.', null, null, 'center');
|
||||
doc.text(105, 90, 'And a little bit more underneath it.', null, null, 'center');
|
||||
doc.text(200, 100, 'This is right aligned text', null, null, 'right');
|
||||
doc.text(200, 110, 'And some more', null, null, 'right');
|
||||
doc.text(20, 120, 'Back to left');
|
||||
|
||||
doc.text(20, 140, '10 degrees rotated', null, 10);
|
||||
doc.text(20, 160, '-10 degrees rotated', null, -10);
|
|
@ -1,6 +0,0 @@
|
|||
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.');
|
|
@ -1,15 +0,0 @@
|
|||
var doc = new jsPDF();
|
||||
|
||||
// We'll make our own renderer to skip this editor
|
||||
var specialElementHandlers = {
|
||||
'#editor': function(element, renderer){
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
// All units are in the set measurement for the document
|
||||
// This can be changed to "pt" (points), "mm" (Default), "cm", "in"
|
||||
doc.fromHTML($('body').get(0), 15, 15, {
|
||||
'width': 170,
|
||||
'elementHandlers': specialElementHandlers
|
||||
});
|
|
@ -1,7 +0,0 @@
|
|||
|
||||
var pdf = new jsPDF('p','pt','a4');
|
||||
|
||||
pdf.addHTML(document.body,function() {
|
||||
var string = pdf.output('datauristring');
|
||||
$('.preview-pane').attr('src', string);
|
||||
});
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
4
js/jquery/jquery-1.7.1.min.js
vendored
4
js/jquery/jquery-1.7.1.min.js
vendored
File diff suppressed because one or more lines are too long
356
js/jquery/jquery-ui-1.8.17.custom.min.js
vendored
356
js/jquery/jquery-ui-1.8.17.custom.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -1,3 +0,0 @@
|
|||
|
||||
// Kitchen Sink Example
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
var doc = new jsPDF('landscape');
|
||||
doc.text(20, 20, 'Hello landscape world!');
|
26
js/lines.js
26
js/lines.js
|
@ -1,26 +0,0 @@
|
|||
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);
|
72966
js/pdfmake.js
Normal file
72966
js/pdfmake.js
Normal file
File diff suppressed because one or more lines are too long
25
js/pdfmake.min.js
vendored
Normal file
25
js/pdfmake.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
js/pdfmake.min.js.map
Normal file
1
js/pdfmake.min.js.map
Normal file
File diff suppressed because one or more lines are too long
|
@ -1,30 +0,0 @@
|
|||
var doc = new jsPDF();
|
||||
|
||||
// Empty square
|
||||
doc.rect(20, 20, 10, 10);
|
||||
|
||||
// Filled square
|
||||
doc.rect(40, 20, 10, 10, 'F');
|
||||
|
||||
// Empty red square
|
||||
doc.setDrawColor(255,0,0);
|
||||
doc.rect(60, 20, 10, 10);
|
||||
|
||||
// Filled square with red borders
|
||||
doc.setDrawColor(255,0,0);
|
||||
doc.rect(80, 20, 10, 10, 'FD');
|
||||
|
||||
// Filled red square
|
||||
doc.setDrawColor(0);
|
||||
doc.setFillColor(255,0,0);
|
||||
doc.rect(100, 20, 10, 10, 'F');
|
||||
|
||||
// Filled red square with black borders
|
||||
doc.setDrawColor(0);
|
||||
doc.setFillColor(255,0,0);
|
||||
doc.rect(120, 20, 10, 10, 'FD');
|
||||
|
||||
// Black square with rounded corners
|
||||
doc.setDrawColor(0);
|
||||
doc.setFillColor(255, 255, 255);
|
||||
doc.roundedRect(140, 20, 10, 10, 3, 3, 'FD');
|
|
@ -1,40 +0,0 @@
|
|||
// @TODO: Need to simplify this demo
|
||||
|
||||
var doc = new jsPDF('p','in','letter')
|
||||
, sizes = [12, 16, 20]
|
||||
, fonts = [['Times','Roman'],['Helvetica',''], ['Times','Italic']]
|
||||
, font, size, lines
|
||||
, margin = 0.5 // inches on a 8.5 x 11 inch sheet.
|
||||
, verticalOffset = margin
|
||||
, loremipsum = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus id eros turpis. Vivamus tempor urna vitae sapien mollis molestie. Vestibulum in lectus non enim bibendum laoreet at at libero. Etiam malesuada erat sed sem blandit in varius orci porttitor. Sed at sapien urna. Fusce augue ipsum, molestie et adipiscing at, varius quis enim. Morbi sed magna est, vel vestibulum urna. Sed tempor ipsum vel mi pretium at elementum urna tempor. Nulla faucibus consectetur felis, elementum venenatis mi mollis gravida. Aliquam mi ante, accumsan eu tempus vitae, viverra quis justo.\n\nProin feugiat augue in augue rhoncus eu cursus tellus laoreet. Pellentesque eu sapien at diam porttitor venenatis nec vitae velit. Donec ultrices volutpat lectus eget vehicula. Nam eu erat mi, in pulvinar eros. Mauris viverra porta orci, et vehicula lectus sagittis id. Nullam at magna vitae nunc fringilla posuere. Duis volutpat malesuada ornare. Nulla in eros metus. Vivamus a posuere libero.'
|
||||
|
||||
// Margins:
|
||||
doc.setDrawColor(0, 255, 0)
|
||||
.setLineWidth(1/72)
|
||||
.line(margin, margin, margin, 11 - margin)
|
||||
.line(8.5 - margin, margin, 8.5-margin, 11-margin)
|
||||
|
||||
// the 3 blocks of text
|
||||
for (var i in fonts){
|
||||
if (fonts.hasOwnProperty(i)) {
|
||||
font = fonts[i]
|
||||
size = sizes[i]
|
||||
|
||||
lines = doc.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.
|
||||
doc.text(0.5, verticalOffset + size / 72, lines)
|
||||
|
||||
verticalOffset += (lines.length + 0.5) * size / 72
|
||||
}
|
||||
}
|
|
@ -1,161 +0,0 @@
|
|||
/**
|
||||
* 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 += "<p style='text-align:center;font-style:italic;font-size:.8em'>click to close</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 = {
|
||||
"&" : "&",
|
||||
"<" : "<",
|
||||
">" : ">",
|
||||
'"' : '"',
|
||||
"'" : ''',
|
||||
"/" : '/'
|
||||
};
|
||||
|
||||
this.escapeHtml = function(string) {
|
||||
return String(string).replace(/[&<>"'\/]/g, function(s) {
|
||||
return this.entityMap[s];
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
this.getParameterByName = function(name) {
|
||||
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
|
||||
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), 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';
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
var doc = new jsPDF();
|
||||
|
||||
// I know the proper spelling is colour ;)
|
||||
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.');
|
File diff suppressed because one or more lines are too long
|
@ -1,8 +0,0 @@
|
|||
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');
|
|
@ -1,5 +0,0 @@
|
|||
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('a6','l');
|
||||
doc.text(20, 20, 'Do you like that?');
|
|
@ -1,27 +0,0 @@
|
|||
var name = prompt('What is your name?');
|
||||
var multiplier = parseInt(prompt('Enter a number:'));
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
// You wouldn't normally call this - this is just to make the
|
||||
// demo not look broken as we've disabled auto update.
|
||||
if (jsPDFEditor !== undefined) {
|
||||
jsPDFEditor.update(true);
|
||||
}
|
7
js/vfs_fonts.js
Normal file
7
js/vfs_fonts.js
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue