# @rpii/wdio-html-reporter-pdf

> WebdriverIO report add on. Converts HTML formatted report to pdf

Latest version **8.0.7** (published 2024-03-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install @rpii/wdio-html-reporter-pdf
pnpm add @rpii/wdio-html-reporter-pdf
yarn add @rpii/wdio-html-reporter-pdf
bun add @rpii/wdio-html-reporter-pdf
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 8.0.7 |
| Published | 2024-03-08 |
| First published | 2020-08-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 4 |
| Unpacked size | 9.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Rich Peters |
| Maintainers | rpii |
| Keywords | html, reporter, webdriverio, wdio, wdio-plugin, wdio-reporter, wdio-html-reporter, wdio-nice-html-reporter, wdio-html-format-reporter-pdf, pdf |

## Links

- npm: https://www.npmjs.com/package/@rpii/wdio-html-reporter-pdf
- Repository: https://github.com/rpii/wdio-html-reporter-pdf
- Homepage: https://github.com/rpii/wdio-html-reporter-pdf#readme
- Issues: https://github.com/rpii/wdio-html-reporter-pdf/issues
- npm.io page: https://npm.io/package/@rpii/wdio-html-reporter-pdf

## Dependencies (4)

- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [fs-extra](https://npm.io/package/fs-extra.md) ^11.2.0
- [copyfiles](https://npm.io/package/copyfiles.md) ^2.4.1
- [puppeteer](https://npm.io/package/puppeteer.md) 22.4.0

## Alternatives

- [@cantoo/pdf-lib](https://npm.io/package/@cantoo/pdf-lib.md) — 297.9K weekly downloads
- [datatables.net-buttons](https://npm.io/package/datatables.net-buttons.md) — 200.1K weekly downloads
- [@ckeditor/ckeditor5-export-pdf](https://npm.io/package/@ckeditor/ckeditor5-export-pdf.md) — 167.0K weekly downloads
- [scanbot-web-sdk](https://npm.io/package/scanbot-web-sdk.md) — 15.0K weekly downloads
- [@syncfusion/ej2-angular-pdfviewer](https://npm.io/package/@syncfusion/ej2-angular-pdfviewer.md) — 8.8K weekly downloads

## Recent versions

- 8.0.7 (latest) — 2024-03-08
- 8.0.6 — 2024-03-08
- 8.0.5 — 2024-02-19
- 8.0.4 — 2024-02-19
- 8.0.3 — 2024-02-18
- 8.0.2 — 2024-02-18
- 8.0.1 — 2024-02-18
- 8.0.0 — 2023-01-06
- 7.0.4 — 2022-11-04
- 7.0.4-beta2 — 2022-11-04
- 7.0.4-beta — 2022-11-04
- 7.0.3 — 2022-03-19
- 7.0.1 — 2021-07-08
- 7.0.0 — 2021-07-08
- 6.3.1 — 2021-05-26
- … 11 more at https://npm.io/package/@rpii/wdio-html-reporter-pdf/versions

## README

# wdio-html-reporter-pdf
Generate a pdf from an html-report.  
Requires version 8.1.0 or later of wdio-html-nice-reporter to generate the html report
#### Lock the puppeteer version to prevent issues

#### Fixes to render a very large html file

#### Converted to ES Module
    bug fix for expanding sections in new puppeteer


### Updated for module compatibility with webdriver 8
#### Newest Features:

    Upgrade: Set timeout to 0 to prevent timeouts
    Upgrade: update puppeteer version.  
    Upgrade: rewritten in typescript, update puppeteer.  


## Installation

The easiest way is to keep the `@rpii/wdio-html-reporter-pdf` as a devDependency in your package.json:

```javascript
{
  "devDependencies": {
    "@rpii/wdio-html-reporter-pdf": "~7.0.0"
  }
}
```
## Updates

Updated version of puppeteer to get rid of issues.


## Configuration
Add a file called make-pdf.ts in the root of the project.

There are difficulties in puppeteer if you try to integrate the code into wdio.conf.js.

The following code shows a simple way to add as a post build action.  you can invoke it from a pipeline if you are using jenkins.


```javascript / babel

// babel version
const path = require("path") ;
const fs = require("fs-extra") ;

let printPdf = require('@rpii/wdio-html-reporter-pdf').default ;

(async () => {
    let args = process.argv.slice(2) ;
    let reportName = args[0] ? args[0] : "master-report";

    try {

        // need full paths
        let htmlReportFile = path.resolve(__dirname, 'reports/html-reports/' + reportName + '.html');
        let pdfFile = path.resolve(__dirname, 'reports/' + reportName + '.pdf');
        //for linux you will need these options
        let options = ['--no-sandbox', '--disable-gpu', '--disable-extensions'];
        await printPdf(htmlReportFile, pdfFile, options);
    } catch (ex)  {
        console.error(ex);
    }
})();
    
``` 

Add a line to your package.json under scripts
```javascript
    "pdf": "node make-pdf.ts"
``` 
To use an already installed chrome:  Add a line to your package.json under scripts

```javascript
    "pdf-chrome-linux": "node make-pdf.ts /usr/bin/google-chrome"
``` 

## Usage
Run after completing a build.

If you need to specify a path to chrome, that is the fourth parameter.

---
_Source: https://npm.io/package/@rpii/wdio-html-reporter-pdf · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
