Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
A “blank PDF” can mean several different failures: a zero-byte download, a valid PDF containing an empty page, a truncated or corrupt file, or an HTML/PHP error that your endpoint mislabeled as application/pdf. Identify which artifact you actually received before changing the template. Then inspect PHP and library errors, input size, output buffering, temporary directories, asset permissions, and renderer limitations in that order.
First, identify what “empty” means
Save the response instead of relying on the browser preview. Record the HTTP status, Content-Type, byte count, and first bytes of the file.
curl -i "https://example.test/export.php?id=42" -o response.bin
wc -c response.bin
xxd -l 16 response.bin
A real PDF normally starts with the ASCII signature %PDF-. Use a PDF parser or desktop viewer to distinguish these cases:
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →- Zero bytes: the application returned nothing, terminated early, or failed before writing the document.
- Valid PDF with a blank page: the renderer ran, but received no usable content or discarded it during layout.
- Corrupt or truncated PDF: output was interrupted, mixed with other bytes, or the process ran out of memory or storage.
- HTML/PHP error saved as a PDF: warnings, an exception page, or a login response was sent with the wrong content type.
Check the PHP-FPM/Apache error log and the application log at the same timestamp. Do not debug only the browser tab: mPDF’s blank-screen guidance notes that script errors and memory exhaustion can produce blank browser output.
#1 Best Overall
- Create a mix using audio, music and voice tracks and recordings.
- Customize your tracks with amazing effects and helpful editing tools.
- Use tools like the Beat Maker and Midi Creator.
- Work efficiently by using Bookmarks and tools like Effect Chain, which allow you to apply multiple effects at a time
- Use one of the many other NCH multimedia applications that are integrated with MixPad.
Use a minimal PHP reproduction
Remove your framework controller, database query, images, and large stylesheet temporarily. Render a known-good document and write it to a file rather than streaming it.
<?php
require __DIR__ . '/vendor/autoload.php';
use MpdfMpdf;
use MpdfConfigConfigVariables;
use MpdfConfigFontVariables;
$temporaryDirectory = __DIR__ . '/var/mpdf-temp';
if (!is_dir($temporaryDirectory) && !mkdir($temporaryDirectory, 0750, true)) {
throw new RuntimeException('Cannot create mPDF temporary directory');
}
$mpdf = new Mpdf(['tempDir' => $temporaryDirectory]);
$mpdf->WriteHTML('<h1>PDF smoke test</h1><p>Renderer is running.</p>');
$mpdf->Output(__DIR__ . '/var/smoke-test.pdf', MpdfOutputDestination::FILE);
clearstatcache(true, __DIR__ . '/var/smoke-test.pdf');
$size = filesize(__DIR__ . '/var/smoke-test.pdf');
if ($size === false || $size < 100) {
throw new RuntimeException('PDF was not written or is unexpectedly small');
}
If this fails, the problem is environmental or library-level, not your business template. If it succeeds, add your real HTML in small increments until the failure returns.
Surface exceptions and PHP errors
In development, enable error reporting and catch the renderer’s exception. In production, log details while returning a generic error to the client; never emit a stack trace into a PDF response.
PC 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 & 11Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minute<?php
ini_set('display_errors', '0');
ini_set('log_errors', '1');
error_reporting(E_ALL);
try {
$mpdf = new MpdfMpdf(['tempDir' => __DIR__ . '/var/mpdf-temp']);
$mpdf->WriteHTML($html);
$bytes = $mpdf->Output('', MpdfOutputDestination::STRING_RETURN);
if (strncmp($bytes, '%PDF-', 5) !== 0) {
throw new RuntimeException('Renderer did not return a PDF signature');
}
header('Content-Type: application/pdf');
header('Content-Disposition: inline; filename="document.pdf"');
header('Content-Length: ' . strlen($bytes));
echo $bytes;
} catch (MpdfMpdfException $e) {
error_log('PDF generation failed: ' . $e->getMessage());
http_response_code(500);
header('Content-Type: application/json');
echo json_encode(['error' => 'PDF generation failed']);
}
Also inspect web-server logs, PHP-FPM logs, container logs, and the process memory limit. A blank response after a fatal error often means the error was logged but never shown to the caller.
Rank #2
Check for output sent before PDF generation
Any notice, warning, debug echo, whitespace before <?php, or included file that prints text can corrupt a streamed PDF. mPDF documents this failure mode on its error-messages page.
- Remove closing PHP tags from PHP-only files.
- Search included files for
echo,var_dump, accidental HTML, and UTF-8 byte-order marks. - Do not send framework middleware output, debug toolbars, or a session warning on the PDF route.
- Clear an intentionally used output buffer only after understanding why it exists.
PHP’s output-buffering manual explains that buffered output is held until flushed. Buffering can be useful, but blindly calling ob_end_clean() may hide a real diagnostic or break middleware. During debugging, log the buffer length and contents rather than silently discarding them.
$level = ob_get_level();
if ($level > 0) {
error_log('Output buffers before PDF: ' . $level);
}
Investigate mPDF’s large-input limit
If a short document works but a long invoice, report, or CSS-heavy page becomes blank or loses sections, test the size of the string passed to WriteHTML(). The mPDF known-issues documentation explains that oversized input can exceed PHP’s PCRE processing limit; a regular-expression operation may return null, leaving blank pages or missing content.
Split HTML and CSS into chunks
$mpdf->WriteHTML($baseCss, MpdfHTMLParserMode::HEADER_CSS);
foreach (array_chunk($sections, 1) as $section) {
$mpdf->WriteHTML($section[0], MpdfHTMLParserMode::HTML_BODY);
}
Chunk at logical boundaries such as a page, table, or repeated report section. Avoid splitting in the middle of a tag. Reproduce with a minimal document, then add one section at a time so you can identify the first input that triggers the limit.
Free tools Windows power users keep installed
One-click scans. No signup required.
Review the PCRE setting carefully
Check the effective value in the same SAPI that runs the request:
<?php
var_dump(PHP_SAPI, ini_get('pcre.backtrack_limit'), ini_get('memory_limit'));
If your hosting policy permits it, raise pcre.backtrack_limit for the worker and retest. A higher limit consumes more CPU and memory; splitting the input is usually safer for repeatable production jobs. Do not assume a setting changed in CLI also applies to PHP-FPM.
Verify temporary storage and permissions
Renderers need scratch space for fonts, images, and intermediate data. mPDF’s temporary-file guidance requires a writable directory and warns against making it world-writable with 777.
- Create a directory outside the public web root, such as
/var/app/mpdf-temp. - Give ownership to the actual PHP-FPM, Apache, or CLI user that runs the job.
- Use restrictive permissions (for example, owner read/write/execute and no public access).
- Confirm free disk space and inode availability.
- Run a smoke test through the same web endpoint, not only from your shell.
In containers, remember that a writable path may be ephemeral. Mount persistent or adequately sized temporary storage when jobs can run concurrently.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Check images, stylesheets, fonts, and remote-resource rules
A PDF can be structurally valid yet appear empty when its visible content depends on blocked assets. Test with plain text first, then add one asset at a time.
Rank #4
- Transform audio playing via your speakers and headphones
- Improve sound quality by adjusting it with effects
- Take control over the sound playing through audio hardware
- Use absolute, correctly encoded local paths and confirm the PHP worker can read them.
- Check HTTPS certificate validation, redirects, authentication, and DNS from the server—not your laptop.
- Confirm that CSS URLs, web fonts, and images are allowed by the renderer’s security settings.
- Log HTTP status and byte size for each downloaded asset; a 200 response containing an HTML login page is not an image.
Dompdf’s usage documentation covers its temporary-directory, remote-resource, and logging options. The current TCPDF HTML/CSS renderer documents local-path and remote-host allowlists at tcpdf.org/docs/html-css/; an unallowed asset may be refused without an exception. Treat those settings as security boundaries rather than enabling unrestricted filesystem or network access.
Compare your HTML/CSS with the renderer’s capabilities
PHP PDF libraries are not full browsers. If text appears but grid, flexbox, sticky elements, filters, or complex responsive rules disappear, reduce the template to the renderer’s supported subset. mPDF describes its CSS support as limited compared with modern browser rendering and points to headless Chrome when reproducing a modern web page is the priority; see the mPDF project README.
Choose the rendering approach against requirements
| Requirement | Question to answer | Implication |
|---|---|---|
| HTML/CSS fidelity | Does the template depend on browser layout or JavaScript? | Consider a headless-browser renderer instead of forcing unsupported CSS through a PHP library. |
| Deployment | Can the target host install and sandbox a browser runtime? | If not, a PHP renderer may be operationally simpler. |
| Asset access | Are local files, private URLs, or authenticated resources required? | Design an explicit allowlist and credential strategy. |
| Document features | Do you need page ranges, headers, footers, fonts, or special pagination? | Validate those features with a representative document before migrating. |
There is no universal best library. Fix PHP errors, permissions, and invalid responses before changing renderers; a browser engine will not repair a broken endpoint.
A repeatable diagnostic checklist
- Capture status, content type, byte count, and the first bytes of the response.
- Write a minimal PDF to disk and verify it independently of HTTP streaming.
- Enable logging, catch library exceptions, and inspect PHP-FPM/web-server logs.
- Remove all output before generation and audit buffering.
- Compare small and large inputs; inspect PCRE and memory limits for mPDF.
- Verify the temp directory, ownership, permissions, disk space, and runtime user.
- Test text, CSS, local assets, then remote assets separately.
- Reduce unsupported CSS or evaluate a headless-browser approach when browser fidelity is essential.
- Restore the production template incrementally and keep the smallest failing fixture as a regression test.
Or skip the browser setup
If your actual goal is a screenshot or PDF of a web page rather than server-side PHP template rendering, ScreenshotNeo provides a single website-screenshot API request. It accepts consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; bot checks/CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing result.
It also offers an MCP server for Claude, Cursor, and other MCP clients, with take_screenshot, get_page_info, and capture_pdf tools. Options include full-page lazy-image capture, CSS-selector element capture, dark mode, device presets or custom viewports, retina scale, PDF paper and margin controls, custom CSS/JavaScript, click and wait conditions, request blocking, headers/cookies/user agents, timezone and geolocation, transparent backgrounds, resizing, chosen cache TTLs, signed links, asynchronous webhooks, bulk capture for up to 100 URLs per call, usage reporting, and an OpenAPI specification.
cURL
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Python
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)
Node.js
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const fs = await import('node:fs/promises');
await fs.writeFile('shot.webp', Buffer.from(await res.arrayBuffer()));
See the parameter reference and output details in the ScreenshotNeo documentation. Every feature is included on every plan: 1,000 screenshots per month are free with no card, Starter is $5 for 3,000, and yearly billing provides two months free. Create a free ScreenshotNeo account to try it.
Best Value
- Full-featured professional audio and music editor that lets you record and edit music, voice and other audio recordings
- Add effects like echo, amplification, noise reduction, normalize, equalizer, envelope, reverb, echo, reverse and more
- Supports all popular audio formats including, wav, mp3, vox, gsm, wma, real audio, au, aif, flac, ogg and more
- Sound editing functions include cut, copy, paste, delete, insert, silence, auto-trim and more
- Integrated VST plugin support gives professionals access to thousands of additional tools and effects
Common symptoms and targeted fixes
| Symptom | Likely boundary | Next action |
|---|---|---|
| Zero-byte file | Fatal error, aborted process, or unwritable destination | Check logs, temp/storage permissions, disk space, and exception handling. |
| HTML appears when opened as PDF | Error or authentication response mislabeled as PDF | Inspect status and content type; return JSON/HTML errors separately. |
| Small documents work; large ones do not | PCRE, memory, or request timeout | Measure input, split WriteHTML() calls, and review limits. |
| Text is present but images are missing | Asset path, network, or allowlist failure | Test each URL from the server and configure narrowly scoped access. |
| Layout collapses but PDF opens | Unsupported CSS or browser-only behavior | Reduce CSS or select a renderer designed for browser fidelity. |
| Intermittent corruption | Concurrent temp-file collisions, output contamination, or resource exhaustion | Use isolated writable temp storage, remove prior output, and monitor memory and disk. |
FAQ
Why is the browser blank but the downloaded file valid?
Browser viewers can fail to display a valid file because of caching, an incomplete response, or viewer limitations. Save the response and validate its PDF signature and page structure with an independent viewer or parser.
Recommended Free Tools
Should I enable PHP error display on a production PDF endpoint?
No. Log errors server-side and return a correctly typed error response. Displayed warnings become bytes in the PDF stream and can expose sensitive data.
Can increasing memory or PCRE limits guarantee a fix?
No. Those changes help only when the corresponding limit is the failure boundary. Confirm with a minimal reproduction and logs, then prefer smaller chunks and simpler input where practical.
When is a headless browser the wrong choice?
It may be unsuitable when the host cannot install or sandbox a browser, when startup cost is unacceptable, or when a simpler PHP renderer already meets your pagination and CSS needs.
Frequently Asked Questions
How do I tell whether a PDF is empty or actually an HTML error?
Check the HTTP status, Content-Type, byte count, and first bytes. A PDF begins with %PDF-; an HTML error usually begins with markup or an error message.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problemsWhat is the safest way to debug output corruption?
Write the PDF to a file first, log exceptions, and audit warnings, debug output, whitespace, and output buffers before streaming it.
Does ScreenshotNeo replace a PHP HTML-to-PDF library?
It is an alternative for capturing an existing web page as an image or PDF through an API; it does not fix a PHP template renderer that is failing inside your application.
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.

