Comparing version 0.0.5 to 0.0.6
{ | ||
"name": "pdfmake", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"homepage": "https://bpampuch.github.io/pdfmake", | ||
@@ -5,0 +5,0 @@ "authors": [ |
{ | ||
"name": "pdfmake", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Client/server side PDF printing in pure JavaScript", | ||
@@ -5,0 +5,0 @@ "main": "src/printer.js", |
@@ -1,4 +0,19 @@ | ||
pdfmake | ||
pdfmake [![Build Status](https://travis-ci.org/bpampuch/pdfmake.png?branch=master)](https://travis-ci.org/bpampuch/pdfmake) [![NPM version](https://badge.fury.io/js/pdfmake.png)](http://badge.fury.io/js/pdfmake) [![Bower version](https://badge.fury.io/bo/pdfmake.png)](http://badge.fury.io/bo/pdfmake) | ||
======= | ||
Client/server side PDF printing in pure JavaScript | ||
Check out [the playground](http://bpampuch.github.io/pdfmake/playground.html) | ||
Docs + getting started will appear soon. | ||
## currently working on | ||
* tables - column spans | ||
* tables - row spans | ||
* tables - vertical lines | ||
* tables - vertical alignment | ||
* headers/footers | ||
* page numbering | ||
* images |
@@ -119,3 +119,3 @@ /* jslint node: true */ | ||
/****TESTS**** (remove first '/' to comment) | ||
/****TESTS**** (add a leading '/' to uncomment) | ||
DocumentContext.bottomMostContext = bottomMostContext; | ||
@@ -122,0 +122,0 @@ // */ |
@@ -6,2 +6,3 @@ /* jslint node: true */ | ||
var PdfKit = require('pdfkit'); | ||
var sizes = require('./standardPageSizes'); | ||
@@ -71,4 +72,6 @@ //////////////////////////////////////// | ||
*/ | ||
PdfPrinter.prototype.createPdfKitDocument = function(docDefinition) { | ||
var pageSize = docDefinition.pageSize || { width: 595.28, height: 841.89 }; | ||
PdfPrinter.prototype.createPdfKitDocument = function(docDefinition, options) { | ||
options = options || {}; | ||
var pageSize = pageSize2widthAndHeight(docDefinition.pageSize || 'a4'); | ||
this.pdfKitDoc = new PdfKit({ size: [ pageSize.width, pageSize.height ]}); | ||
@@ -86,5 +89,34 @@ this.pdfKitDoc.info.Producer = 'pdfmake'; | ||
renderPages(pages, this.fontProvider, this.pdfKitDoc); | ||
if(options.autoPrint){ | ||
var PDFReference = this.pdfKitDoc.store.objects[2].constructor; | ||
var jsRef = this.pdfKitDoc.ref({ | ||
S: 'JavaScript', | ||
JS: new StringObject('this.print\\(true\\);') | ||
}); | ||
var namesRef = this.pdfKitDoc.ref({ | ||
Names: [new StringObject('EmbeddedJS'), new PDFReference(jsRef.id)], | ||
}); | ||
this.pdfKitDoc.store.objects[2].data.Names = { JavaScript: new PDFReference(namesRef.id) }; | ||
} | ||
return this.pdfKitDoc; | ||
}; | ||
function pageSize2widthAndHeight(pageSize) { | ||
if (typeof pageSize == 'string' || pageSize instanceof String) { | ||
var size = sizes[pageSize.toUpperCase()]; | ||
if (!size) throw ('Page size ' + pageSize + ' not recognized'); | ||
return { width: size[0], height: size[1] }; | ||
} | ||
return pageSize; | ||
} | ||
function StringObject(str){ | ||
this.isString = true; | ||
this.toString = function(){ | ||
return str; | ||
}; | ||
} | ||
function renderPages(pages, fontProvider, pdfKitDoc) { | ||
@@ -91,0 +123,0 @@ for(var i = 0, l = pages.length; i < l; i++) { |
@@ -69,2 +69,4 @@ /* jslint node: true */ | ||
TextTools.prototype.sizeOfString = function(text, styleContextStack) { | ||
text = text.replace('\t', ' '); | ||
//TODO: refactor - extract from measure | ||
@@ -89,2 +91,3 @@ var fontName = getStyleProperty({}, styleContextStack, 'font', 'Roboto'); | ||
var results = []; | ||
text = text.replace('\t', ' '); | ||
@@ -240,3 +243,3 @@ var array = text.match(WORD_RE); | ||
/****TESTS**** (remove first '/' to comment) | ||
/****TESTS**** (add a leading '/' to uncomment) | ||
TextTools.prototype.splitWords = splitWords; | ||
@@ -243,0 +246,0 @@ TextTools.prototype.normalizeTextArray = normalizeTextArray; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
632196
26
1813
20