Skip to content

Commit

Permalink
0.1.61
Browse files Browse the repository at this point in the history
  • Loading branch information
liborm85 committed Oct 25, 2019
1 parent f827bd2 commit 08bbf60
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 17 deletions.
51 changes: 44 additions & 7 deletions build/pdfmake.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! pdfmake v0.1.60, @license MIT, @link http://pdfmake.org */
/*! pdfmake v0.1.61, @license MIT, @link http://pdfmake.org */
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
Expand Down Expand Up @@ -977,7 +977,7 @@ module.exports = {
/* 2 */
/***/ (function(module, exports) {

var core = module.exports = { version: '2.6.9' };
var core = module.exports = { version: '2.6.10' };
if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef


Expand Down Expand Up @@ -4763,7 +4763,7 @@ module.exports = function (fn, that, length) {
/* 39 */
/***/ (function(module, exports) {

var core = module.exports = { version: '2.6.9' };
var core = module.exports = { version: '2.6.10' };
if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef


Expand Down Expand Up @@ -19420,6 +19420,32 @@ var getSvgToPDF = function () {
}
};

var findFont = function (fonts, requiredFonts, defaultFont) {
for (var i = 0; i < requiredFonts.length; i++) {
var requiredFont = requiredFonts[i].toLowerCase();

for (var font in fonts) {
if (font.toLowerCase() === requiredFont) {
return font;
}
}
}

return defaultFont;
};

var typeName = function (bold, italics) {
var type = 'normal';
if (bold && italics) {
type = 'bolditalics';
} else if (bold) {
type = 'bold';
} else if (italics) {
type = 'italics';
}
return type;
};

////////////////////////////////////////
// PdfPrinter

Expand Down Expand Up @@ -19772,7 +19798,7 @@ function renderPages(pages, fontProvider, pdfKitDoc, progressCallback) {
renderImage(item.item, item.item.x, item.item.y, pdfKitDoc);
break;
case 'svg':
renderSVG(item.item, item.item.x, item.item.y, pdfKitDoc);
renderSVG(item.item, item.item.x, item.item.y, pdfKitDoc, fontProvider);
break;
case 'beginClip':
beginClip(item.item, pdfKitDoc);
Expand Down Expand Up @@ -19992,8 +20018,19 @@ function renderImage(image, x, y, pdfKitDoc) {
}
}

function renderSVG(svg, x, y, pdfKitDoc) {
getSvgToPDF()(pdfKitDoc, svg.svg, svg.x, svg.y, Object.assign({ width: svg._width, height: svg._height, assumePt: true }, svg.options));
function renderSVG(svg, x, y, pdfKitDoc, fontProvider) {
var options = Object.assign({ width: svg._width, height: svg._height, assumePt: true }, svg.options);
options.fontCallback = function (family, bold, italic, fontOptions) {
fontOptions.fauxBold = bold;
fontOptions.fauxItalic = italic;

var fontsFamily = family.split(',').map(function (f) { return f.trim().replace(/('|")/g, ''); });
var font = findFont(fontProvider.fonts, fontsFamily, 'Roboto'); // TODO: default font from dd

return fontProvider.fonts[font][typeName(bold, italic)];
};

getSvgToPDF()(pdfKitDoc, svg.svg, svg.x, svg.y, options);
}

function beginClip(rect, pdfKitDoc) {
Expand Down Expand Up @@ -63638,7 +63675,7 @@ TableProcessor.prototype.drawHorizontalLine = function (lineIndex, writer, overr
for (var i = 0, l = this.rowSpanData.length; i < l; i++) {
var data = this.rowSpanData[i];
var shouldDrawLine = !data.rowSpan;
var borderColor;
var borderColor = null;

// draw only if the current cell requires a top border or the cell in the
// row above requires a bottom border
Expand Down
2 changes: 1 addition & 1 deletion build/pdfmake.js.map

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions build/pdfmake.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/pdfmake.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pdfmake",
"version": "0.1.60",
"version": "0.1.61",
"description": "Client/server side PDF printing in pure JavaScript",
"main": "src/printer.js",
"browser": "build/pdfmake.js",
Expand Down

0 comments on commit 08bbf60

Please sign in to comment.