forked from parallax/jsPDF
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautoprint.js
More file actions
38 lines (33 loc) · 865 Bytes
/
Copy pathautoprint.js
File metadata and controls
38 lines (33 loc) · 865 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* jsPDF Autoprint Plugin
*
* Licensed under the MIT License.
* http://opensource.org/licenses/mit-license
*/
/**
* Makes the PDF automatically print. This works in Chrome, Firefox, Acrobat
* Reader.
*
* @returns {jsPDF}
* @name autoPrint
* @example
* var doc = new jsPDF()
* doc.text(10, 10, 'This is a test')
* doc.autoPrint()
* doc.save('autoprint.pdf')
*/
(function (jsPDFAPI) {
'use strict';
jsPDFAPI.autoPrint = function () {
'use strict'
var refAutoPrintTag;
this.internal.events.subscribe('postPutResources', function () {
refAutoPrintTag = this.internal.newObject()
this.internal.write("<< /S/Named /Type/Action /N/Print >>", "endobj");
});
this.internal.events.subscribe("putCatalog", function () {
this.internal.write("/OpenAction " + refAutoPrintTag + " 0" + " R");
});
return this;
};
})(jsPDF.API);