The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
Make the checked state part of the HTML you pass to Dompdf, then draw the mark with supported generated content. A browser’s live checkbox property is not available to Dompdf, and native form-control painting is unreliable in a PDF. Emit checked="checked" in the source, use the Unicode box glyphs U+2610 (☐) and U+2611 (☑), and select a font such as DejaVu Sans that contains them.
The reliable implementation
Dompdf is a CSS-driven HTML-to-PDF renderer. It lays out the HTML string supplied to loadHtml(); it does not run browser JavaScript to inspect a user’s current checkbox state. Your application therefore has to serialize the state into the HTML before rendering.
This minimal document renders an empty or checked square as text rather than relying on a browser control:
Recommended Free Tools
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<style>
input[type="checkbox"] {
display: inline-block;
font-family: "DejaVu Sans" !important;
font-size: 18px;
line-height: 1;
}
input[type="checkbox"]:before {
content: "\2610";
}
input[type="checkbox"][checked]:before {
content: "\2611";
}
</style>
</head>
<body>
<label class="checkline">
<input type="checkbox" name="terms" checked="checked">
Terms accepted
</label>
</body>
</html>
The important details are the literal checked attribute, the attribute selector [checked], and the explicit font and Unicode escapes. Dompdf’s own default stylesheet uses the same approach.
#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
Complete PHP example
Generate the attribute from your application value, not from a JavaScript-only change made in a browser. Escape every user-facing label before inserting it into the document.
<?php
require __DIR__ . '/vendor/autoload.php';
use DompdfDompdf;
use DompdfOptions;
$termsAccepted = (bool) ($record['terms_accepted'] ?? false);
$marketingOptIn = (bool) ($record['marketing_opt_in'] ?? false);
function checkbox(bool $checked, string $name, string $label): string
{
$attribute = $checked ? ' checked="checked"' : '';
return sprintf(
'<label class="checkline"><input type="checkbox" name="%s"%s> %s</label>',
htmlspecialchars($name, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'),
$attribute,
htmlspecialchars($label, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8')
);
}
$html = '<!doctype html><html><head><meta charset="utf-8">
<style>
.checkline { display: block; margin: 0 0 8px; }
input[type="checkbox"] {
display: inline-block;
font-family: "DejaVu Sans" !important;
font-size: 18px;
line-height: 1;
}
input[type="checkbox"]:before { content: "\2610"; }
input[type="checkbox"][checked]:before { content: "\2611"; }
</style></head><body>'
. checkbox($termsAccepted, 'terms', 'Terms accepted')
. checkbox($marketingOptIn, 'marketing', 'Send me product updates')
. '</body></html>';
$options = new Options();
$options->set('isHtml5ParserEnabled', true);
$dompdf = new Dompdf($options);
$dompdf->loadHtml($html, 'UTF-8');
$dompdf->setPaper('A4', 'portrait');
$dompdf->render();
$dompdf->stream('form.pdf', ['Attachment' => false]);
If a value is unknown, choose a deliberate policy. Treating a missing value as unchecked is usually safer than marking a legal acceptance as checked. For compliance records, preserve the original value and timestamp separately from the visual PDF.
Why a checked box is blank in the PDF
The browser state was never serialized
HTML has a checked attribute, while the DOM also has a live checked property. JavaScript can set the property without changing the original HTML attribute. If your server later submits or stores a template that still lacks checked, Dompdf correctly sees an unchecked input. Build the final string on the server and inspect it immediately before loadHtml().
Free tools Windows power users keep installed
One-click scans. No signup required.
Native controls are not a dependable PDF drawing primitive
Browsers paint checkbox widgets as platform controls. Dompdf instead applies its supported CSS and layout engine. The portable solution is generated text containing box glyphs, not a platform-specific control appearance.
The glyph is missing from the font
A square or an empty space usually means the selected font does not contain U+2610 or U+2611. DejaVu Sans is available with Dompdf and provides the coverage used by its built-in checkbox rule. If you use another family, verify that the font file includes both glyphs and register it with @font-face when necessary.
The stylesheet never loaded
When the rule lives in a remote <link> stylesheet, Dompdf must be allowed to fetch it. A failed request, disallowed protocol, or non-CSS response leaves the input unstyled. Inline the small rule while diagnosing; if that fixes the output, investigate the remote stylesheet rather than the checkbox selector.
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⁴
State serialization patterns
Boolean values from a database
$checked = (int) $row['completed'] === 1;
$attr = $checked ? ' checked="checked"' : '';
$html .= '<input type="checkbox"'.$attr.'> Completed';
Do not concatenate a raw database value as an attribute. Convert it to a boolean, then emit either the complete attribute or nothing.
Values from an HTTP form
$checked = isset($_POST['terms']) && $_POST['terms'] === '1';
Unchecked HTML checkboxes are commonly omitted from a request, so test for presence and validate the expected value. Never infer a checked state merely because a key exists if your client can submit arbitrary values.
Multiple choices
$selected = array_map('strval', $record['features'] ?? []);
foreach ($features as $key => $label) {
$checked = in_array((string) $key, $selected, true);
$html .= checkbox($checked, 'features[]', $label);
}
Use strict comparisons and stable identifiers. This prevents a value such as 1 from accidentally matching an unrelated string.
CSS that Dompdf can actually use
The relevant properties are content, font-family, font-size, and line-height. Keep the rule intentionally small.
| Need | Use | Reason |
|---|---|---|
| Unchecked mark | content: "\2610" |
U+2610 is the open box glyph. |
| Checked mark | content: "\2611" |
U+2611 is the ballot box with check glyph. |
| Reliable font | font-family: "DejaVu Sans" !important |
It is supplied with Dompdf and includes the needed glyphs. |
| Vertical sizing | font-size and line-height |
These control alignment without relying on unsupported box-model behavior. |
Avoid building the solution around box-sizing; Dompdf’s compatibility information lists it as unsupported. If the mark sits too high or low, adjust the font size, line height, or surrounding label spacing rather than adding browser-only control styling.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsRemote CSS, fonts, and HTML parsing
Allowing a remote stylesheet
If you cannot inline the rule, enable remote resources in the options used to create Dompdf:
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.
$options = new DompdfOptions();
$options->set('isRemoteEnabled', true);
$dompdf = new DompdfDompdf($options);
Remote access is subject to the URL protocol allow-list and the response MIME type. A URL that returns an HTML error page instead of text/css will not become a stylesheet. Check the application logs for an “Unable to load css file” warning.
Registering a custom font
Use a font file that really contains both checkbox characters, register it through Dompdf’s font mechanism, and reference the exact family name in CSS. Test with DejaVu Sans first; it separates a font-registration problem from a checkbox problem.
Parsing malformed markup
Dompdf is not tolerant of poorly formed HTML. Close labels, quotes, and table cells, include a character encoding declaration, and enable the HTML5 parser for templates that contain modern markup. A malformed input can cause a selector or pseudo-element to be discarded even when the CSS itself is correct.
A repeatable debugging checklist
- Log the final HTML string and search for the specific checked input. It must contain
checked="checked", not only a JavaScript property in an earlier browser page. - Replace external stylesheets with the inline rule shown above.
- Set the font to DejaVu Sans and use the explicit escapes
2610and2611. - Render one checked and one unchecked input on an otherwise empty page.
- Enable the HTML5 parser and validate the generated markup.
- If inline CSS works, re-enable the remote stylesheet and inspect protocol, MIME type, TLS, and Dompdf warnings.
- Open the generated PDF in more than one viewer. A viewer rendering difference is separate from Dompdf’s source and layout output.
Common symptoms and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| Checked box appears empty | The HTML has no checked attribute. | Serialize the application boolean before loadHtml(). |
| Both states look identical | The [checked] selector does not match, or the stylesheet failed. |
Inspect the final attribute and inline the CSS. |
| A blank square or tofu glyph appears | Font lacks U+2610/U+2611. | Use DejaVu Sans or register a font with those glyphs. |
| Checkbox CSS has no effect | Remote CSS was blocked, returned the wrong MIME type, or malformed HTML prevented parsing. | Inline the rule, enable remote resources if required, and validate markup. |
| Mark is misaligned | Font metrics and line height differ from the browser. | Adjust font-size, line-height, and label spacing; avoid unsupported box-model properties. |
| Layout changes after a package update | Font, parser, or CSS behavior changed between Dompdf versions. | Keep a small fixture PDF in regression tests and verify both states after upgrades. |
Testing and operational considerations
Use a two-state fixture
Render the same template with one value true and one false. The PDF should contain visibly different marks and identical labels. Keep the fixture in automated tests so a dependency, font, or parser change cannot silently remove the check.
Keep the source auditable
Store the normalized boolean used for rendering, the time it was captured, and (where appropriate) the user or record that supplied it. The glyph is a visual representation; it is not a substitute for the underlying value.
Prefer deterministic resources
Inline the tiny checkbox stylesheet and use a known local font for invoices, forms, and archival documents. Remote CSS introduces network, protocol, and MIME-type failure modes. If remote resources are unavoidable, set explicit timeouts and log the resulting warnings.
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 goal is a clean image or PDF of the finished page rather than a Dompdf implementation, ScreenshotNeo captures a URL with one request. It accepts cookie and consent banners before capture, removes more than 60 known consent platforms plus newsletter popups and chat widgets, and reports whether the page was cleanly captured. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed.
For a rendered page, the cURL call is:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo documentation for parameters such as PDF output, full-page capture, a CSS selector, custom CSS and JavaScript, waits, cookies, headers, device presets, caching, signed links, asynchronous jobs, and bulk capture. An MCP server also exposes take_screenshot, get_page_info, and capture_pdf to Claude, Cursor, and other MCP clients.
The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Create a free ScreenshotNeo account to try it.
Frequently Asked Questions
Does adding checked=”false” work?
No. HTML boolean attributes are true when present, regardless of their text. Omit the attribute for an unchecked item and emit checked=”checked” for a checked one.
Can I use an image instead of a Unicode glyph?
Yes, but an image adds a resource-loading and sizing dependency. The generated-content approach is usually simpler when the selected font contains U+2610 and U+2611.
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 & 11Why does JavaScript work in Chrome but not in Dompdf?
Dompdf does not execute browser JavaScript to discover live form state. Serialize the state into the HTML string before rendering.
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.

