Module for pdf export
- Description:
Module for pdf export
- Source:
Methods
(static) renderPDF(html, callback, options, puppeteerArgs, remoteContent, allowedOrigins)
- Description:
Function to generate pdf from html
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
html |
string | html text to be converted to html |
callback |
function | callback function after pdf is generated |
options |
object | pdf options, default null |
puppeteerArgs |
object | pupeteer arguments, default null |
remoteContent |
boolean | if it is set base64 string of html content buffer is set as pdf content, default true |
allowedOrigins |
array | origins the document may fetch from, in addition to the configured Countly origin. Anything else is refused. |
(inner) isAllowedRenderUrl(url, origins) → {boolean}
- Description:
Whether a rendered document may fetch the given url.
Split out from the interception handler so the decision can be exercised without launching Chromium: the handler does nothing but call this and continue or abort.
data:, blob: and about: carry no network request anywhere, so they pass through - the document itself is opened as a data: url. Everything else is compared by full origin, and anything that will not parse is refused.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
url |
string | the url the document asked for |
origins |
Set | the allowed origins, from renderOrigins() |
Returns:
true if the request may proceed
- Type
- boolean
(inner) renderOrigins(extra) → {Set}
- Description:
The origins a rendered document is allowed to fetch from.
Rendering runs on the server, so anything the document requests is requested from the server's network position: loopback, the private network, a cloud metadata service. The report templates only ever point at Countly itself, at
hostor at the localhost form the caller builds for exactly that reason, so an allow-list of those costs nothing and closes the rest.Origins are compared as scheme, host and port together. Host alone would be too loose, since Countly is frequently on loopback itself and every other service on that interface would come along with it.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
extra |
array | origins the caller knows it needs, e.g. its public host |
Returns:
the set of allowed origins
- Type
- Set