pdfmake 0.2.2 → 0.2.3

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.
@@ -0,0 +1,3 @@
1
+ var SVGtoPDF = require('./svg-to-pdfkit/source.js');
2
+
3
+ module.exports = SVGtoPDF;
@@ -24,20 +24,15 @@ function Document(docDefinition, tableLayouts, fonts, vfs) {
24
24
 
25
25
  function canCreatePdf() {
26
26
  // Ensure the browser provides the level of support needed
27
- try {
28
- var arr = new Uint8Array(1)
29
- var proto = { foo: function () { return 42 } }
30
- Object.setPrototypeOf(proto, Uint8Array.prototype)
31
- Object.setPrototypeOf(arr, proto)
32
- return arr.foo() === 42
33
- } catch (e) {
34
- return false
35
- }
36
-
37
- if (!Object.keys || typeof Uint16Array === 'undefined') {
38
- return false;
27
+ try {
28
+ var arr = new Uint8Array(1)
29
+ var proto = { foo: function () { return 42 } }
30
+ Object.setPrototypeOf(proto, Uint8Array.prototype)
31
+ Object.setPrototypeOf(arr, proto)
32
+ return arr.foo() === 42
33
+ } catch (e) {
34
+ return false
39
35
  }
40
- return true;
41
36
  }
42
37
 
43
38
  Document.prototype._createDoc = function (options, cb) {
package/src/helpers.js CHANGED
@@ -97,6 +97,17 @@ function getNodeId(node) {
97
97
  return null;
98
98
  }
99
99
 
100
+ function isPattern(color) {
101
+ return isArray(color) && color.length === 2;
102
+ }
103
+
104
+ // converts from a [<pattern name>, <color>] as used by pdfmake
105
+ // into [<pattern object>, <color>] as used by pdfkit
106
+ // (the pattern has to be registered in the doc definition of course)
107
+ function getPattern(color, patterns) {
108
+ return [patterns[color[0]], color[1]];
109
+ }
110
+
100
111
  module.exports = {
101
112
  isString: isString,
102
113
  isNumber: isNumber,
@@ -109,5 +120,7 @@ module.exports = {
109
120
  pack: pack,
110
121
  fontStringify: fontStringify,
111
122
  offsetVector: offsetVector,
112
- getNodeId: getNodeId
123
+ getNodeId: getNodeId,
124
+ isPattern: isPattern,
125
+ getPattern: getPattern
113
126
  };