pdfmake 0.1.53 → 0.1.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,35 +1,39 @@
1
1
  {
2
2
  "name": "pdfmake",
3
- "version": "0.1.53",
3
+ "version": "0.1.57",
4
4
  "description": "Client/server side PDF printing in pure JavaScript",
5
5
  "main": "src/printer.js",
6
+ "browser": "build/pdfmake.js",
6
7
  "directories": {
7
8
  "test": "tests"
8
9
  },
9
10
  "dependencies": {
10
11
  "iconv-lite": "^0.4.24",
11
12
  "linebreak": "^0.3.0",
12
- "pdfkit": "^0.9.0"
13
+ "pdfkit": "^0.10.0"
13
14
  },
14
15
  "devDependencies": {
15
- "@babel/core": "^7.3.3",
16
- "@babel/preset-env": "^7.3.1",
17
- "babel-loader": "^8.0.5",
18
- "brfs": "^2.0.1",
16
+ "@babel/core": "^7.4.5",
17
+ "@babel/plugin-transform-modules-commonjs": "^7.4.4",
18
+ "@babel/preset-env": "^7.4.5",
19
+ "babel-loader": "^8.0.6",
20
+ "brfs": "^2.0.2",
21
+ "eslint-plugin-jsdoc": "^7.2.3",
19
22
  "expose-loader": "^0.7.5",
20
23
  "fancy-log": "^1.3.3",
21
- "file-saver": "^2.0.1",
22
- "gulp": "^4.0.0",
24
+ "file-saver": "^2.0.2",
25
+ "gulp": "^4.0.2",
23
26
  "gulp-each": "^0.5.0",
24
27
  "gulp-eslint": "^5.0.0",
25
28
  "gulp-file-contents-to-json": "^0.2.2",
26
29
  "gulp-spawn-mocha": "^5.0.1",
27
- "mocha": "^5.2.0",
30
+ "mocha": "^6.1.4",
28
31
  "rewire": "^4.0.1",
29
- "sinon": "^7.2.3",
32
+ "sinon": "^7.3.2",
30
33
  "string-replace-webpack-plugin": "^0.1.3",
31
34
  "transform-loader": "^0.2.4",
32
- "webpack": "3.11.0"
35
+ "uglifyjs-webpack-plugin": "^2.1.3",
36
+ "webpack": "^4.33.0"
33
37
  },
34
38
  "scripts": {
35
39
  "build": "gulp build",
@@ -1,7 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var PdfPrinter = require('../printer');
4
3
  var isFunction = require('../helpers').isFunction;
4
+ var isUndefined = require('../helpers').isUndefined;
5
+ var isNull = require('../helpers').isNull;
5
6
  var FileSaver = require('file-saver');
6
7
  var saveAs = FileSaver.saveAs;
7
8
 
@@ -23,7 +24,7 @@ function Document(docDefinition, tableLayouts, fonts, vfs) {
23
24
 
24
25
  function canCreatePdf() {
25
26
  // Ensure the browser provides the level of support needed
26
- if (!Object.keys) {
27
+ if (!Object.keys || typeof Uint16Array === 'undefined') {
27
28
  return false;
28
29
  }
29
30
  return true;
@@ -35,6 +36,8 @@ Document.prototype._createDoc = function (options) {
35
36
  options.tableLayouts = this.tableLayouts;
36
37
  }
37
38
 
39
+ var PdfPrinter = require('../printer');
40
+
38
41
  var printer = new PdfPrinter(this.fonts);
39
42
  require('fs').bindFS(this.vfs); // bind virtual file system to file system
40
43
 
@@ -109,6 +112,16 @@ Document.prototype._openPdf = function (options, win) {
109
112
  var urlCreator = window.URL || window.webkitURL;
110
113
  var pdfUrl = urlCreator.createObjectURL(result);
111
114
  win.location.href = pdfUrl;
115
+
116
+ /* temporarily disabled
117
+ if (win !== window) {
118
+ setTimeout(function () {
119
+ if (isNull(win.window)) { // is closed by AdBlock
120
+ window.location.href = pdfUrl; // open in actual window
121
+ }
122
+ }, 500);
123
+ }
124
+ */
112
125
  }, options);
113
126
  } catch (e) {
114
127
  win.close();
@@ -133,8 +146,16 @@ Document.prototype.print = function (options, win) {
133
146
  this._openPdf(options, win);
134
147
  };
135
148
 
149
+ /**
150
+ * download(defaultFileName = 'file.pdf', cb = null, options = {})
151
+ * or
152
+ * download(cb, options = {})
153
+ */
136
154
  Document.prototype.download = function (defaultFileName, cb, options) {
137
155
  if (isFunction(defaultFileName)) {
156
+ if (!isUndefined(cb)) {
157
+ options = cb;
158
+ }
138
159
  cb = defaultFileName;
139
160
  defaultFileName = null;
140
161
  }
@@ -5,10 +5,14 @@ function VirtualFileSystem() {
5
5
  this.dataSystem = {};
6
6
  }
7
7
 
8
- VirtualFileSystem.prototype.readFileSync = function (filename) {
8
+ VirtualFileSystem.prototype.readFileSync = function (filename, options) {
9
9
  filename = fixFilename(filename);
10
10
 
11
11
  var dataContent = this.dataSystem[filename];
12
+ if (typeof dataContent === 'string' && options === 'utf8') {
13
+ return dataContent;
14
+ }
15
+
12
16
  if (dataContent) {
13
17
  return new Buffer(dataContent, typeof dataContent === 'string' ? 'base64' : undefined);
14
18
  }
package/src/docMeasure.js CHANGED
@@ -10,6 +10,7 @@ var isNumber = require('./helpers').isNumber;
10
10
  var isObject = require('./helpers').isObject;
11
11
  var isArray = require('./helpers').isArray;
12
12
  var fontStringify = require('./helpers').fontStringify;
13
+ var getNodeId = require('./helpers').getNodeId;
13
14
  var pack = require('./helpers').pack;
14
15
  var qrEncoder = require('./qrEnc.js');
15
16
 
@@ -229,9 +230,10 @@ DocMeasure.prototype.measureToc = function (node) {
229
230
  var lineStyle = item._textNodeRef.tocStyle || textStyle;
230
231
  var lineMargin = item._textNodeRef.tocMargin || textMargin;
231
232
  var lineNumberStyle = item._textNodeRef.tocNumberStyle || numberStyle;
233
+ var destination = getNodeId(item._nodeRef);
232
234
  body.push([
233
- {text: item._textNodeRef.text, alignment: 'left', style: lineStyle, margin: lineMargin},
234
- {text: '00000', alignment: 'right', _tocItemRef: item._nodeRef, style: lineNumberStyle, margin: [0, lineMargin[1], 0, lineMargin[3]]}
235
+ {text: item._textNodeRef.text, linkToDestination: destination, alignment: 'left', style: lineStyle, margin: lineMargin},
236
+ {text: '00000', linkToDestination: destination, alignment: 'right', _tocItemRef: item._nodeRef, style: lineNumberStyle, margin: [0, lineMargin[1], 0, lineMargin[3]]}
235
237
  ]);
236
238
  }
237
239
 
@@ -129,6 +129,10 @@ DocPreprocessor.prototype.preprocessText = function (node) {
129
129
  this.tocs[tocItemId] = {toc: {_items: [], _pseudo: true}};
130
130
  }
131
131
 
132
+ if (!node.id) {
133
+ node.id = 'toc-' + tocItemId + '-' + this.tocs[tocItemId].toc._items.length;
134
+ }
135
+
132
136
  var tocItemRef = {
133
137
  _nodeRef: this._getNodeForNodeRef(node),
134
138
  _textNodeRef: node
@@ -163,6 +167,7 @@ DocPreprocessor.prototype.preprocessText = function (node) {
163
167
  };
164
168
  }
165
169
  node.text = '00000';
170
+ node.linkToDestination = node.pageReference;
166
171
  node._pageRef = this.nodeReferences[node.pageReference];
167
172
  }
168
173
 
@@ -172,6 +177,7 @@ DocPreprocessor.prototype.preprocessText = function (node) {
172
177
  }
173
178
 
174
179
  node.text = '';
180
+ node.linkToDestination = node.textReference;
175
181
  node._textRef = this.nodeReferences[node.textReference];
176
182
  }
177
183
 
@@ -240,4 +246,4 @@ DocPreprocessor.prototype._getNodeForNodeRef = function (node) {
240
246
  return node;
241
247
  }
242
248
 
243
- module.exports = DocPreprocessor;
249
+ module.exports = DocPreprocessor;
@@ -159,6 +159,15 @@ DocumentContext.prototype.moveTo = function (x, y) {
159
159
  }
160
160
  };
161
161
 
162
+ DocumentContext.prototype.moveToRelative = function (x, y) {
163
+ if (x !== undefined && x !== null) {
164
+ this.x = this.x + x;
165
+ }
166
+ if (y !== undefined && y !== null) {
167
+ this.y = this.y + y;
168
+ }
169
+ };
170
+
162
171
  DocumentContext.prototype.beginDetachedBlock = function () {
163
172
  this.snapshots.push({
164
173
  x: this.x,
@@ -241,6 +241,9 @@ ElementWriter.prototype.addFragment = function (block, useBlockXOffset, useBlock
241
241
  case 'line':
242
242
  var l = cloneLine(item.item);
243
243
 
244
+ if (l._node) {
245
+ l._node.positions[0].pageNumber = ctx.page + 1;
246
+ }
244
247
  l.x = (l.x || 0) + (useBlockXOffset ? (block.xOffset || 0) : ctx.x);
245
248
  l.y = (l.y || 0) + (useBlockYOffset ? (block.yOffset || 0) : ctx.y);
246
249
 
package/src/helpers.js CHANGED
@@ -79,6 +79,24 @@ function fontStringify(key, val) {
79
79
  return val;
80
80
  }
81
81
 
82
+ function getNodeId(node) {
83
+ if (node.id) {
84
+ return node.id;
85
+ }
86
+
87
+ if (isArray(node.text)) {
88
+ for (var i = 0, l = node.text.length; i < l; i++) {
89
+ var n = node.text[i];
90
+ var nodeId = getNodeId(n);
91
+ if (nodeId) {
92
+ return nodeId;
93
+ }
94
+ }
95
+ }
96
+
97
+ return null;
98
+ }
99
+
82
100
  module.exports = {
83
101
  isString: isString,
84
102
  isNumber: isNumber,
@@ -90,5 +108,6 @@ module.exports = {
90
108
  isUndefined: isUndefined,
91
109
  pack: pack,
92
110
  fontStringify: fontStringify,
93
- offsetVector: offsetVector
111
+ offsetVector: offsetVector,
112
+ getNodeId: getNodeId
94
113
  };
@@ -12,11 +12,11 @@ ImageMeasure.prototype.measureImage = function (src) {
12
12
  if (!this.pdfKitDoc._imageRegistry[src]) {
13
13
  try {
14
14
  image = this.pdfKitDoc.openImage(realImageSrc(src));
15
+ if (!image) {
16
+ throw 'No image';
17
+ }
15
18
  } catch (error) {
16
- image = null;
17
- }
18
- if (image === null || image === undefined) {
19
- throw 'invalid image, images dictionary should contain dataURL entries (or local file paths in node.js)';
19
+ throw 'Invalid image: ' + error.toString() + '\nImages dictionary should contain dataURL entries (or local file paths in node.js)';
20
20
  }
21
21
  image.embed(this.pdfKitDoc);
22
22
  this.pdfKitDoc._imageRegistry[src] = image;
@@ -13,6 +13,7 @@ var isArray = require('./helpers').isArray;
13
13
  var pack = require('./helpers').pack;
14
14
  var offsetVector = require('./helpers').offsetVector;
15
15
  var fontStringify = require('./helpers').fontStringify;
16
+ var getNodeId = require('./helpers').getNodeId;
16
17
  var isFunction = require('./helpers').isFunction;
17
18
  var TextTools = require('./textTools');
18
19
  var StyleContextStack = require('./styleContextStack');
@@ -357,7 +358,7 @@ LayoutBuilder.prototype.processNode = function (node) {
357
358
  var relPosition = node.relativePosition;
358
359
  if (relPosition) {
359
360
  self.writer.context().beginDetachedBlock();
360
- self.writer.context().moveTo((relPosition.x || 0) + self.writer.context().x, (relPosition.y || 0) + self.writer.context().y);
361
+ self.writer.context().moveToRelative(relPosition.x || 0, relPosition.y || 0);
361
362
  }
362
363
 
363
364
  if (node.stack) {
@@ -611,9 +612,19 @@ LayoutBuilder.prototype.processTable = function (tableNode) {
611
612
  // leafs (texts)
612
613
  LayoutBuilder.prototype.processLeaf = function (node) {
613
614
  var line = this.buildNextLine(node);
615
+ if (line && (node.tocItem || node.id)) {
616
+ line._node = node;
617
+ }
614
618
  var currentHeight = (line) ? line.getHeight() : 0;
615
619
  var maxHeight = node.maxHeight || -1;
616
620
 
621
+ if (line) {
622
+ var nodeId = getNodeId(node);
623
+ if (nodeId) {
624
+ line.id = nodeId;
625
+ }
626
+ }
627
+
617
628
  if (node._tocItemRef) {
618
629
  line._pageNodeRef = node._tocItemRef;
619
630
  }
package/src/printer.js CHANGED
@@ -98,8 +98,10 @@ PdfPrinter.prototype.createPdfKitDocument = function (docDefinition, options) {
98
98
  userPassword: docDefinition.userPassword,
99
99
  ownerPassword: docDefinition.ownerPassword,
100
100
  permissions: docDefinition.permissions,
101
+ fontLayoutCache: isBoolean(options.fontLayoutCache) ? options.fontLayoutCache : true,
101
102
  bufferPages: options.bufferPages || false,
102
- autoFirstPage: false
103
+ autoFirstPage: false,
104
+ font: null
103
105
  };
104
106
 
105
107
  this.pdfKitDoc = PdfKitEngine.createPdfDocument(pdfOptions);
@@ -389,7 +391,6 @@ function renderLine(line, x, y, pdfKitDoc) {
389
391
  var pageNumber = _pageNodeRef.positions[0].pageNumber.toString();
390
392
 
391
393
  inline.text = pageNumber;
392
- inline.linkToPage = pageNumber;
393
394
  newWidth = textTools.widthOfString(inline.text, inline.font, inline.fontSize, inline.characterSpacing, inline.fontFeatures);
394
395
  diffWidth = inline.width - newWidth;
395
396
  inline.width = newWidth;
@@ -434,6 +435,14 @@ function renderLine(line, x, y, pdfKitDoc) {
434
435
  link: inline.link
435
436
  };
436
437
 
438
+ if (inline.linkToDestination) {
439
+ options.goTo = inline.linkToDestination;
440
+ }
441
+
442
+ if (line.id && i === 0) {
443
+ options.destination = line.id;
444
+ }
445
+
437
446
  if (inline.fontFeatures) {
438
447
  options.features = inline.fontFeatures;
439
448
  }
@@ -489,9 +498,15 @@ function renderVector(vector, pdfKitDoc) {
489
498
 
490
499
  //TODO: clipping
491
500
 
501
+ var gradient = null;
502
+
492
503
  switch (vector.type) {
493
504
  case 'ellipse':
494
505
  pdfKitDoc.ellipse(vector.x, vector.y, vector.r1, vector.r2);
506
+
507
+ if (vector.linearGradient) {
508
+ gradient = pdfKitDoc.linearGradient(vector.x - vector.r1, vector.y, vector.x + vector.r1, vector.y);
509
+ }
495
510
  break;
496
511
  case 'rect':
497
512
  if (vector.r) {
@@ -501,14 +516,7 @@ function renderVector(vector, pdfKitDoc) {
501
516
  }
502
517
 
503
518
  if (vector.linearGradient) {
504
- var gradient = pdfKitDoc.linearGradient(vector.x, vector.y, vector.x + vector.w, vector.y);
505
- var step = 1 / (vector.linearGradient.length - 1);
506
-
507
- for (var i = 0; i < vector.linearGradient.length; i++) {
508
- gradient.stop(i * step, vector.linearGradient[i]);
509
- }
510
-
511
- vector.color = gradient;
519
+ gradient = pdfKitDoc.linearGradient(vector.x, vector.y, vector.x + vector.w, vector.y);
512
520
  }
513
521
  break;
514
522
  case 'line':
@@ -539,6 +547,16 @@ function renderVector(vector, pdfKitDoc) {
539
547
  break;
540
548
  }
541
549
 
550
+ if (vector.linearGradient && gradient) {
551
+ var step = 1 / (vector.linearGradient.length - 1);
552
+
553
+ for (var i = 0; i < vector.linearGradient.length; i++) {
554
+ gradient.stop(i * step, vector.linearGradient[i]);
555
+ }
556
+
557
+ vector.color = gradient;
558
+ }
559
+
542
560
  if (vector.color && vector.lineColor) {
543
561
  pdfKitDoc.fillColor(vector.color, vector.fillOpacity || 1);
544
562
  pdfKitDoc.strokeColor(vector.lineColor, vector.strokeOpacity || 1);
@@ -157,42 +157,82 @@ TableProcessor.prototype.drawHorizontalLine = function (lineIndex, writer, overr
157
157
  var offset = lineWidth / 2;
158
158
  var currentLine = null;
159
159
  var body = this.tableNode.table.body;
160
+ var cellAbove;
161
+ var currentCell;
162
+ var rowCellAbove;
160
163
 
161
164
  for (var i = 0, l = this.rowSpanData.length; i < l; i++) {
162
165
  var data = this.rowSpanData[i];
163
166
  var shouldDrawLine = !data.rowSpan;
167
+ var borderColor;
164
168
 
165
169
  // draw only if the current cell requires a top border or the cell in the
166
170
  // row above requires a bottom border
167
171
  if (shouldDrawLine && i < l - 1) {
168
172
  var topBorder = false, bottomBorder = false;
169
173
 
170
- // the current cell
171
- if (lineIndex < body.length) {
172
- var cell = body[lineIndex][i];
173
- topBorder = cell.border ? cell.border[1] : this.layout.defaultBorder;
174
- }
175
-
176
174
  // the cell in the row above
177
175
  if (lineIndex > 0) {
178
- var cellAbove = body[lineIndex - 1][i];
176
+ cellAbove = body[lineIndex - 1][i];
179
177
  bottomBorder = cellAbove.border ? cellAbove.border[3] : this.layout.defaultBorder;
178
+ if (cellAbove.borderColor) {
179
+ borderColor = cellAbove.borderColor[3];
180
+ }
181
+ }
182
+
183
+ // the current cell
184
+ if (lineIndex < body.length) {
185
+ currentCell = body[lineIndex][i];
186
+ topBorder = currentCell.border ? currentCell.border[1] : this.layout.defaultBorder;
187
+ if (borderColor == null && currentCell.borderColor) {
188
+ borderColor = currentCell.borderColor[1];
189
+ }
180
190
  }
181
191
 
182
192
  shouldDrawLine = topBorder || bottomBorder;
183
193
  }
184
194
 
195
+ if (cellAbove && cellAbove._rowSpanCurrentOffset) {
196
+ rowCellAbove = body[lineIndex - 1 - cellAbove._rowSpanCurrentOffset][i];
197
+ if (rowCellAbove.borderColor) {
198
+ borderColor = rowCellAbove.borderColor[3];
199
+ }
200
+ }
201
+
202
+ if (borderColor == null) {
203
+ borderColor = isFunction(this.layout.hLineColor) ? this.layout.hLineColor(lineIndex, this.tableNode, i) : this.layout.hLineColor;
204
+ }
205
+
185
206
  if (!currentLine && shouldDrawLine) {
186
207
  currentLine = {left: data.left, width: 0};
187
208
  }
188
209
 
189
210
  if (shouldDrawLine) {
190
- currentLine.width += (data.width || 0);
211
+ var colSpanIndex = 0;
212
+ if (rowCellAbove && rowCellAbove.colSpan) {
213
+ while (rowCellAbove.colSpan > colSpanIndex) {
214
+ currentLine.width += (this.rowSpanData[i + colSpanIndex++].width || 0);
215
+ }
216
+ i += colSpanIndex - 1;
217
+ } else if (cellAbove && cellAbove.colSpan) {
218
+ while (cellAbove.colSpan > colSpanIndex) {
219
+ currentLine.width += (this.rowSpanData[i + colSpanIndex++].width || 0);
220
+ }
221
+ i += colSpanIndex - 1;
222
+ } else if (currentCell && currentCell.colSpan) {
223
+ while (currentCell.colSpan > colSpanIndex) {
224
+ currentLine.width += (this.rowSpanData[i + colSpanIndex++].width || 0);
225
+ }
226
+ i += colSpanIndex - 1;
227
+ } else {
228
+ currentLine.width += (this.rowSpanData[i].width || 0);
229
+ }
191
230
  }
192
231
 
193
232
  var y = (overrideY || 0) + offset;
194
233
 
195
- if (!shouldDrawLine || i === l - 1) {
234
+
235
+ if (shouldDrawLine) {
196
236
  if (currentLine && currentLine.width) {
197
237
  writer.addVector({
198
238
  type: 'line',
@@ -202,9 +242,13 @@ TableProcessor.prototype.drawHorizontalLine = function (lineIndex, writer, overr
202
242
  y2: y,
203
243
  lineWidth: lineWidth,
204
244
  dash: dash,
205
- lineColor: isFunction(this.layout.hLineColor) ? this.layout.hLineColor(lineIndex, this.tableNode) : this.layout.hLineColor
245
+ lineColor: borderColor
206
246
  }, false, overrideY);
207
247
  currentLine = null;
248
+ borderColor = null;
249
+ cellAbove = null;
250
+ currentCell = null;
251
+ rowCellAbove = null;
208
252
  }
209
253
  }
210
254
  }
@@ -213,16 +257,55 @@ TableProcessor.prototype.drawHorizontalLine = function (lineIndex, writer, overr
213
257
  }
214
258
  };
215
259
 
216
- TableProcessor.prototype.drawVerticalLine = function (x, y0, y1, vLineIndex, writer) {
217
- var width = this.layout.vLineWidth(vLineIndex, this.tableNode);
260
+ TableProcessor.prototype.drawVerticalLine = function (x, y0, y1, vLineColIndex, writer, vLineRowIndex, beforeVLineColIndex) {
261
+ var width = this.layout.vLineWidth(vLineColIndex, this.tableNode);
218
262
  if (width === 0) {
219
263
  return;
220
264
  }
221
- var style = this.layout.vLineStyle(vLineIndex, this.tableNode);
265
+ var style = this.layout.vLineStyle(vLineColIndex, this.tableNode);
222
266
  var dash;
223
267
  if (style && style.dash) {
224
268
  dash = style.dash;
225
269
  }
270
+
271
+ var body = this.tableNode.table.body;
272
+ var cellBefore;
273
+ var currentCell;
274
+ var borderColor;
275
+
276
+ // the cell in the col before
277
+ if (vLineColIndex > 0) {
278
+ cellBefore = body[vLineRowIndex][beforeVLineColIndex];
279
+ if (cellBefore && cellBefore.borderColor) {
280
+ borderColor = cellBefore.borderColor[2];
281
+ }
282
+ }
283
+
284
+ // the current cell
285
+ if (borderColor == null && vLineColIndex < body.length) {
286
+ currentCell = body[vLineRowIndex][vLineColIndex];
287
+ if (currentCell && currentCell.borderColor) {
288
+ borderColor = currentCell.borderColor[0];
289
+ }
290
+ }
291
+
292
+ if (borderColor == null && cellBefore && cellBefore._rowSpanCurrentOffset) {
293
+ var rowCellBeforeAbove = body[vLineRowIndex - cellBefore._rowSpanCurrentOffset][beforeVLineColIndex];
294
+ if (rowCellBeforeAbove.borderColor) {
295
+ borderColor = rowCellBeforeAbove.borderColor[2];
296
+ }
297
+ }
298
+
299
+ if (borderColor == null && currentCell && currentCell._rowSpanCurrentOffset) {
300
+ var rowCurrentCellAbove = body[vLineRowIndex - currentCell._rowSpanCurrentOffset][vLineColIndex];
301
+ if (rowCurrentCellAbove.borderColor) {
302
+ borderColor = rowCurrentCellAbove.borderColor[2];
303
+ }
304
+ }
305
+
306
+ if (borderColor == null) {
307
+ borderColor = isFunction(this.layout.vLineColor) ? this.layout.vLineColor(vLineColIndex, this.tableNode, vLineRowIndex) : this.layout.vLineColor;
308
+ }
226
309
  writer.addVector({
227
310
  type: 'line',
228
311
  x1: x + width / 2,
@@ -231,8 +314,11 @@ TableProcessor.prototype.drawVerticalLine = function (x, y0, y1, vLineIndex, wri
231
314
  y2: y1,
232
315
  lineWidth: width,
233
316
  dash: dash,
234
- lineColor: isFunction(this.layout.vLineColor) ? this.layout.vLineColor(vLineIndex, this.tableNode) : this.layout.vLineColor
317
+ lineColor: borderColor
235
318
  }, false, true);
319
+ cellBefore = null;
320
+ currentCell = null;
321
+ borderColor = null;
236
322
  };
237
323
 
238
324
  TableProcessor.prototype.endTable = function (writer) {
@@ -319,7 +405,7 @@ TableProcessor.prototype.endRow = function (rowIndex, writer, pageBreaks) {
319
405
  }
320
406
 
321
407
  if (leftCellBorder) {
322
- this.drawVerticalLine(xs[i].x, y1 - hzLineOffset, y2 + this.bottomLineWidth, xs[i].index, writer);
408
+ this.drawVerticalLine(xs[i].x, y1 - hzLineOffset, y2 + this.bottomLineWidth, xs[i].index, writer, rowIndex, xs[i - 1] ? xs[i - 1].index : null);
323
409
  }
324
410
 
325
411
  if (i < l - 1) {
@@ -377,6 +463,12 @@ TableProcessor.prototype.endRow = function (rowIndex, writer, pageBreaks) {
377
463
  this.tableNode.table.body[rowIndex + j][i]._colSpan = row[i].colSpan;
378
464
  }
379
465
  }
466
+ // fix rowSpans
467
+ if (row[i].rowSpan && row[i].rowSpan > 1) {
468
+ for (var j = 1; j < row[i].rowSpan; j++) {
469
+ this.tableNode.table.body[rowIndex + j][i]._rowSpanCurrentOffset = j;
470
+ }
471
+ }
380
472
  }
381
473
 
382
474
  if (this.rowSpanData[i].rowSpan > 0) {
@@ -392,14 +484,14 @@ TableProcessor.prototype.endRow = function (rowIndex, writer, pageBreaks) {
392
484
 
393
485
  if (this.dontBreakRows) {
394
486
  writer.tracker.auto('pageChanged',
395
- function () {
396
- if (!self.headerRows && self.layout.hLineWhenBroken !== false) {
397
- self.drawHorizontalLine(rowIndex, writer);
398
- }
399
- },
400
- function () {
401
- writer.commitUnbreakableBlock();
402
- }
487
+ function () {
488
+ if (!self.headerRows && self.layout.hLineWhenBroken !== false) {
489
+ self.drawHorizontalLine(rowIndex, writer);
490
+ }
491
+ },
492
+ function () {
493
+ writer.commitUnbreakableBlock();
494
+ }
403
495
  );
404
496
  }
405
497
 
package/src/textTools.js CHANGED
@@ -293,6 +293,7 @@ function measure(fontProvider, textArray, styleContextStack) {
293
293
  var characterSpacing = getStyleProperty(item, styleContextStack, 'characterSpacing', 0);
294
294
  var link = getStyleProperty(item, styleContextStack, 'link', null);
295
295
  var linkToPage = getStyleProperty(item, styleContextStack, 'linkToPage', null);
296
+ var linkToDestination = getStyleProperty(item, styleContextStack, 'linkToDestination', null);
296
297
  var noWrap = getStyleProperty(item, styleContextStack, 'noWrap', null);
297
298
  var preserveLeadingSpaces = getStyleProperty(item, styleContextStack, 'preserveLeadingSpaces', false);
298
299
  var preserveTrailingSpaces = getStyleProperty(item, styleContextStack, 'preserveTrailingSpaces', false);
@@ -331,6 +332,7 @@ function measure(fontProvider, textArray, styleContextStack) {
331
332
  item.background = background;
332
333
  item.link = link;
333
334
  item.linkToPage = linkToPage;
335
+ item.linkToDestination = linkToDestination;
334
336
  item.noWrap = noWrap;
335
337
  item.opacity = opacity;
336
338
  });