| 115 | } |
| 116 | |
| 117 | private static addExtraContent( |
| 118 | clone: HTMLElement, |
| 119 | options: PrintOptions |
| 120 | ): void { |
| 121 | if (options.title) { |
| 122 | let title = clone.querySelector("title") |
| 123 | if (!title) { |
| 124 | title = document.createElement("title") |
| 125 | clone.appendChild(title) |
| 126 | } |
| 127 | title.textContent = options.title |
| 128 | } |
| 129 | |
| 130 | if (options.append) { |
| 131 | const appendElement = document.createElement("div") |
| 132 | appendElement.innerHTML = options.append |
| 133 | clone.appendChild(appendElement) |
| 134 | } |
| 135 | |
| 136 | if (options.prepend) { |
| 137 | const prependElement = document.createElement("div") |
| 138 | prependElement.innerHTML = options.prepend |
| 139 | clone.insertBefore(prependElement, clone.firstChild) |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | private static printContentInIFrame( |
| 144 | content: string, |