-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathprint.js
74 lines (64 loc) · 2.31 KB
/
print.js
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/**
* Some notes:
* - Prince cant grok trailing commas, so prettier is disabled anywhere it tries to enforce wrapping with trailing comma
* - Prince doesn't support template strings yet
* - Set Prince.trackboxes to true for advanced debugging, see https://www.princexml.com/doc/cookbook/#how-and-where-is-my-box
* */
/* eslint-disable no-undef */
'use strict';
// Prince.trackBoxes = true;
const shortname = document.querySelector('h1.shortname');
const version = document.querySelector('h1.version');
rearrangeTables();
PDF.pageLayout = 'two-column-right';
PDF.pageMode = 'show-bookmarks';
PDF.duplex = 'duplex-flip-long-edge';
PDF.title = document.title;
PDF.author = 'Ecma International';
PDF.subject = shortname.innerHTML + (version ? ', ' + version.innerHTML : '');
/**
* Sets up table captions and figcaptions for tables, which provides for
* continuation table captions.
* */
function rearrangeTables() {
const tables = Array.from(document.getElementsByTagName('emu-table'));
tables.forEach(emuTable => {
const figcaption = emuTable.getElementsByTagName('figcaption')[0];
const tableCaptionText = figcaption.innerHTML;
const table = emuTable.getElementsByTagName('table')[0];
const captionElement = document.createElement('caption');
captionElement.innerHTML = tableCaptionText;
table.insertBefore(captionElement, table.getElementsByTagName('thead')[0]);
table.appendChild(figcaption);
});
}
/**
* @typedef {Object} PrinceBox
* @property {string} type
* @property {number} pageNum
* @property {number} x
* @property {number} y
* @property {number} w
* @property {number} h
* @property {number} baseline
* @property {number} marginTop
* @property {number} marginBottom
* @property {number} marginLeft
* @property {number} marginRight
* @property {number} paddingTop
* @property {number} paddingBottom
* @property {number} paddingLeft
* @property {number} paddingRight
* @property {number} borderTop
* @property {number} borderBottom
* @property {number} borderLeft
* @property {number} borderRight
* @property {string} floatPosition "TOP" or "BOTTOM"
* @property {PrinceBox[]} children
* @property {PrinceBox} parent
* @property {Element|null} element
* @property {string|null} pseudo
* @property {string} text
* @property {string} src
* @property {CSSStyleSheet} style
* */