What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
If your HTML layout depends on CSS Grid, use PHP to call a browser-based renderer such as headless Chrome or Chromium. PHP-native PDF libraries do not automatically behave like a browser: the cited tc-lib-pdf documentation says it does not implement Grid or flexbox, and Dompdf lists Grid as unsupported. If you must use a PHP-native renderer, build a PDF-specific layout around that library’s supported CSS and inspect the output.
Why the rendering engine matters more than PHP
PHP can prepare HTML, choose a URL or file, and start a conversion. The rendering engine decides how CSS is interpreted. A library that parses HTML and writes a PDF is not necessarily a full browser, so CSS that works in Chrome on screen may not carry over to that library.
| # | Preview | Product | Price | |
|---|---|---|---|---|
| 1 |
|
PDF Explained: The ISO Standard for Document Exchange | $14.41 | Buy on Amazon |
| 2 |
|
Adobe Acrobat 6 PDF For Dummies | $13.00 | Buy on Amazon |
| 3 |
|
Debugging: The 9 Indispensable Rules for Finding Even the Most Elusive Software and Hardware... | $13.39 | Buy on Amazon |
Check whether your page uses display: grid, grid-template-columns, grid-template-areas, or placement rules such as grid-column. If the document’s structure or alignment depends on these rules, treat Grid support as a requirement rather than assuming a PHP PDF library will reproduce the page.
- Keep the existing Grid design: use browser-based PDF rendering and verify the actual document.
- Keep rendering entirely in PHP: choose a library whose supported CSS fits the document, and be prepared to create a simplified PDF layout.
- Either way: test page breaks, fonts, images, and long-content cases; feature support alone does not guarantee that a particular document paginates as intended.
Choose a rendering approach
| Approach | When it fits | Grid considerations |
|---|---|---|
| Headless Chrome or Chromium | You need a browser-based rendering path for existing HTML and CSS. | mPDF’s project guidance points users who need state-of-the-art CSS support and close rendering of existing pages toward headless Chrome. You still need to check the generated PDF. |
| mPDF | You want a PHP HTML-to-PDF library and can tailor the template to its supported behavior. | The project describes mPDF as a Composer-installable PHP library, but calls it dated and says a template tailored for mPDF may be necessary when its rendering differs from the desired result. Do not assume Grid works: mPDF project guidance and its supported CSS manual are the places to check. |
| Dompdf | Your document can be designed within its documented CSS profile. | Dompdf describes support as mostly CSS 2.1 with a handful of CSS3 properties; its README lists Grid as unsupported. See its features page and README. |
| tc-lib-pdf | You want a PHP PDF library and can avoid unsupported layout features or provide an alternate template. | Its documentation explicitly says CSS flexbox and Grid are not implemented. See HTML and CSS support. |
For a browser-based service rather than a browser installed beside your PHP app, the TCPDF comparison describes Gotenberg as an HTTP service running Chromium and LibreOffice. Treat that as an option to investigate in its own documentation; the cited comparison does not establish a specific PHP integration or deployment configuration. TCPDF’s comparison also helps distinguish browser renderers from libraries that write PDFs from PHP.
Free tools Windows power users keep installed
One-click scans. No signup required.
#1 Best Overall
Convert a page with headless Chromium from PHP
This example assumes Chromium is installed on the same machine as PHP and the PHP process can execute it. It converts a URL, which is useful when the HTML and its CSS, fonts, and images are already served by your application. Set CHROME_BIN to the browser executable if it is not on the default path.
- Install Chromium using the package manager or deployment process for your operating system. Confirm the binary path and that it can start under the same user that runs PHP.
- Make the page reachable from that machine. For a private page, arrange appropriate access rather than exposing it publicly.
- Save the following as
render.php, update the URL and output path, and run it with the PHP CLI. - Open the generated PDF and inspect representative short and long pages before relying on the output in production.
<?php
// render.php — requires PHP CLI and an installed Chromium/Chrome executable.
$url = 'https://example.com/report';
$output = __DIR__ . '/report.pdf';
$chrome = getenv('CHROME_BIN') ?: 'chromium';
if (!filter_var($url, FILTER_VALIDATE_URL) || !in_array(parse_url($url, PHP_URL_SCHEME), ['http', 'https'], true)) {
fwrite(STDERR, "URL must be a valid http or https URL.n");
exit(1);
}
$command = escapeshellarg($chrome)
. ' --headless --disable-gpu --no-sandbox'
. ' --no-pdf-header-footer'
. ' --print-to-pdf=' . escapeshellarg($output)
. ' ' . escapeshellarg($url);
exec($command . ' 2>&1', $lines, $status);
if ($status !== 0 || !is_file($output) || filesize($output) === 0) {
fwrite(STDERR, "Chromium failed to create the PDF:n" . implode("n", $lines) . "n");
exit(1);
}
echo "Created {$output}n";
?>
Run it with php render.php. The script quotes arguments to avoid shell parsing of the URL and file path, but it is not a general-purpose job runner: do not accept arbitrary user-supplied URLs or output paths without validation and controls. A renderer that can fetch attacker-chosen URLs may reach internal services or local resources. Also, --no-sandbox disables Chromium’s sandbox; use an appropriately isolated runtime and follow the security guidance for your browser deployment rather than treating that flag as a universal production default.
If your HTML is local, save it to a file and pass its file:// URL instead of an HTTP URL. Be aware that relative CSS, font, and image paths must resolve from that file and remain accessible to the browser process. For repeatable deployments, prefer a controlled application URL or use absolute asset paths. The command-line approach shown here depends on your installed Chromium build and system environment; it is not a guarantee that every browser flag behaves identically across distributions.
Prepare HTML and CSS for print
A browser renderer understands Grid, but a web page is not automatically a well-paginated document. Add print-specific rules for page size, margins, and content that should not split. For example:
@media print {
@page { size: A4; margin: 14mm; }
.screen-only, nav, .toolbar { display: none !important; }
.report-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; }
.card, figure, table { break-inside: avoid; }
h1, h2 { break-after: avoid; }
}
These declarations are an example starting point, not a promise that a given browser version will place every element as you expect. Try realistic content lengths: a short card may fit on one page while a longer one cannot. Inspect whether columns remain legible at print width, whether background colors are needed, and whether a heading is stranded at the bottom of a page.
Rank #2
For reliable output, the browser must be able to load the page’s stylesheets, fonts, images, and data. A page that depends on login state, client-side rendering, or slow network requests may be captured before it is ready unless your conversion setup explicitly handles those conditions. Make the print view deterministic where possible and verify the generated PDF rather than judging only the on-screen page.
Use a PHP-native renderer when its CSS subset fits
If a PHP-only dependency is important, assess the library’s current CSS documentation before committing the template. The tc-lib-pdf documentation states that Grid and flexbox are not implemented. Dompdf’s published feature description is mostly CSS 2.1, and its README says Grid is unsupported. Those documented limits make either a poor assumption-free drop-in for a page whose layout is built around Grid.
mPDF remains a PHP option for HTML-to-PDF work, installed through Composer according to its project documentation. Its own project guidance describes it as dated and recommends headless Chrome when state-of-the-art CSS support and close rendering of existing HTML pages are required. If choosing mPDF, design against its supported CSS guidance and consider a separate HTML template for PDF output instead of trying to force a browser-first Grid design through it.
A PDF-specific template need not duplicate the entire application. It can use simpler block or table-based structure for the renderer, omit interactive controls, and define explicit widths and page-break behavior. Keep the browser page and PDF view driven by the same underlying content where practical, but validate each output path independently.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Test the PDF and diagnose common failures
Run tests using the actual deployment environment and representative pages. The documentation establishes different renderer support profiles; it does not establish that any particular page will render or paginate identically across engines.
Rank #3
- Used Book in Good Condition
| Symptom | Likely cause | What to check |
|---|---|---|
| Grid columns stack or overlap in a PHP library | The selected renderer does not support CSS Grid or the needed Grid behavior. | Check that renderer’s official CSS support. Use a browser renderer to retain Grid, or change to a PDF-specific layout. |
| PDF differs from the browser view | Print styles, page dimensions, font loading, or the renderer’s CSS support differ from the assumptions of the screen layout. | Inspect the PDF at its actual page size; check computed print rules, font and image access, and the target renderer’s documentation. |
| Images or fonts are missing | The conversion process cannot access the asset URL, relative paths resolve differently, or the asset is not ready when rendering occurs. | Use paths accessible to the browser process, check network and authentication requirements, and test the page from the same host and runtime. |
| Content is clipped or split awkwardly | Screen-oriented dimensions or long content do not fit the selected paper size and margins. | Add and refine print-specific page-break rules, then test unusually long text, tables, and repeated elements. |
| PHP reports command failure or no PDF appears | Chromium may be missing, the executable path may be wrong, the PHP user may lack permissions, or the browser may fail to start. | Check CHROME_BIN, executable permissions, the output directory, and the captured command output. Run the browser under the same user and environment as PHP. |
| Output is blank or incomplete | The page may require client-side data or assets that were unavailable when the browser rendered it. | Confirm the URL works from the renderer host, inspect application logs, and make the page’s data and assets ready before conversion. |
For each release, check at least a typical page, a page with the most complex Grid arrangement, a long page, and a page with images or custom fonts. Review text selection and page boundaries in the resulting PDF as well as the visual layout. This validation is implementation guidance, not a claim that a particular library has been tested here.
Or skip the browser setup
If your page is publicly reachable at a URL and you need a screenshot or PDF without installing Chromium beside PHP, ScreenshotNeo provides a website screenshot API. It accepts one URL per GET request and can return PNG, JPEG, WebP, or PDF. For a web page, a one-call cURL request looks like this:
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchescurl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com/report -o report.pdf
See the ScreenshotNeo API documentation for request parameters and response details. ScreenshotNeo accepts cookie or consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each of those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers identify the page verdict and whether the request was billed. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents and MCP clients. It is for capturing a reachable web page, not a replacement for rendering an arbitrary local HTML file that is not hosted at a URL.
Create a free ScreenshotNeo account: the free plan includes 1,000 screenshots a month with no card required; paid plans start at $5 for 3,000.
Sources and support profiles
- tc-lib-pdf: HTML and CSS
- mPDF project repository and guidance
- mPDF supported CSS manual
- Dompdf features and Dompdf README
- TCPDF project comparison of PHP PDF libraries
Frequently Asked Questions
Does PHP itself render CSS Grid into a PDF?
No. PHP is the integration language; the PDF renderer determines how HTML and CSS are interpreted.
Can I use a local HTML file with ScreenshotNeo?
The ScreenshotNeo example captures a URL. A local file that is not hosted at a reachable URL is outside that workflow.
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 →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.

