To run page JavaScript before creating a PDF in PHP, use Chrome or Chromium controlled from PHP. A PHP PDF library’s setting for fetching remote images or CSS does not make that library execute JavaScript like a browser. Dompdf explicitly distinguishes its PDF-embedded JavaScript option from parsing page JavaScript. If the page can be rendered into static HTML first, a PHP PDF library may still fit; if its content or layout depends on scripts, use a browser engine.
Why enabling remote resources does not load page JavaScript
There are two different operations that are easy to confuse:
- Fetching remote resources: downloading items such as images and stylesheets referenced by HTML.
- Executing page JavaScript: running scripts in a browser-like environment so they can change the document before it is printed.
Dompdf’s isRemoteEnabled setting concerns web-based resources such as images and CSS. Its isJavascriptEnabled option concerns JavaScript embedded in the resulting PDF; it does not turn Dompdf into a browser that parses and runs the page’s scripts. Enabling either setting is therefore not a substitute for a JavaScript-capable renderer.
This distinction matters for pages that populate a chart after load, build a table from an API response, render a client-side application, or otherwise change after the initial HTML arrives. A renderer that only receives the initial markup may produce a PDF with missing or incomplete content even when it can fetch the page’s CSS and images.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11#1 Best Overall
- INNOVATIVE CARTRIDGE-FREE PRINTING — No more dealing with lots of tiny ink cartridges; With this wireless document and photo printer each ink bottle set is equivalent to about 90 individual cartridges²
- LESS FREQUENT INK REPLACEMENT — Replacement ink bottles don't have to be changed nearly as often as ink cartridges¹; When you choose this combination printer, scanner and copier you can print up to 4,500 pages black/7,500 color³
- COLOR PRINTING — Up to 2 years of ink in the box4 (and with every replacement ink set) for fewer out-of-ink frustrations
- ZERO CARTRIDGE WASTE — By using an Epson EcoTank printer you can help reduce the amount of cartridge waste ending up in landfills
- HOME PRINTER DESIGNED FOR RELIABILITY — The Epson EcoTank ET-2800 All-in-One Supertank Color Printer creates vivid, detailed prints and documents thanks to Micro Piezo Heat-Free Technology; Fire off 10 ISO pages per minute1 to easily finish large jobs
Choose the renderer based on what the PDF must contain
| Approach | JavaScript behavior | Best fit | Trade-offs |
|---|---|---|---|
| Dompdf | Does not parse page JavaScript as a browser. Its JavaScript option is for scripts embedded in the PDF. | HTML and CSS that are already complete without browser-side scripts. | Remote resources require the appropriate configuration and PHP support; CSS and layout support have limitations. Check the project documentation for the version in your application. |
| mPDF | Use it as a PHP HTML-to-PDF renderer, not as a browser for executing page scripts. | HTML/CSS prepared for an mPDF workflow. | The project manual describes the software as dated and says a template tailored to mPDF may be necessary. It recommends headless Chrome for modern CSS support or mirroring existing HTML pages. |
| Chrome or Chromium controlled from PHP | Runs page JavaScript in a browser engine; the chrome-php/chrome project documents adding a script tag by URL and producing a PDF. |
Pages whose content or appearance depends on scripts, or pages that need browser rendering. | Requires a Chrome or Chromium runtime as well as PHP-side browser control. You must choose suitable waits and account for browser resource use and security. |
The TCPDF project’s comparison page reports versions, licenses, and PHP requirements checked on 2026-08-31. Treat those details as a dated snapshot, not as timeless compatibility guidance.
Load a script URL and save a PDF with PHP-controlled Chrome
The chrome-php/chrome README documents creating a page, navigating to a URL or setting its HTML, adding a script tag using a URL, waiting for a response, and saving PDF output. The core documented calls for adding the script and saving the PDF are:
<?php
$page->addScriptTag([
'url' => 'https://example.com/script.js'
])->waitForResponse();
$page->pdf()->saveToFile('/path/output.pdf');
This is the project’s documented API shape for those operations; it is not a complete standalone script because the page must first be created and loaded or populated with HTML. Use the project’s current setup and API documentation for browser creation, navigation, waiting, and cleanup. The README also lists Chrome or Chromium as a runtime requirement. Confirm the package’s current PHP and browser compatibility before deploying it.
Use the correct page before injecting the script
For an existing website, navigate the browser-controlled page to the URL you intend to print, then add the external script. For content you generate in PHP, set the page’s HTML first and add the script after that. The script URL must be reachable from the browser process, not merely from a developer’s workstation. If the script depends on other files or services, those requests also need to succeed in the deployment environment.
Rank #2
- CARTRIDGE-FREE PRINTING — Print lab-quality photos, graphics and creative projects; Get vibrant colors and sharp text with Epson's high-accuracy printhead and Claria ET Premium 6-color inks
- INK BOTTLES — Save on photos1 and creative projects with affordable in-house printing; All-in-one printer allows you to print 4" x 6" photos for about 4 cents each vs. 40 cents with traditional ink cartridges1
- LESS FREQUENT INK REPLACEMENT — Replacement ink bottles don't have to be changed nearly as often as ink cartridges¹; Printer, scanner and copier lets you print up to 6,200 color pages³
- PRINT FOR LONGER — Up to 2 years of ink in the box² (and with every replacement ink set) for fewer out-of-ink frustrations with this wireless printer
- ZERO CARTRIDGE WASTE — Epson EcoTank printer helps reduce the amount of cartridge waste ending up in landfills; Cartridge-free printer uses high-yield ink bottles; Each replacement ink bottle set is equivalent to about 100 individual ink cartridges⁴
Wait for the condition your page actually needs
Adding a script tag and receiving a response does not necessarily mean the page has finished all its work. The package documents load, interactive, and network-idle wait events. Its README describes network idle as no network activity for at least 500 ms. That is package guidance, not a guarantee that every asynchronous application is finished: a page may update later, poll a service, or keep network connections open.
Choose a wait based on the content. If the PDF requires a particular chart or table, wait for a selector that identifies that element where the package’s current API supports it. If completion depends on a known script response, wait for that response and then verify the page state. Use a delay only when you have a known timing reason; a fixed delay can be either wastefully long or too short.
Check remote access, browser access, and security
Remote resources in a PHP renderer
If the page is static and you use Dompdf, its usage documentation says web-based resources require isRemoteEnabled and PHP cURL or allow_url_fopen. That setting allows resource fetching; it does not execute page JavaScript. Keep the distinction clear when diagnosing missing content.
Remote scripts in Chrome or Chromium
With a browser engine, the script’s origin, network path, authentication requirements, and content-security policy can affect whether it loads. The cited package documentation does not guarantee behavior for every CDN, CSP, authentication flow, or dynamically updating page. Test the actual script and target site from the same environment that will generate production PDFs.
Recommended Free Tools
Rank #3
- SET IT UP ONCE AND PRINT WITH CONFIDENCE. No complicated maintenance. Just easy, reliable printing you can count on.
- INK FOR YEARS. NOT MONTHS. Up to 2 years of ink included. Get thousands of pages of cartridge-free printing. More pages, less hassle
- KEEPS PRINTING WELL AFTER COMPETITORS HAVE QUIT. No complex maintenance. Sharper text, richer colors.[2] Only with HP Smart Tank
- PREMIUM SUPPORT - Strong technical expertise to solve issues faster
- THE LAST PRINTER YOU'LL EVER NEED. Enjoy years of refillable, cartridge-free printing.
Do not treat HTML-to-PDF input as harmless
Rendering can expose server resources to untrusted input. Dompdf warns that enabling embedded PHP for untrusted or user-supplied documents can run code with the renderer’s system access. The mPDF manual likewise warns against accepting outside-user HTML/CSS without rigorous vetting and sanitization. Restrict who can submit HTML, avoid enabling embedded PHP for untrusted documents, and apply appropriate isolation and network controls to the rendering process.
Troubleshoot missing or incomplete PDF content
| Symptom | Likely cause | What to check |
|---|---|---|
| The PDF omits content created by JavaScript. | A non-browser PHP renderer received the page before scripts populated it. | Use Chrome or Chromium for execution, or produce final static HTML before conversion. |
| Images or CSS are missing in Dompdf output. | Remote fetching is disabled, or PHP lacks the required cURL or allow_url_fopen support. |
Check isRemoteEnabled and the PHP runtime configuration. Remember this will not enable JavaScript execution. |
| The external script does not run. | The browser process cannot fetch the script, the URL is incorrect, or site policy/authentication blocks it. | Test reachability from the deployed browser environment and inspect the page’s actual load behavior and policy. |
| The PDF starts rendering before charts or data appear. | The chosen wait only establishes a navigation or network condition, not application completion. | Wait for a page-specific element or verified completion condition, then create the PDF. |
| The application works locally but fails after deployment. | Chrome/Chromium may be absent, incompatible, or unable to access required network resources in the server environment. | Verify the runtime installation, package compatibility, permissions, network access, and cleanup behavior on the deployment host. |
| Rendering user-provided HTML creates a security concern. | HTML, embedded PHP, scripts, or remote resource references may reach capabilities or systems they should not. | Vet and sanitize inputs, disable risky execution features, and isolate the rendering service with least privilege and appropriate network restrictions. |
Performance, reliability, and operating cost
Browser-based rendering gives you browser JavaScript behavior, but it also means operating a browser runtime alongside PHP. Plan for browser startup, page load, script execution, PDF generation, and cleanup in each job. The source documentation provides no benchmark or universal runtime figure, so measure the pages and deployment conditions that matter to your application rather than assuming a fixed completion time.
Reliability depends on the page as well as the renderer. External scripts, APIs, fonts, and images can fail or respond slowly; a network-idle condition may never occur if requests continue. Prefer an explicit application-ready condition when possible, give the job a bounded timeout, and record enough diagnostics to distinguish navigation failures from missing page content. For repeatable output, control the HTML, script version, viewport and page state used by the capture.
Resource use and security boundaries matter more when rendering many documents or accepting external URLs. Browser processes need appropriate memory and CPU headroom, and a renderer that can reach remote URLs should not be allowed to fetch arbitrary internal services. The cited documentation does not specify a universal hosting size or cost; evaluate those against your workload and isolation requirements.
Rank #4
- Wireless Bluetooth Printer: Portable thermal printer compatible with iPhone, Android phones, iPad and tablet computers via Bluetooth. For smartphones, please download the "Nada Print" App. You can also connect to laptops and computers for printing using a USB-C cable. (Note: Laptops and computers can only be connected via USB and require the installation of a driver first. Bluetooth connection is not supported.)
- No-ink printing: Only supports US Letter and A4 size thermal paper.(Doesn't support regular paper) The no-ink portable thermal printer uses direct thermal technology, requiring no ink, toner or ribbons, making it environmentally friendly, cost-effective and time-saving. The thermal printer package comes with a roll of US Letter thermal printing paper. Note: When installing the paper, remember to switch the paper size switch on APP
- Clear Print: NDYIN N80 portable thermal printer adopts high-definition printing technology, with a 203DPI resolution to provide you with clear printing results. This mobile printer is compatible with roll paper, folded paper and tattoo transfer paper, supporting printing from your mobile phone PDF, Word, pictures and web pages anytime and anywhere. It is recommended to use our NDYIN thermal paper to achieve good printing quality
- Portable wireless printer for travel: The thermal printer is equipped with a built-in 1500mAh rechargeable battery, which can print 160 sheets of 8.5" x 11" thermal paper after being fully charged. It weighs only 1.5 pounds and is compact in size. This ink-free portable printer can be easily carried in a backpack or briefcase! It is perfect for business travel, cars, small offices, construction sites, schools and homes. You can print documents, contracts, invoices and boarding passes anytime and anywhere
- The N80 thermal printer has a wide range of uses. The package includes the N80 printer, a roll of US Letter paper(7m/roll), a user manual, a guide card, a type-C soft cable and a type C adapter. Note: The charging adapter is not included. Special thermal paper is required for use; ordinary paper cannot be used. This ink-free portable thermal printer is suitable for various scenarios such as home, school, travel, office, and outdoor, meeting the printing needs of different groups of people. This tattoo template printer is also compatible with tattoo transfer paper, making it an ideal choice for tattoo art
Or skip the browser setup
If your immediate need is to capture a live URL as an image or PDF rather than build a PHP-managed browser workflow, ScreenshotNeo offers a website screenshot API and MCP server. Its options include PDF output and custom JavaScript, but it is a capture service, not a drop-in PHP library; check the API documentation for the supported request parameters and format.
Example cURL request (the supplied example returns a WebP screenshot):
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
See the ScreenshotNeo API documentation for setup and request options. Cookie banners, popups, and chat widgets are removed before the shot; bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots a month with no card, and paid plans start at $5 for 3,000. Sign up for the free plan.
Frequently Asked Questions
Does Dompdf’s JavaScript option execute a remote page script before PDF creation?
No. Dompdf says that option does not make it parse page JavaScript like a web browser.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →What does Chrome’s network-idle wait mean in the chrome-php documentation?
The README describes network idle as no network activity for at least 500 ms; it is not proof that every application-specific asynchronous update is complete.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




