Skip to content

Implement Webdriver#88

Open
TheSyscall wants to merge 44 commits intomainfrom
webdriver
Open

Implement Webdriver#88
TheSyscall wants to merge 44 commits intomainfrom
webdriver

Conversation

@TheSyscall
Copy link

@TheSyscall TheSyscall commented Mar 13, 2026

Changes

  • Removed ReactPHP dependency
    The module no longer relies on ReactPHP, as such it no longer provides the asynchronous methods to generate PDFs that were never part of the Hook

  • Introduced backend abstraction
    A new backend concept allows different rendering strategies to be plugged in and extended more easily.

  • Added WebDriver support
    Implemented a WebDriver-based backend with support for Chrome and Firefox.

  • Automatic backend fallback
    If a backend fails or is unavailable, the system now automatically falls back to the next available option. (The order of this is currently hardcoded as Webdriver > Remote Chrome > Local Chrome)

  • New configuration form
    Replaced the existing configuration with a new ipl\Web\Compat\Form-based ConfigForm.

requires Icinga/ipl-web#358

WebDriver

This module can be configured to connect to a webdriver instance. (Backend)

When a PDF is requested, via the Print PDF button on any site or the one in the reporting module, it sends commands to the WebDriver server in a standardized format.

Each browser has its own driver (like ChromeDriver for Chrome or GeckoDriver for Firefox).
This driver acts as a bridge between your script and the browser.

Browser
The driver sends commands to the browser, which executes them just like a user interaction.

For this to work we require a working chromedriver or geckodriver (firefox) instance.

Adding this this to a docker compose file will spin up one for each of the supported webdrivers.

  selenium-chrome:
    image: selenium/standalone-chrome
    container_name: selenium-chrome
    ports:
      - "4444:4444"
    shm_size: '2gb'
    restart: always

  selenium-firefox:
    image: selenium/standalone-firefox
    container_name: selenium-firefox
    ports:
      - "4445:4444"
      - "7900:7900"
    shm_size: '2gb'
    restart: always

Currently supported features:

Backend Generate PDF Layout Plugins Merge PDF (Coverpage) Coverpage Layout Header/Footer
HeadlessChrome Remote (Legacy) Yes Yes Yes Yes Yes
HeadlessChrome Local (Legacy) Yes Yes Yes Yes Yes
Chromedriver Yes Yes Yes No Yes
Geckodriver Yes No No No No

Known issues

  • Firefox seems to generate compressed PDFs and the TCPDF library we use https://github.com/karriereat/pdf-merge seems to not handle the deflate process properly.
  • Chromedriver reports an error with the coverpage properties.
(
x   [error] => invalid argument
   [message] => invalid argument: params not passed
   (Session info: chrome=145.0.7632.116)
   [stacktrace] => #0 0x55aaccc62b6a <unknown>
#1 0x55aacc675a32 <unknown>
#2 0x55aacc71fcee <unknown>
#3 0x55aacc713369 <unknown>
#4 0x55aacc6bcc0f <unknown>
#5 0x55aacc6bd9d1 <unknown>
#6 0x55aaccc276b9 <unknown>
#7 0x55aaccc2a5c1 <unknown>
#8 0x55aaccc13e29 <unknown>
#9 0x55aaccc2b17e <unknown>
#10 0x55aaccbfa4b0 <unknown>
#11 0x55aaccc4f578 <unknown>
#12 0x55aaccc4f74b <unknown>
#13 0x55aaccc611a3 <unknown>
#14 0x7fc8d9558aa4 <unknown>
#15 0x7fc8d95e5a64 __clone
)

ReactPHP event loop, promise and child process have been removed and
replaced with native PHP io stream functions
This allows us to set headers and footers
This fixes an issue where the webdriver server is never closed because
PDF merging causes OOM.
Relicense this module to `GPL-3.0-only`.
Add `GPL-3.0-or-later` SPDX license headers to source files, allowing
relicensing under future GPL versions. This ensures compatibility with
third-party dependencies (e.g. `Apache-2.0`) incompatible with
`GPL-2.0-only`.
@cla-bot cla-bot bot added the cla/signed label Mar 13, 2026
@TheSyscall TheSyscall self-assigned this Mar 19, 2026
@TheSyscall TheSyscall marked this pull request as ready for review March 19, 2026 08:26
@TheSyscall TheSyscall requested a review from Al2Klimov March 19, 2026 08:26
Copy link
Member

@Al2Klimov Al2Klimov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do either of the following:

  • update doc/
  • write a comment under this PR as a quick doc/ substitute, given your changes

I have no plan of all this, so I must set this up from scratch to review.

@TheSyscall
Copy link
Author

TheSyscall commented Mar 19, 2026

If you use docker you can just use the two services provided in the PR description.
The only other configuration apart from this is to go to the module's configuration page and add the host + port to the webdriver server.

To test the legacy chrome backend, just follow the existing documentation.

The PdfExport module allows you to create PDFs of any page in IW2, it is also used to create reports with a custom cover page in the reporting module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants