New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

pdfmake

Package Overview
Dependencies
Maintainers
4
Versions
103
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pdfmake - npm Package Compare versions

Comparing version 0.1.25 to 0.1.26

8

gulpfile.js

@@ -12,5 +12,8 @@ var gulp = require('gulp');

var fc2json = require('gulp-file-contents-to-json');
var header = require('gulp-header');
var DEBUG = process.env.NODE_ENV === 'debug',
CI = process.env.CI === 'true';
var banner = '/*! <%= pkg.name %> v<%= pkg.version %>, @license <%= pkg.license %>, @link <%= pkg.homepage %> */\n';
var uglifyOptions = {

@@ -26,10 +29,13 @@ compress: {

gulp.task('default', [/*'lint',*/ 'test', 'build']);
gulp.task('default', [/*'lint',*/ 'test', 'build', 'buildFonts']);
gulp.task('build', function () {
var pkg = require('./package.json');
return gulp.src('src/browser-extensions/pdfMake.js')
.pipe(webpack(require('./webpack.config.js'), null, reportWebPackErrors))
.pipe(replace(/\/[*/][@#]\s+sourceMappingURL=((?:(?!\s+\*\/).)*).*\n/g, ''))
.pipe(header(banner, {pkg: pkg}))
.pipe(gulp.dest('build'))
.pipe(sourcemaps.init())
.pipe(uglify(uglifyOptions))
.pipe(header(banner, {pkg: pkg}))
.pipe(rename({extname: '.min.js'}))

@@ -36,0 +42,0 @@ .pipe(sourcemaps.write('./'))

13

package.json
{
"name": "pdfmake",
"version": "0.1.25",
"version": "0.1.26",
"description": "Client/server side PDF printing in pure JavaScript",

@@ -15,3 +15,3 @@ "main": "src/printer.js",

"devDependencies": {
"expose-loader": "^0.7.1",
"expose-loader": "^0.7.3",
"gulp": "^3.9.1",

@@ -21,8 +21,9 @@ "gulp-jshint": "^2.0.4",

"gulp-replace": "^0.5.4",
"gulp-sourcemaps": "^1.9.1",
"gulp-sourcemaps": "^2.4.1",
"gulp-spawn-mocha": "^3.1.0",
"gulp-uglify": "^2.0.1",
"gulp-util": "^3.0.8",
"gulp-each": "^0.2.0",
"gulp-each": "^0.5.0",
"gulp-file-contents-to-json": "^0.2.1",
"gulp-header": "^1.8.8",
"iconv-lite":"^0.4.15",

@@ -34,5 +35,5 @@ "json-loader": "^0.5.4",

"string-replace-webpack-plugin": "^0.0.5",
"transform-loader": "^0.2.3",
"transform-loader": "^0.2.4",
"brfs": "^1.4.3",
"webpack": "^1.14.0",
"webpack": "^2.2.1",
"webpack-stream": "^3.2.0"

@@ -39,0 +40,0 @@ },

@@ -1,4 +0,22 @@

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) [![Latest Version](https://img.shields.io/packagist/v/bpampuch/pdfmake.svg)](https://packagist.org/packages/bpampuch/pdfmake)
=======
# pdfmake [![Build Status][travis_img]][travis_url] [![GitHub][github_img]][github_url] [![npm][npm_img]][npm_url] [![Bower][bower_img]][bower_url] [![Packagist][packagist_img]][packagist_url] [![CDNJS][cdnjs_img]][cndjs_url]
[travis_img]: https://travis-ci.org/bpampuch/pdfmake.png?branch=master
[travis_url]: https://travis-ci.org/bpampuch/pdfmake
[github_img]: https://img.shields.io/github/release/bpampuch/pdfmake.svg
[github_url]: https://github.com/bpampuch/pdfmake/releases/latest
[npm_img]: https://img.shields.io/npm/v/pdfmake.svg?colorB=0E7FBF
[npm_url]: https://www.npmjs.com/package/pdfmake
[bower_img]: https://img.shields.io/bower/v/pdfmake.svg?colorB=0E7FBF
[bower_url]: https://github.com/bpampuch/pdfmake
[packagist_img]: https://img.shields.io/packagist/v/bpampuch/pdfmake.svg?colorB=0E7FBF
[packagist_url]: https://packagist.org/packages/bpampuch/pdfmake
[cdnjs_img]: https://img.shields.io/cdnjs/v/pdfmake.svg?colorB=0E7FBF
[cndjs_url]: https://cdnjs.com/libraries/pdfmake
Client/server side PDF printing in pure JavaScript

@@ -5,0 +23,0 @@

@@ -61,3 +61,3 @@ /* jslint node: true */

if (!cb) {
throw 'getBuffer is an async method and needs a callback argument';
throw '_getPages is an async method and needs a callback argument';
}

@@ -99,13 +99,10 @@ this._createDoc(options, function (ignoreBuffer, pages) {

Document.prototype.open = function () {
Document.prototype._openPdf = function (options) {
var win = this._openWindow();
try {
var that = this;
this.getBuffer(function (result) {
var blob = that._bufferToBlob(result);
this.getBlob(function (result) {
var urlCreator = window.URL || window.webkitURL;
var pdfUrl = urlCreator.createObjectURL(blob);
var pdfUrl = urlCreator.createObjectURL(result);
win.location.href = pdfUrl;
}, {autoPrint: false});
}, options);
} catch (e) {

@@ -117,21 +114,18 @@ win.close();

Document.prototype.open = function (options) {
options = options || {};
options.autoPrint = false;
Document.prototype.print = function () {
var win = this._openWindow();
this._openPdf(options);
};
try {
var that = this;
this.getBuffer(function (result) {
var blob = that._bufferToBlob(result);
var urlCreator = window.URL || window.webkitURL;
var pdfUrl = urlCreator.createObjectURL(blob);
win.location.href = pdfUrl;
}, {autoPrint: true});
} catch (e) {
win.close();
throw e;
}
Document.prototype.print = function (options) {
options = options || {};
options.autoPrint = true;
this._openPdf(options);
};
Document.prototype.download = function (defaultFileName, cb) {
Document.prototype.download = function (defaultFileName, cb, options) {
if (typeof defaultFileName === 'function') {

@@ -143,6 +137,4 @@ cb = defaultFileName;

defaultFileName = defaultFileName || 'file.pdf';
var that = this;
this.getBuffer(function (result) {
var blob = that._bufferToBlob(result);
saveAs(blob, defaultFileName);
this.getBlob(function (result) {
saveAs(result, defaultFileName);

@@ -152,3 +144,3 @@ if (typeof cb === 'function') {

}
});
}, options);
};

@@ -174,2 +166,13 @@

Document.prototype.getBlob = function (cb, options) {
if (!cb) {
throw 'getBlob is an async method and needs a callback argument';
}
var that = this;
this.getBuffer(function (result) {
var blob = that._bufferToBlob(result);
cb(blob);
}, options);
};
Document.prototype.getBuffer = function (cb, options) {

@@ -176,0 +179,0 @@ if (!cb) {

@@ -62,5 +62,5 @@ /* jslint node: true */

} else if (node.ul) {
return extendMargins(self.measureList(false, node));
return extendMargins(self.measureUnorderedList(node));
} else if (node.ol) {
return extendMargins(self.measureList(true, node));
return extendMargins(self.measureOrderedList(node));
} else if (node.table) {

@@ -220,20 +220,41 @@ return extendMargins(self.measureTable(node));

DocMeasure.prototype.gapSizeForList = function (isOrderedList, listItems) {
if (isOrderedList) {
var longestNo = (listItems.length).toString().replace(/./g, '9');
return this.textTools.sizeOfString(longestNo + '. ', this.styleStack);
} else {
return this.textTools.sizeOfString('9. ', this.styleStack);
}
DocMeasure.prototype.gapSizeForList = function () {
return this.textTools.sizeOfString('9. ', this.styleStack);
};
DocMeasure.prototype.buildMarker = function (isOrderedList, counter, styleStack, gapSize) {
var marker;
DocMeasure.prototype.buildUnorderedMarker = function (styleStack, gapSize, type) {
function buildDisc(gapSize, color) {
// TODO: ascender-based calculations
var radius = gapSize.fontSize / 6;
return {
canvas: [{
x: radius,
y: (gapSize.height / gapSize.lineHeight) + gapSize.descender - gapSize.fontSize / 3,
r1: radius,
r2: radius,
type: 'ellipse',
color: color
}]
};
}
if (isOrderedList) {
marker = {_inlines: this.textTools.buildInlines(counter, styleStack).items};
} else {
function buildSquare(gapSize, color) {
// TODO: ascender-based calculations
var size = gapSize.fontSize / 3;
return {
canvas: [{
x: 0,
y: (gapSize.height / gapSize.lineHeight) + gapSize.descender - (gapSize.fontSize / 3) - (size / 2),
h: size,
w: size,
type: 'rect',
color: color
}]
};
}
function buildCircle(gapSize, color) {
// TODO: ascender-based calculations
var radius = gapSize.fontSize / 6;
marker = {
return {
canvas: [{

@@ -245,3 +266,3 @@ x: radius,

type: 'ellipse',
color: 'black'
lineColor: color
}]

@@ -251,2 +272,24 @@ };

var marker;
var color = styleStack.getProperty('markerColor') || styleStack.getProperty('color') || 'black';
switch (type) {
case 'circle':
marker = buildCircle(gapSize, color);
break;
case 'square':
marker = buildSquare(gapSize, color);
break;
case 'none':
marker = {};
break;
case 'disc':
default:
marker = buildDisc(gapSize, color);
break;
}
marker._minWidth = marker._maxWidth = gapSize.width;

@@ -258,21 +301,105 @@ marker._minHeight = marker._maxHeight = gapSize.height;

DocMeasure.prototype.measureList = function (isOrdered, node) {
DocMeasure.prototype.buildOrderedMarker = function (counter, styleStack, type, separator) {
function prepareAlpha(counter) {
function toAlpha(num) {
return (num >= 26 ? toAlpha((num / 26 >> 0) - 1) : '') + 'abcdefghijklmnopqrstuvwxyz'[num % 26 >> 0];
}
if (counter < 1) {
return counter.toString();
}
return toAlpha(counter - 1);
}
function prepareRoman(counter) {
if (counter < 1 || counter > 4999) {
return counter.toString();
}
var num = counter;
var lookup = {M: 1000, CM: 900, D: 500, CD: 400, C: 100, XC: 90, L: 50, XL: 40, X: 10, IX: 9, V: 5, IV: 4, I: 1}, roman = '', i;
for (i in lookup) {
while (num >= lookup[i]) {
roman += i;
num -= lookup[i];
}
}
return roman;
}
function prepareDecimal(counter) {
return counter.toString();
}
var counterText;
switch (type) {
case 'none':
counterText = null;
break;
case 'upper-alpha':
counterText = prepareAlpha(counter).toUpperCase();
break;
case 'lower-alpha':
counterText = prepareAlpha(counter);
break;
case 'upper-roman':
counterText = prepareRoman(counter);
break;
case 'lower-roman':
counterText = prepareRoman(counter).toLowerCase();
break;
case 'decimal':
default:
counterText = prepareDecimal(counter);
break;
}
if (counterText === null) {
return {};
}
if (separator) {
if (Array.isArray(separator)) {
if (separator[0]) {
counterText = separator[0] + counterText;
}
if (separator[1]) {
counterText += separator[1];
}
counterText += ' ';
} else {
counterText += separator + ' ';
}
}
var textArray = {text: counterText};
var markerColor = styleStack.getProperty('markerColor');
if (markerColor) {
textArray.color = markerColor;
}
return {_inlines: this.textTools.buildInlines(textArray, styleStack).items};
};
DocMeasure.prototype.measureUnorderedList = function (node) {
var style = this.styleStack.clone();
var items = isOrdered ? node.ol : node.ul;
node._gapSize = this.gapSizeForList(isOrdered, items);
var items = node.ul;
node.type = node.type || 'disc';
node._gapSize = this.gapSizeForList();
node._minWidth = 0;
node._maxWidth = 0;
var counter = 1;
for (var i = 0, l = items.length; i < l; i++) {
var nextItem = items[i] = this.measureNode(items[i]);
var item = items[i] = this.measureNode(items[i]);
var marker = counter++ + '. ';
if (!item.ol && !item.ul) {
item.listMarker = this.buildUnorderedMarker(style, node._gapSize, node.type);
}
if (!nextItem.ol && !nextItem.ul) {
nextItem.listMarker = this.buildMarker(isOrdered, nextItem.counter || marker, style, node._gapSize);
} // TODO: else - nested lists numbering
node._minWidth = Math.max(node._minWidth, items[i]._minWidth + node._gapSize.width);

@@ -285,2 +412,49 @@ node._maxWidth = Math.max(node._maxWidth, items[i]._maxWidth + node._gapSize.width);

DocMeasure.prototype.measureOrderedList = function (node) {
var style = this.styleStack.clone();
var items = node.ol;
node.type = node.type || 'decimal';
node.separator = node.separator || '.';
node.reversed = node.reversed || false;
if (!node.start) {
node.start = node.reversed ? items.length : 1;
}
node._gapSize = this.gapSizeForList();
node._minWidth = 0;
node._maxWidth = 0;
var counter = node.start;
for (var i = 0, l = items.length; i < l; i++) {
var item = items[i] = this.measureNode(items[i]);
if (!item.ol && !item.ul) {
item.listMarker = this.buildOrderedMarker(item.counter || counter, style, node.type, node.separator);
if (item.listMarker._inlines) {
node._gapSize.width = Math.max(node._gapSize.width, item.listMarker._inlines[0].width);
}
} // TODO: else - nested lists numbering
node._minWidth = Math.max(node._minWidth, items[i]._minWidth);
node._maxWidth = Math.max(node._maxWidth, items[i]._maxWidth);
if (node.reversed) {
counter--;
} else {
counter++;
}
}
node._minWidth += node._gapSize.width;
node._maxWidth += node._gapSize.width;
for (var i = 0, l = items.length; i < l; i++) {
var item = items[i];
if (!item.ol && !item.ul) {
item.listMarker._minWidth = item.listMarker._maxWidth = node._gapSize.width;
}
}
return node;
};
DocMeasure.prototype.measureColumns = function (node) {

@@ -287,0 +461,0 @@ var columns = node.columns;

@@ -202,5 +202,11 @@ /* jslint node: true */

if (createNewPage) {
var currentAvailableWidth = this.availableWidth;
var currentPageOrientation = this.getCurrentPage().pageSize.orientation;
var pageSize = getPageSize(this.getCurrentPage(), pageOrientation);
this.addPage(pageSize);
this.pageSnapshot().availableWidth = pageSize.width - this.x - this.pageMargins.right;
if (currentPageOrientation === pageSize.orientation) {
this.availableWidth = currentAvailableWidth;
}
} else {

@@ -207,0 +213,0 @@ this.page = nextPageIndex;

@@ -20,5 +20,5 @@ /* jslint node: true */

function FontProvider(fontDescriptors, pdfDoc) {
function FontProvider(fontDescriptors, pdfKitDoc) {
this.fonts = {};
this.pdfDoc = pdfDoc;
this.pdfKitDoc = pdfKitDoc;
this.fontCache = {};

@@ -53,3 +53,3 @@

}
this.fontCache[familyName][type] = this.pdfDoc.font.apply(this.pdfDoc, def)._font;
this.fontCache[familyName][type] = this.pdfKitDoc.font.apply(this.pdfKitDoc, def)._font;
}

@@ -56,0 +56,0 @@

@@ -6,4 +6,4 @@ /* jslint node: true */

function ImageMeasure(pdfDoc, imageDictionary) {
this.pdfDoc = pdfDoc;
function ImageMeasure(pdfKitDoc, imageDictionary) {
this.pdfKitDoc = pdfKitDoc;
this.imageDictionary = imageDictionary || {};

@@ -16,4 +16,4 @@ }

if (!this.pdfDoc._imageRegistry[src]) {
label = 'I' + (++this.pdfDoc._imageCount);
if (!this.pdfKitDoc._imageRegistry[src]) {
label = 'I' + (++this.pdfKitDoc._imageCount);
try {

@@ -27,6 +27,6 @@ image = PDFImage.open(realImageSrc(src), label);

}
image.embed(this.pdfDoc);
this.pdfDoc._imageRegistry[src] = image;
image.embed(this.pdfKitDoc);
this.pdfKitDoc._imageRegistry[src] = image;
} else {
image = this.pdfDoc._imageRegistry[src];
image = this.pdfKitDoc._imageRegistry[src];
}

@@ -33,0 +33,0 @@

@@ -529,3 +529,3 @@ /* jslint node: true */

self.writer.addVector(vector);
} else {
} else if (marker._inlines) {
var markerLine = new Line(self.pageSize.width);

@@ -532,0 +532,0 @@ markerLine.addInline(marker._inlines[0]);

@@ -74,6 +74,6 @@ /* jslint node: true */

*
* var pdfDoc = printer.createPdfKitDocument(docDefinition);
* var pdfKitDoc = printer.createPdfKitDocument(docDefinition);
*
* pdfDoc.pipe(fs.createWriteStream('sample.pdf'));
* pdfDoc.end();
* pdfKitDoc.pipe(fs.createWriteStream('sample.pdf'));
* pdfKitDoc.end();
*

@@ -85,30 +85,7 @@ * @return {Object} a pdfKit document object which can be saved or encode to data-url

// if pageSize.height is set to auto, set the height to infinity so there are no page breaks.
if (docDefinition.pageSize && docDefinition.pageSize.height === 'auto') {
docDefinition.pageSize.height = Infinity;
}
var pageSize = fixPageSize(docDefinition.pageSize, docDefinition.pageOrientation);
var pageSize = pageSize2widthAndHeight(docDefinition.pageSize || 'a4');
if (docDefinition.pageOrientation === 'landscape') {
pageSize = {width: pageSize.height, height: pageSize.width};
}
pageSize.orientation = docDefinition.pageOrientation === 'landscape' ? docDefinition.pageOrientation : 'portrait';
this.pdfKitDoc = new PdfKit({size: [pageSize.width, pageSize.height], autoFirstPage: false, compress: docDefinition.compress || true});
this.pdfKitDoc.info.Producer = 'pdfmake';
this.pdfKitDoc.info.Creator = 'pdfmake';
setMetadata(docDefinition, this.pdfKitDoc);
// pdf kit maintains the uppercase fieldnames from pdf spec
// to keep the pdfmake api consistent, the info field are defined lowercase
if (docDefinition.info) {
var info = docDefinition.info;
// check for falsey an set null, so that pdfkit always get either null or value
this.pdfKitDoc.info.Title = info.title ? info.title : null;
this.pdfKitDoc.info.Author = info.author ? info.author : null;
this.pdfKitDoc.info.Subject = info.subject ? info.subject : null;
this.pdfKitDoc.info.Keywords = info.keywords ? info.keywords : null;
this.pdfKitDoc.info.CreationDate = info.creationDate ? info.creationDate : null;
}
this.fontProvider = new FontProvider(this.fontDescriptors, this.pdfKitDoc);

@@ -118,6 +95,3 @@

var builder = new LayoutBuilder(
pageSize,
fixPageMargins(docDefinition.pageMargins || 40),
new ImageMeasure(this.pdfKitDoc, docDefinition.images));
var builder = new LayoutBuilder(pageSize, fixPageMargins(docDefinition.pageMargins || 40), new ImageMeasure(this.pdfKitDoc, docDefinition.images));

@@ -142,3 +116,3 @@ registerDefaultTableLayouts(builder);

renderPages(pages, this.fontProvider, this.pdfKitDoc);
renderPages(pages, this.fontProvider, this.pdfKitDoc, options.progressCallback);

@@ -157,3 +131,31 @@ if (options.autoPrint) {

function setMetadata(docDefinition, pdfKitDoc) {
pdfKitDoc.info.Producer = 'pdfmake';
pdfKitDoc.info.Creator = 'pdfmake';
// pdf kit maintains the uppercase fieldnames from pdf spec
// to keep the pdfmake api consistent, the info field are defined lowercase
if (docDefinition.info) {
var info = docDefinition.info;
// check for falsey an set null, so that pdfkit always get either null or value
pdfKitDoc.info.Title = info.title ? info.title : null;
pdfKitDoc.info.Author = info.author ? info.author : null;
pdfKitDoc.info.Subject = info.subject ? info.subject : null;
pdfKitDoc.info.Keywords = info.keywords ? info.keywords : null;
pdfKitDoc.info.CreationDate = info.creationDate ? info.creationDate : null;
}
}
function calculatePageHeight(pages, margins) {
function getItemHeight(item) {
if (typeof item.item.getHeight === 'function') {
return item.item.getHeight();
} else if (item.item._height) {
return item.item._height;
} else {
// TODO: add support for next item types
return 0;
}
}
var fixedMargins = fixPageMargins(margins || 40);

@@ -163,3 +165,3 @@ var height = fixedMargins.top + fixedMargins.bottom;

page.items.forEach(function (item) {
height += item.item.getHeight();
height += getItemHeight(item);
});

@@ -170,2 +172,17 @@ });

function fixPageSize(pageSize, pageOrientation) {
// if pageSize.height is set to auto, set the height to infinity so there are no page breaks.
if (pageSize && pageSize.height === 'auto') {
pageSize.height = Infinity;
}
var size = pageSize2widthAndHeight(pageSize || 'A4');
if (((pageOrientation === 'portrait') && (size.width > size.height)) ||
((pageOrientation === 'landscape') && (size.width < size.height))) { // swap page sizes
size = {width: size.height, height: size.width};
}
size.orientation = size.width > size.height ? 'landscape' : 'portrait';
return size;
}
function fixPageMargins(margin) {

@@ -183,4 +200,5 @@ if (!margin) {

margin = {left: margin[0], top: margin[1], right: margin[2], bottom: margin[3]};
} else
} else {
throw 'Invalid pageMargins definition';
}
}

@@ -252,3 +270,3 @@

if (!size) {
throw ('Page size ' + pageSize + ' not recognized');
throw 'Page size ' + pageSize + ' not recognized';
}

@@ -271,5 +289,12 @@ return {width: size[0], height: size[1]};

function renderPages(pages, fontProvider, pdfKitDoc) {
function renderPages(pages, fontProvider, pdfKitDoc, progressCallback) {
pdfKitDoc._pdfMakePages = pages;
pdfKitDoc.addPage();
var totalItems = progressCallback && _.sumBy(pages, function (page) {
return page.items.length;
});
var renderedItems = 0;
progressCallback = progressCallback || function () {};
for (var i = 0; i < pages.length; i++) {

@@ -295,2 +320,4 @@ if (i > 0) {

}
renderedItems++;
progressCallback(renderedItems / totalItems);
}

@@ -354,13 +381,13 @@ if (page.watermark) {

function renderVector(vector, pdfDoc) {
function renderVector(vector, pdfKitDoc) {
//TODO: pdf optimization (there's no need to write all properties everytime)
pdfDoc.lineWidth(vector.lineWidth || 1);
pdfKitDoc.lineWidth(vector.lineWidth || 1);
if (vector.dash) {
pdfDoc.dash(vector.dash.length, {space: vector.dash.space || vector.dash.length, phase: vector.dash.phase || 0});
pdfKitDoc.dash(vector.dash.length, {space: vector.dash.space || vector.dash.length, phase: vector.dash.phase || 0});
} else {
pdfDoc.undash();
pdfKitDoc.undash();
}
pdfDoc.fillOpacity(vector.fillOpacity || 1);
pdfDoc.strokeOpacity(vector.strokeOpacity || 1);
pdfDoc.lineJoin(vector.lineJoin || 'miter');
pdfKitDoc.fillOpacity(vector.fillOpacity || 1);
pdfKitDoc.strokeOpacity(vector.strokeOpacity || 1);
pdfKitDoc.lineJoin(vector.lineJoin || 'miter');

@@ -371,13 +398,13 @@ //TODO: clipping

case 'ellipse':
pdfDoc.ellipse(vector.x, vector.y, vector.r1, vector.r2);
pdfKitDoc.ellipse(vector.x, vector.y, vector.r1, vector.r2);
break;
case 'rect':
if (vector.r) {
pdfDoc.roundedRect(vector.x, vector.y, vector.w, vector.h, vector.r);
pdfKitDoc.roundedRect(vector.x, vector.y, vector.w, vector.h, vector.r);
} else {
pdfDoc.rect(vector.x, vector.y, vector.w, vector.h);
pdfKitDoc.rect(vector.x, vector.y, vector.w, vector.h);
}
if (vector.linearGradient) {
var gradient = pdfDoc.linearGradient(vector.x, vector.y, vector.x + vector.w, vector.y);
var gradient = pdfKitDoc.linearGradient(vector.x, vector.y, vector.x + vector.w, vector.y);
var step = 1 / (vector.linearGradient.length - 1);

@@ -393,4 +420,4 @@

case 'line':
pdfDoc.moveTo(vector.x1, vector.y1);
pdfDoc.lineTo(vector.x2, vector.y2);
pdfKitDoc.moveTo(vector.x1, vector.y1);
pdfKitDoc.lineTo(vector.x2, vector.y2);
break;

@@ -402,5 +429,5 @@ case 'polyline':

pdfDoc.moveTo(vector.points[0].x, vector.points[0].y);
pdfKitDoc.moveTo(vector.points[0].x, vector.points[0].y);
for (var i = 1, l = vector.points.length; i < l; i++) {
pdfDoc.lineTo(vector.points[i].x, vector.points[i].y);
pdfKitDoc.lineTo(vector.points[i].x, vector.points[i].y);
}

@@ -413,3 +440,3 @@

if (vector.closePath || p1.x === pn.x && p1.y === pn.y) {
pdfDoc.closePath();
pdfKitDoc.closePath();
}

@@ -421,7 +448,7 @@ }

if (vector.color && vector.lineColor) {
pdfDoc.fillAndStroke(vector.color, vector.lineColor);
pdfKitDoc.fillAndStroke(vector.color, vector.lineColor);
} else if (vector.color) {
pdfDoc.fill(vector.color);
pdfKitDoc.fill(vector.color);
} else {
pdfDoc.stroke(vector.lineColor || 'black');
pdfKitDoc.stroke(vector.lineColor || 'black');
}

@@ -428,0 +455,0 @@ }

@@ -100,3 +100,4 @@ /* jslint node: true */

'lineHeight',
'noWrap'
'noWrap',
'markerColor'
//'tableCellPadding'

@@ -152,3 +153,3 @@ // 'cellBorder',

if (typeof item == 'string' || item instanceof String) {
if (typeof item === 'string' || item instanceof String) {
// named-style-override

@@ -155,0 +156,0 @@

@@ -148,3 +148,3 @@ /* jslint node: true */

var noWrap = getStyleProperty(item, styleContextStack, 'noWrap', false);
var noWrap = getStyleProperty(item || {}, styleContextStack, 'noWrap', false);
if (item !== null && (typeof item === 'object' || item instanceof Object)) {

@@ -151,0 +151,0 @@ words = splitWords(normalizeString(item.text), noWrap);

@@ -19,3 +19,3 @@ var path = require('path');

loaders: [
{test: /\.json$/, loader: 'json'},
{test: /\.json$/, loader: 'json-loader'},
{test: /pdfMake.js$/, loader: 'expose?pdfMake', include: [path.join(__dirname, './src/browser-extensions')]},

@@ -79,8 +79,6 @@ {test: /pdfkit[\/\\]js[\/\\]mixins[\/\\]fonts.js$/, loader: StringReplacePlugin.replace({

]})
}
],
postLoaders: [
{test: /fontkit[\/\\]index.js$/, loader: "transform?brfs"},
{test: /unicode-properties[\/\\]index.js$/, loader: "transform?brfs"},
{test: /linebreak[\/\\]src[\/\\]linebreaker.js/, loader: "transform?brfs"}
},
{enforce: 'post', test: /fontkit[\/\\]index.js$/, loader: "transform?brfs"},
{enforce: 'post', test: /unicode-properties[\/\\]index.js$/, loader: "transform?brfs"},
{enforce: 'post', test: /linebreak[\/\\]src[\/\\]linebreaker.js/, loader: "transform?brfs"}
]

@@ -87,0 +85,0 @@ },

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc