@paprize/puppeteer
openReport()
openReport(
page,reportUrl,jsonData,timeout):Promise<void>
Defined in: openReport.ts:21
Opens a report in the given Puppeteer page, injects a JSON data file if provided, and waits for the report to be ready.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
page | Page | undefined | The Puppeteer Page instance where the report will be opened. |
reportUrl | URL | undefined | The URL of the report to be opened. |
jsonData | string | undefined | undefined | Optional JSON data as a string to be injected into the page. |
timeout | number | 30000 | The maximum time to wait for the report to be ready, in milliseconds. Defaults to 30,000 ms. |
Returns
Promise<void>
A promise that resolves when the report is ready.
Throws
Will throw an error if the report does not become ready within the specified timeout.
pageToPdf()
pageToPdf(
page,options?):Promise<Uint8Array<ArrayBufferLike>>
Defined in: pageToPdf.ts:12
Generates a PDF from the given Puppeteer Page instance using the specified options.
Parameters
| Parameter | Type | Description |
|---|---|---|
page | Page | The Puppeteer Page instance to generate the PDF from. |
options? | ReportOptions | Optional additional options to customize the PDF generation. These options will be merged with the default settings. |
Returns
Promise<Uint8Array<ArrayBufferLike>>
A promise that resolves to a Uint8Array containing the generated PDF data.
reportToPdf()
reportToPdf(
page,reportUrl,jsonData?,pdfOptions?):Promise<Uint8Array<ArrayBufferLike>>
Defined in: reportToPdf.ts:15
Generates a PDF from a report by navigating to the specified report URL and optionally sending JSON data to the page.
Parameters
| Parameter | Type | Description |
|---|---|---|
page | Page | The Puppeteer Page instance used to interact with the report. |
reportUrl | URL | The URL of the report to be converted to a PDF. |
jsonData? | string | Optional JSON data to be sent to the report page. |
pdfOptions? | PDFOptions | Optional configuration for generating the PDF, including timeout and other settings. |
Returns
Promise<Uint8Array<ArrayBufferLike>>
A promise that resolves to a Uint8Array containing the generated PDF data.
serveReport()
serveReport(
dir,port?):Promise<ReportServer>
Defined in: serveReport.ts:23
Serves a static report from the specified directory over HTTP.
Parameters
| Parameter | Type | Description |
|---|---|---|
dir | string | The directory containing the static files to serve. |
port? | number | Optional. The port on which the server will listen. If not provided, a random available port will be used. |
Returns
Promise<ReportServer>
A promise that resolves to a ReportServer object, which provides methods to close the server and retrieve its host URL.
The server serves files from the specified directory and automatically rewrites requests
to /index.html for any unmatched routes. Subdirectories in the specified directory are
mapped to corresponding routes.