pdfmake 0.2.13 → 0.2.15

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.
@@ -52,8 +52,8 @@ PageElementWriter.prototype.addQr = function (qr, index) {
52
52
  });
53
53
  };
54
54
 
55
- PageElementWriter.prototype.addVector = function (vector, ignoreContextX, ignoreContextY, index) {
56
- return this.writer.addVector(vector, ignoreContextX, ignoreContextY, index);
55
+ PageElementWriter.prototype.addVector = function (vector, ignoreContextX, ignoreContextY, index, forcePage) {
56
+ return this.writer.addVector(vector, ignoreContextX, ignoreContextY, index, forcePage);
57
57
  };
58
58
 
59
59
  PageElementWriter.prototype.beginClip = function (width, height) {
package/src/printer.js CHANGED
@@ -112,6 +112,9 @@ PdfPrinter.prototype.createPdfKitDocument = function (docDefinition, options) {
112
112
  options = options || {};
113
113
 
114
114
  docDefinition.version = docDefinition.version || '1.3';
115
+ docDefinition.subset = docDefinition.subset || undefined;
116
+ docDefinition.tagged = typeof docDefinition.tagged === 'boolean' ? docDefinition.tagged : false;
117
+ docDefinition.displayTitle = typeof docDefinition.displayTitle === 'boolean' ? docDefinition.displayTitle : false;
115
118
  docDefinition.compress = isBoolean(docDefinition.compress) ? docDefinition.compress : true;
116
119
  docDefinition.images = docDefinition.images || {};
117
120
  docDefinition.pageMargins = ((docDefinition.pageMargins !== undefined) && (docDefinition.pageMargins !== null)) ? docDefinition.pageMargins : 40;
@@ -121,6 +124,9 @@ PdfPrinter.prototype.createPdfKitDocument = function (docDefinition, options) {
121
124
  var pdfOptions = {
122
125
  size: [pageSize.width, pageSize.height],
123
126
  pdfVersion: docDefinition.version,
127
+ subset: docDefinition.subset,
128
+ tagged: docDefinition.tagged,
129
+ displayTitle: docDefinition.displayTitle,
124
130
  compress: docDefinition.compress,
125
131
  userPassword: docDefinition.userPassword,
126
132
  ownerPassword: docDefinition.ownerPassword,
@@ -686,6 +692,17 @@ function renderSVG(svg, x, y, pdfKitDoc, fontProvider) {
686
692
  };
687
693
 
688
694
  SVGtoPDF(pdfKitDoc, svg.svg, svg.x, svg.y, options);
695
+
696
+ if (svg.link) {
697
+ pdfKitDoc.link(svg.x, svg.y, svg._width, svg._height, svg.link);
698
+ }
699
+ if (svg.linkToPage) {
700
+ pdfKitDoc.ref({Type: 'Action', S: 'GoTo', D: [svg.linkToPage, 0, 0]}).end();
701
+ pdfKitDoc.annotate(svg.x, svg.y, svg._width, svg._height, { Subtype: 'Link', Dest: [svg.linkToPage - 1, 'XYZ', null, null, null] });
702
+ }
703
+ if (svg.linkToDestination) {
704
+ pdfKitDoc.goTo(svg.x, svg.y, svg._width, svg._height, svg.linkToDestination);
705
+ }
689
706
  }
690
707
 
691
708
  function beginClip(rect, pdfKitDoc) {
@@ -49,15 +49,19 @@ TableProcessor.prototype.beginTable = function (writer) {
49
49
 
50
50
  this.dontBreakRows = tableNode.table.dontBreakRows || false;
51
51
 
52
- if (this.rowsWithoutPageBreak) {
52
+ if (this.rowsWithoutPageBreak || this.dontBreakRows) {
53
53
  writer.beginUnbreakableBlock();
54
+ // Draw the top border of the table
55
+ this.drawHorizontalLine(0, writer);
56
+ if (this.rowsWithoutPageBreak && this.dontBreakRows) {
57
+ // We just increase the value of transactionLevel
58
+ writer.beginUnbreakableBlock();
59
+ }
54
60
  }
55
61
 
56
62
  // update the border properties of all cells before drawing any lines
57
63
  prepareCellBorders(this.tableNode.table.body);
58
64
 
59
- this.drawHorizontalLine(0, writer);
60
-
61
65
  function getTableInnerContentWidth() {
62
66
  var width = 0;
63
67
 
@@ -156,7 +160,12 @@ TableProcessor.prototype.beginRow = function (rowIndex, writer) {
156
160
 
157
161
  this.rowCallback = this.onRowBreak(rowIndex, writer);
158
162
  writer.tracker.startTracking('pageChanged', this.rowCallback);
159
- if (this.dontBreakRows) {
163
+ if (rowIndex == 0 && !this.dontBreakRows && !this.rowsWithoutPageBreak) {
164
+ // We store the 'y' to draw later and if necessary the top border of the table
165
+ this._tableTopBorderY = writer.context().y;
166
+ writer.context().moveDown(this.topLineWidth);
167
+ }
168
+ if (this.dontBreakRows && rowIndex > 0) {
160
169
  writer.beginUnbreakableBlock();
161
170
  }
162
171
  this.rowTopY = writer.context().y;
@@ -167,7 +176,7 @@ TableProcessor.prototype.beginRow = function (rowIndex, writer) {
167
176
  writer.context().moveDown(this.rowPaddingTop);
168
177
  };
169
178
 
170
- TableProcessor.prototype.drawHorizontalLine = function (lineIndex, writer, overrideY) {
179
+ TableProcessor.prototype.drawHorizontalLine = function (lineIndex, writer, overrideY, moveDown = true, forcePage) {
171
180
  var lineWidth = this.layout.hLineWidth(lineIndex, this.tableNode);
172
181
  if (lineWidth) {
173
182
  var style = this.layout.hLineStyle(lineIndex, this.tableNode);
@@ -266,7 +275,7 @@ TableProcessor.prototype.drawHorizontalLine = function (lineIndex, writer, overr
266
275
  lineWidth: lineWidth,
267
276
  dash: dash,
268
277
  lineColor: borderColor
269
- }, false, overrideY);
278
+ }, false, isNumber(overrideY), null, forcePage);
270
279
  currentLine = null;
271
280
  borderColor = null;
272
281
  cellAbove = null;
@@ -276,7 +285,9 @@ TableProcessor.prototype.drawHorizontalLine = function (lineIndex, writer, overr
276
285
  }
277
286
  }
278
287
 
279
- writer.context().moveDown(lineWidth);
288
+ if (moveDown) {
289
+ writer.context().moveDown(lineWidth);
290
+ }
280
291
  }
281
292
  };
282
293
 
@@ -392,6 +403,15 @@ TableProcessor.prototype.endRow = function (rowIndex, writer, pageBreaks) {
392
403
  ys[ys.length - 1].y1 = endingY;
393
404
 
394
405
  var skipOrphanePadding = (ys[0].y1 - ys[0].y0 === this.rowPaddingTop);
406
+ if (rowIndex === 0 && !skipOrphanePadding && !this.rowsWithoutPageBreak && !this.dontBreakRows) {
407
+ // Draw the top border of the table
408
+ var pageTableStartedAt = null;
409
+ if (pageBreaks && pageBreaks.length > 0) {
410
+ // Get the page where table started at
411
+ pageTableStartedAt = pageBreaks[0].prevPage;
412
+ }
413
+ this.drawHorizontalLine(0, writer, this._tableTopBorderY, false, pageTableStartedAt);
414
+ }
395
415
  for (var yi = (skipOrphanePadding ? 1 : 0), yl = ys.length; yi < yl; yi++) {
396
416
  var willBreak = yi < ys.length - 1;
397
417
  var rowBreakWithoutHeader = (yi > 0 && !this.headerRows);
@@ -411,6 +431,14 @@ TableProcessor.prototype.endRow = function (rowIndex, writer, pageBreaks) {
411
431
  this.reservedAtBottom = 0;
412
432
  }
413
433
 
434
+ // Draw horizontal lines before the vertical lines so they are not overridden
435
+ if (willBreak && this.layout.hLineWhenBroken !== false) {
436
+ this.drawHorizontalLine(rowIndex + 1, writer, y2);
437
+ }
438
+ if (rowBreakWithoutHeader && this.layout.hLineWhenBroken !== false) {
439
+ this.drawHorizontalLine(rowIndex, writer, y1);
440
+ }
441
+
414
442
  for (i = 0, l = xs.length; i < l; i++) {
415
443
  var leftCellBorder = false;
416
444
  var rightCellBorder = false;
@@ -497,13 +525,6 @@ TableProcessor.prototype.endRow = function (rowIndex, writer, pageBreaks) {
497
525
  }
498
526
  }
499
527
  }
500
-
501
- if (willBreak && this.layout.hLineWhenBroken !== false) {
502
- this.drawHorizontalLine(rowIndex + 1, writer, y2);
503
- }
504
- if (rowBreakWithoutHeader && this.layout.hLineWhenBroken !== false) {
505
- this.drawHorizontalLine(rowIndex, writer, y1);
506
- }
507
528
  }
508
529
 
509
530
  writer.context().page = endingPage;
@@ -542,7 +563,8 @@ TableProcessor.prototype.endRow = function (rowIndex, writer, pageBreaks) {
542
563
  if (this.dontBreakRows) {
543
564
  writer.tracker.auto('pageChanged',
544
565
  function () {
545
- if (!self.headerRows && self.layout.hLineWhenBroken !== false) {
566
+ if (rowIndex > 0 && !self.headerRows && self.layout.hLineWhenBroken !== false) {
567
+ // Draw the top border of the row after a page break
546
568
  self.drawHorizontalLine(rowIndex, writer);
547
569
  }
548
570
  },
@@ -1,7 +0,0 @@
1
- <component name="ProjectCodeStyleConfiguration">
2
- <code_scheme name="Project" version="173">
3
- <JSCodeStyleSettings version="0">
4
- <option name="FORCE_SEMICOLON_STYLE" value="true" />
5
- </JSCodeStyleSettings>
6
- </code_scheme>
7
- </component>
@@ -1,5 +0,0 @@
1
- <component name="ProjectCodeStyleConfiguration">
2
- <state>
3
- <option name="USE_PER_PROJECT_SETTINGS" value="true" />
4
- </state>
5
- </component>