pdfmake 0.3.0-beta.10 → 0.3.0-beta.12

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/src/Printer.js CHANGED
@@ -47,6 +47,9 @@ class PdfPrinter {
47
47
  this.resolveUrls(docDefinition).then(() => {
48
48
  try {
49
49
  docDefinition.version = docDefinition.version || '1.3';
50
+ docDefinition.subset = docDefinition.subset || undefined;
51
+ docDefinition.tagged = typeof docDefinition.tagged === 'boolean' ? docDefinition.tagged : false;
52
+ docDefinition.displayTitle = typeof docDefinition.displayTitle === 'boolean' ? docDefinition.displayTitle : false;
50
53
  docDefinition.compress = typeof docDefinition.compress === 'boolean' ? docDefinition.compress : true;
51
54
  docDefinition.images = docDefinition.images || {};
52
55
  docDefinition.attachments = docDefinition.attachments || {};
@@ -58,6 +61,9 @@ class PdfPrinter {
58
61
  let pdfOptions = {
59
62
  size: [pageSize.width, pageSize.height],
60
63
  pdfVersion: docDefinition.version,
64
+ subset: docDefinition.subset,
65
+ tagged: docDefinition.tagged,
66
+ displayTitle: docDefinition.displayTitle,
61
67
  compress: docDefinition.compress,
62
68
  userPassword: docDefinition.userPassword,
63
69
  ownerPassword: docDefinition.ownerPassword,
package/src/Renderer.js CHANGED
@@ -348,6 +348,17 @@ class Renderer {
348
348
  };
349
349
 
350
350
  SVGtoPDF(this.pdfDocument, svg.svg, svg.x, svg.y, options);
351
+
352
+ if (svg.link) {
353
+ this.pdfDocument.link(svg.x, svg.y, svg._width, svg._height, svg.link);
354
+ }
355
+ if (svg.linkToPage) {
356
+ this.pdfDocument.ref({Type: 'Action', S: 'GoTo', D: [svg.linkToPage, 0, 0]}).end();
357
+ this.pdfDocument.annotate(svg.x, svg.y, svg._width, svg._height, { Subtype: 'Link', Dest: [svg.linkToPage - 1, 'XYZ', null, null, null] });
358
+ }
359
+ if (svg.linkToDestination) {
360
+ this.pdfDocument.goTo(svg.x, svg.y, svg._width, svg._height, svg.linkToDestination);
361
+ }
351
362
  }
352
363
 
353
364
  renderAttachment(attachment) {
@@ -125,14 +125,18 @@ class TableProcessor {
125
125
 
126
126
  this.dontBreakRows = tableNode.table.dontBreakRows || false;
127
127
 
128
- if (this.rowsWithoutPageBreak) {
128
+ if (this.rowsWithoutPageBreak || this.dontBreakRows) {
129
129
  writer.beginUnbreakableBlock();
130
+ // Draw the top border of the table
131
+ this.drawHorizontalLine(0, writer);
132
+ if (this.rowsWithoutPageBreak && this.dontBreakRows) {
133
+ // We just increase the value of transactionLevel
134
+ writer.beginUnbreakableBlock();
135
+ }
130
136
  }
131
137
 
132
138
  // update the border properties of all cells before drawing any lines
133
139
  prepareCellBorders(this.tableNode.table.body);
134
-
135
- this.drawHorizontalLine(0, writer);
136
140
  }
137
141
 
138
142
  onRowBreak(rowIndex, writer) {
@@ -151,7 +155,12 @@ class TableProcessor {
151
155
 
152
156
  this.rowCallback = this.onRowBreak(rowIndex, writer);
153
157
  writer.addListener('pageChanged', this.rowCallback);
154
- if (this.dontBreakRows) {
158
+ if (rowIndex == 0 && !this.dontBreakRows && !this.rowsWithoutPageBreak) {
159
+ // We store the 'y' to draw later and if necessary the top border of the table
160
+ this._tableTopBorderY = writer.context().y;
161
+ writer.context().moveDown(this.topLineWidth);
162
+ }
163
+ if (this.dontBreakRows && rowIndex > 0) {
155
164
  writer.beginUnbreakableBlock();
156
165
  }
157
166
  this.rowTopY = writer.context().y;
@@ -162,7 +171,7 @@ class TableProcessor {
162
171
  writer.context().moveDown(this.rowPaddingTop);
163
172
  }
164
173
 
165
- drawHorizontalLine(lineIndex, writer, overrideY) {
174
+ drawHorizontalLine(lineIndex, writer, overrideY, moveDown = true, forcePage) {
166
175
  let lineWidth = this.layout.hLineWidth(lineIndex, this.tableNode);
167
176
  if (lineWidth) {
168
177
  let style = this.layout.hLineStyle(lineIndex, this.tableNode);
@@ -260,7 +269,7 @@ class TableProcessor {
260
269
  lineWidth: lineWidth,
261
270
  dash: dash,
262
271
  lineColor: borderColor
263
- }, false, overrideY);
272
+ }, false, isNumber(overrideY), null, forcePage);
264
273
  currentLine = null;
265
274
  borderColor = null;
266
275
  cellAbove = null;
@@ -270,7 +279,9 @@ class TableProcessor {
270
279
  }
271
280
  }
272
281
 
273
- writer.context().moveDown(lineWidth);
282
+ if (moveDown) {
283
+ writer.context().moveDown(lineWidth);
284
+ }
274
285
  }
275
286
  }
276
287
 
@@ -406,6 +417,15 @@ class TableProcessor {
406
417
  ys[ys.length - 1].y1 = endingY;
407
418
 
408
419
  let skipOrphanePadding = (ys[0].y1 - ys[0].y0 === this.rowPaddingTop);
420
+ if (rowIndex === 0 && !skipOrphanePadding && !this.rowsWithoutPageBreak && !this.dontBreakRows) {
421
+ // Draw the top border of the table
422
+ let pageTableStartedAt = null;
423
+ if (pageBreaks && pageBreaks.length > 0) {
424
+ // Get the page where table started at
425
+ pageTableStartedAt = pageBreaks[0].prevPage;
426
+ }
427
+ this.drawHorizontalLine(0, writer, this._tableTopBorderY, false, pageTableStartedAt);
428
+ }
409
429
  for (let yi = (skipOrphanePadding ? 1 : 0), yl = ys.length; yi < yl; yi++) {
410
430
  let willBreak = yi < ys.length - 1;
411
431
  let rowBreakWithoutHeader = (yi > 0 && !this.headerRows);
@@ -425,6 +445,14 @@ class TableProcessor {
425
445
  this.reservedAtBottom = 0;
426
446
  }
427
447
 
448
+ // Draw horizontal lines before the vertical lines so they are not overridden
449
+ if (willBreak && this.layout.hLineWhenBroken !== false) {
450
+ this.drawHorizontalLine(rowIndex + 1, writer, y2);
451
+ }
452
+ if (rowBreakWithoutHeader && this.layout.hLineWhenBroken !== false) {
453
+ this.drawHorizontalLine(rowIndex, writer, y1);
454
+ }
455
+
428
456
  for (let i = 0, l = xs.length; i < l; i++) {
429
457
  let leftCellBorder = false;
430
458
  let rightCellBorder = false;
@@ -511,13 +539,6 @@ class TableProcessor {
511
539
  }
512
540
  }
513
541
  }
514
-
515
- if (willBreak && this.layout.hLineWhenBroken !== false) {
516
- this.drawHorizontalLine(rowIndex + 1, writer, y2);
517
- }
518
- if (rowBreakWithoutHeader && this.layout.hLineWhenBroken !== false) {
519
- this.drawHorizontalLine(rowIndex, writer, y1);
520
- }
521
542
  }
522
543
 
523
544
  writer.context().page = endingPage;
@@ -556,7 +577,8 @@ class TableProcessor {
556
577
 
557
578
  if (this.dontBreakRows) {
558
579
  const pageChangedCallback = () => {
559
- if (!this.headerRows && this.layout.hLineWhenBroken !== false) {
580
+ if (rowIndex > 0 && !this.headerRows && this.layout.hLineWhenBroken !== false) {
581
+ // Draw the top border of the row after a page break
560
582
  this.drawHorizontalLine(rowIndex, writer);
561
583
  }
562
584
  };