What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Use a real browser from Deno, wait for the page to render, call Puppeteer’s page.pdf(), and close the browser in a finally block. The approach handles client-rendered pages and gives you control over paper size, margins, CSS media, backgrounds, and page ranges. Deno can run the TypeScript directly, but you must grant the permissions your script and browser need and verify that the selected Puppeteer version and browser executable work in your deployment environment.
The supported conversion flow
A browser-based renderer is the most complete way to turn a live URL or generated HTML into a PDF. The browser executes JavaScript, loads fonts and images, applies the site’s styles, and then prints the rendered page. A typical Deno program follows five steps:
- Import a browser automation package from npm.
- Launch a browser.
- Open a page and navigate to the URL.
- Call
page.pdf()with the output settings you need. - Close the browser even when navigation or PDF generation fails.
Puppeteer’s PDF API returns a Uint8Array. Supplying a path writes the file for you; omitting it lets your code handle the bytes itself. PDF generation uses print CSS by default, so screen-style rendering requires an explicit media emulation call.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsPrerequisites and Deno permissions
Runtime and package support
Deno runs TypeScript without a separate compiler step and can consume npm packages. The exact import syntax, Puppeteer release, and browser-install behavior can change, so confirm them against the versions used by your project before deploying. The documentation reviewed for this workflow does not establish one universal Deno-specific browser installation recipe.
#1 Best Overall
- Convert your PDF files into Word, Excel & Co. the easy way
- Convert scanned documents thanks to our new 2022 OCR technology
- Adjustable conversion settings
- No subscription! Lifetime license!
- Compatible with Windows 11, 10, 8.1, 7 - Internet connection required
Grant only the permissions you need
Deno starts with no file, network, or environment access. A remote page needs network access, and saving a PDF needs filesystem write access. Launching a locally managed browser can also require the process and read permissions expected by your runtime and browser setup. Start narrowly, then add a permission only when an error identifies a genuine requirement.
deno run --allow-net --allow-write --allow-read --allow-run page_to_pdf.ts
If your deployment provides a browser executable through a restricted service, its required permissions may differ. Do not use --allow-all merely to hide a permission error.
Complete Deno example with Puppeteer
Save this as page_to_pdf.ts. It navigates to a URL, waits for network activity to settle, prints an A4 PDF with backgrounds enabled, and always closes the browser.
Recommended Free Tools
import puppeteer from 'npm:puppeteer';
const url = 'https://example.com';
const browser = await puppeteer.launch();
try {
const page = await browser.newPage();
await page.goto(url, { waitUntil: 'networkidle2' });
await page.pdf({
path: 'page.pdf',
format: 'A4',
printBackground: true,
});
} finally {
await browser.close();
}
Run it with the permissions required by your environment:
deno run --allow-net --allow-write --allow-read --allow-run page_to_pdf.ts
The result is page.pdf in the current directory. In a production service, pass the URL and output path through validated configuration rather than accepting arbitrary user input; unrestricted navigation can expose internal addresses or private data.
Writing the returned bytes yourself
When you need to upload the PDF, encrypt it, or return it from an HTTP handler, omit path and use the returned bytes:
Rank #2
- Convert over 50 document file formats.
- Preview your files from Doxillion before converting them.
- Use batch conversion to convert thousands of files at once.
- Enjoy an easy-to-use, intuitive interface with a Drag and Drop file option.
- Burn your converted or original files directly to disc.
const pdf = await page.pdf({ format: 'A4', printBackground: true });
await Deno.writeFile('page.pdf', pdf);
The write operation still needs filesystem permission. The browser must remain open until the PDF promise resolves.
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 minutePDF settings that change the result
| Option | Effect | Important default or interaction |
|---|---|---|
format |
Chooses a named paper size such as A4. | The documented default is Letter when no size is supplied. |
width, height |
Sets custom paper dimensions. | Use these when a named format does not match your output. |
margin |
Controls top, right, bottom, and left whitespace. | Specify units consistently, for example 20mm. |
landscape |
Rotates the paper orientation. | Useful for wide tables and dashboards. |
printBackground |
Includes background colors and images. | Defaults to false; set it to true when the design depends on backgrounds. |
scale |
Scales the printed page. | Changing it affects how much content fits on each sheet. |
pageRanges |
Prints only selected pages. | Use the range syntax accepted by Puppeteer. |
preferCSSPageSize |
Lets CSS control the paper size. | When enabled, a declared @page size takes priority over the format setting. |
waitForFonts |
Waits for fonts before producing the PDF. | Puppeteer documents this as true by default. |
path |
Writes the PDF to a file. | Omit it to receive a Uint8Array. |
Print CSS versus screen CSS
Because PDF generation uses the print media type by default, a site’s @media print rules can hide navigation, change colors, or rearrange columns. To reproduce the on-screen design instead, set the media type before printing:
await page.emulateMediaType('screen');
await page.pdf({
path: 'screen-style.pdf',
format: 'A4',
printBackground: true,
});
For your own HTML, define print-specific rules deliberately:
@page {
size: A4;
margin: 16mm;
}
@media print {
.site-nav,
.cookie-banner {
display: none;
}
}
html {
-webkit-print-color-adjust: exact;
}
The color-adjust property can preserve exact colors, but the final appearance still depends on the page’s assets, browser configuration, and CSS. No browser automation library guarantees identical output for every site.
Waiting for dynamic content
networkidle2 waits until network activity is quiet enough for the navigation to continue, but it cannot know whether an application has finished rendering a chart or loading data after a timer. Add an application-specific wait when necessary:
await page.goto(url, { waitUntil: 'domcontentloaded' });
await page.waitForSelector('[data-report-ready]');
await page.pdf({ path: 'report.pdf', format: 'A4', printBackground: true });
If the page has a known animation or delayed request, a short, explicit delay can be used, but selector-based readiness is less arbitrary. For long pages, make sure lazy-loaded images are triggered before printing; scrolling through the document or waiting for the application’s own “ready” signal may be required.
Rank #3
- EDIT text, images & designs in PDF documents. ORGANIZE PDFs. Convert PDFs to Word, Excel & ePub.
- READ and Comment PDFs – Intuitive reading modes & document commenting and mark up.
- CREATE, COMBINE, SCAN and COMPRESS PDFs
- FILL forms & Digitally Sign PDFs. PROTECT and Encrypt PDFs
- 1 Year License for 1 Windows & 2 Mobile (Android and/or iOS) devices.
Authenticated or customized pages
Perform login and cookie setup in the same browser context before calling page.pdf(). Keep credentials out of source files and logs. If a page blocks automated browsers, presents a CAPTCHA, or depends on a service unavailable from your deployment region, the PDF may contain an error page or incomplete content; automation cannot legitimately bypass a challenge.
Using Playwright instead
Playwright also exposes Page.pdf(), returns a PDF buffer, and uses print CSS by default. It documents the same screen-media pattern: emulate screen before generating the PDF when that is the desired output. Choose between Puppeteer and Playwright based on the package already used by your project, browser installation support in the target deployment, and the automation APIs you need. The available documentation does not establish a Deno-specific speed, cost, or reliability winner, so do not select one on an unverified benchmark.
Decision checklist
- Keep Puppeteer if your codebase already uses its selectors, lifecycle, or plugins.
- Choose Playwright when its browser-management or cross-browser APIs fit your deployment better.
- For either library, pin and review versions, test the browser executable in the same container or host, and exercise representative pages before release.
Reliability, performance, and cost considerations
Reuse browsers for batches
Launching a browser for every URL adds startup overhead. For a batch job, launch once, create a fresh page per URL, close each page, and close the browser after the batch. A fresh page limits cookies and DOM state leaking between documents.
Control resource use
- Set navigation and selector timeouts appropriate to your service rather than waiting forever.
- Use page ranges, paper size, and scale to avoid producing unnecessarily large files.
- Close pages and browsers in
finallyblocks so failed jobs do not accumulate processes. - Measure memory and PDF size with your own pages; the supplied documentation provides no universal performance figure.
Plan for changing pages
A PDF is a snapshot. Ads, timestamps, personalization, A/B tests, third-party widgets, and responsive breakpoints can change between runs. Record the URL, viewport, media type, browser version, and relevant options with each generated document when reproducibility matters.
Troubleshooting common failures
“Permission denied” or a network error
Cause: Deno blocked the requested capability. Fix: add the narrow permission required by the failing operation, such as --allow-net for navigation or --allow-write for the output file. Check that the host and port are allowed by your deployment’s network policy.
Browser launch fails
Cause: Puppeteer cannot find or start a compatible browser, or the runtime blocks the required process/read operation. Fix: verify the Puppeteer version, browser availability, executable path, and container dependencies. Test the same launch command in the deployment image; there is no single browser-install recipe that applies to every Deno environment.
Rank #4
- Perfect Adobe Acrobat Pro alternative – lifetime license for Windows 10 and 11.
- EDIT text, images, pages, hyperlinks, designs in PDF documents. ORGANIZE PDFs.
- READ and Comment on PDFs – Intuitive reading modes & document commenting and mark up tools!
- CREATE, COMBINE, SCAN and COMPRESS PDFs.
- FILL forms & Digitally Sign PDFs. Work with Digital certificates
The PDF is blank or contains a loading screen
Cause: Printing happened before client-side rendering completed. Fix: wait for a specific ready selector, use an appropriate navigation condition, and confirm that API requests succeed from the host running Deno.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Colors or backgrounds are missing
Cause: print CSS is active or background printing is disabled. Fix: set printBackground: true, choose page.emulateMediaType('screen') when appropriate, and review @media print and -webkit-print-color-adjust.
Content is cut off or the layout is unexpectedly wide
Cause: paper dimensions, margins, orientation, scale, or responsive CSS do not match the page. Fix: set an explicit format or custom dimensions, try landscape, adjust margins and scale, and inspect the page at the viewport size used by the browser.
Fonts or images differ from the browser preview
Cause: assets were not available to the renderer, or the page changed media and loading behavior for print. Fix: wait for fonts and required selectors, verify asset responses, and ensure the browser can reach every origin used by the page.
Or skip the browser setup
ScreenshotNeo provides a website capture API and MCP server when you do not want to maintain browser automation in Deno. A single GET request returns a PNG, JPEG, WebP, or PDF; see the ScreenshotNeo documentation for request options.
curl -G 'https://api.screenshotneo.com/v1/shot' -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
import requests
r = requests.get('https://api.screenshotneo.com/v1/shot', params={'access_key': 'YOUR_API_KEY', 'url': 'https://example.com'}, timeout=90)
open('shot.webp', 'wb').write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://example.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
Before capture, ScreenshotNeo accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be disabled. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing result. Its MCP server supplies take_screenshot, get_page_info, and capture_pdf tools to Claude, Cursor, and other MCP clients. The Free plan includes 1,000 screenshots each month with no card; paid plans start at $5 for 3,000 shots, and every feature is included on every plan. Create a free ScreenshotNeo account to try it.
FAQ
Can I convert HTML that is already in a Deno string?
Yes. Serve the string from a local or test HTTP endpoint that the browser can reach, or navigate to a controlled data URL. An HTTP endpoint is usually easier when the document references relative CSS, images, or fonts.
Best Value
- Convert over 50 document file formats.
- Preview your files from Doxillion before converting them.
- Use batch conversion to convert thousands of files at once.
- Enjoy an easy-to-use, intuitive interface with a Drag and Drop file option.
- Burn your converted or original files directly to disc.
Why does a CSS @page rule seem to be ignored?
Puppeteer only gives the CSS page size priority when preferCSSPageSize is enabled. Otherwise, the PDF options such as format and custom dimensions determine the paper.
Can I return the PDF directly from a Deno HTTP handler?
Yes. Keep the Uint8Array returned by page.pdf(), set a PDF content type and disposition, write the bytes to the response, and close the page and browser after the response data has been prepared.
Is a browser PDF identical to a print dialog PDF?
Not necessarily. Both use browser print concepts, but executable version, installed fonts, viewport, permissions, network timing, and page-specific CSS can change the result. Test the exact runtime used in production.
Frequently Asked Questions
Can I convert HTML that is already in a Deno string?
Yes. Serve the string from a local or test HTTP endpoint that the browser can reach, or navigate to a controlled data URL. An HTTP endpoint is usually easier when the document references relative CSS, images, or fonts.
Why does a CSS @page rule seem to be ignored?
Puppeteer only gives the CSS page size priority when preferCSSPageSize is enabled. Otherwise, the PDF options such as format and custom dimensions determine the paper.
Can I return the PDF directly from a Deno HTTP handler?
Yes. Keep the Uint8Array returned by page.pdf(), set a PDF content type and disposition, write the bytes to the response, and close the page and browser after the response data has been prepared.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Is a browser PDF identical to a print dialog PDF?
Not necessarily. Executable version, installed fonts, viewport, permissions, network timing, and page-specific CSS can change the result. Test the exact runtime used in production.
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.

