Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, 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 minuteGenerate each PDF with Puppeteer, load the resulting byte arrays with pdf-lib, copy the source pages into a new document in the order you want, then save the combined PDF. Do not concatenate the buffers themselves: a PDF is a structured document, and the merge needs to copy its pages. Puppeteer’s page.pdf() returns a Promise<Uint8Array>; pdf-lib accepts those bytes and returns the merged document as another Uint8Array. A Node.js Buffer is also a Uint8Array, so it can be passed as input.
Merge Puppeteer PDF buffers with pdf-lib
Install pdf-lib in the Node.js project that generates or processes the PDFs:
npm install pdf-lib
The merge function below accepts an array of PDF byte arrays, creates a destination PDF, copies every page from each source, and returns the merged bytes. The page order follows the input buffer order, and within each source it follows the source document’s page order.
import { PDFDocument } from 'pdf-lib';
export async function mergePdfBuffers(pdfBuffers) {
if (!Array.isArray(pdfBuffers) || pdfBuffers.length === 0) {
throw new Error('Provide at least one PDF buffer to merge.');
}
const mergedPdf = await PDFDocument.create();
for (const pdfBuffer of pdfBuffers) {
const sourcePdf = await PDFDocument.load(pdfBuffer);
const copiedPages = await mergedPdf.copyPages(
sourcePdf,
sourcePdf.getPageIndices(),
);
for (const page of copiedPages) {
mergedPdf.addPage(page);
}
}
return mergedPdf.save();
}
PDFDocument.load() accepts a Uint8Array, ArrayBuffer, or base64 string. copyPages(sourcePdf, indices) copies the selected pages into the destination; save() serializes that destination as PDF bytes. See the pdf-lib PDFDocument API and its project site for the documented methods.
Free tools Windows power users keep installed
One-click scans. No signup required.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
Generate, merge, and write the result
This complete Node.js example uses Puppeteer to generate two in-memory PDFs from HTML, merges them, and writes the result to disk. Install both dependencies with npm install puppeteer pdf-lib. Use a project configured for ES modules, for example by setting "type": "module" in package.json.
import fs from 'node:fs/promises';
import puppeteer from 'puppeteer';
import { PDFDocument } from 'pdf-lib';
async function mergePdfBuffers(pdfBuffers) {
if (!Array.isArray(pdfBuffers) || pdfBuffers.length === 0) {
throw new Error('Provide at least one PDF buffer to merge.');
}
const mergedPdf = await PDFDocument.create();
for (const pdfBuffer of pdfBuffers) {
const sourcePdf = await PDFDocument.load(pdfBuffer);
const pages = await mergedPdf.copyPages(
sourcePdf,
sourcePdf.getPageIndices(),
);
for (const page of pages) mergedPdf.addPage(page);
}
return mergedPdf.save();
}
const browser = await puppeteer.launch({ headless: true });
try {
const pdfBuffers = [];
for (const [index, title] of ['First report', 'Second report'].entries()) {
const page = await browser.newPage();
await page.setContent(
`<!doctype html><html><head><meta charset="utf-8"><title>${title}</title></head>` +
`<body><h1>${title}</h1><p>Document ${index + 1}</p></body></html>`,
{ waitUntil: 'load' },
);
// page.pdf() produces a Uint8Array; retain it in memory.
pdfBuffers.push(await page.pdf({ format: 'A4', printBackground: true }));
await page.close();
}
const mergedBytes = await mergePdfBuffers(pdfBuffers);
await fs.writeFile('combined.pdf', mergedBytes);
} finally {
await browser.close();
}
The result is combined.pdf in the current working directory. This example deliberately keeps the generated PDFs in memory until the merge is complete; it does not create intermediate PDF files. For an HTTP endpoint, send the returned bytes through the framework’s binary response API with a PDF content type rather than converting them to a text string.
Control page order and select pages
The outer loop determines document order. If the desired sequence is second document followed by first, reorder the input array before calling the function. To include only certain pages, pass a list of page indices to copyPages() instead of sourcePdf.getPageIndices(). Indices are page positions, not page labels; construct them in the exact order desired.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
const sourcePdf = await PDFDocument.load(pdfBuffer);
const selectedPages = await mergedPdf.copyPages(sourcePdf, [2, 0]);
for (const page of selectedPages) mergedPdf.addPage(page);
This copies the third page and then the first page of that source, assuming those indices exist. Validate selected indices against sourcePdf.getPageCount() before copying when the selection comes from user input. The documented API describes page copying as the merge mechanism; appending raw PDF byte arrays is not equivalent.
Rendering details that affect the source PDFs
Merging does not change how Puppeteer rendered each input. page.pdf() uses print CSS media by default. If the document must use screen styles, set the media type before creating that source PDF:
await page.emulateMediaType('screen');
const pdfBytes = await page.pdf();
Puppeteer’s PDF generation guide says that page.pdf() waits for fonts to load by default. For pages with web fonts, check the rendered source PDFs if text looks wrong before investigating the merge step. The API reference retrieved for this article identifies Puppeteer documentation version 25.12.0; check the API docs and installed dependency version if behavior differs in another release. See Puppeteer’s Page.pdf() API and PDF generation guide.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Memory, reliability, and document-feature considerations
- Memory use: the source byte arrays, loaded source documents, copied pages, and final serialized bytes may all occupy memory during processing. For large documents or many inputs, process jobs with sensible concurrency limits and monitor the memory available to the Node.js process. The cited APIs do not establish a quantitative performance comparison or a universal safe file-size limit.
- Keep intermediate files only when useful: in-memory processing avoids writing each source PDF to disk. Persisting inputs can help with retries or auditing, but adds storage and cleanup work; it is not required by this merge approach.
- Validate inputs: an empty input list, malformed PDF, encrypted PDF, or unsupported document condition should be treated as an error case. Do not assume every PDF will load and copy successfully; verify behavior for the installed
pdf-libversion and your actual files. - Do not assume special features survive: this workflow copies pages into a new document. The cited API references do not establish preservation guarantees for signatures or specialized interactive features. If those matter, test the specific files and feature requirements before relying on a merged output.
Troubleshoot common failures
“Cannot find package” or import errors
Install pdf-lib in the project where the script runs. If using import, ensure the project is configured for ES modules or adapt imports to the module system already in use. Confirm the script is running from the expected project and dependency installation.
PDFDocument.load() rejects an input
Check that the value contains PDF bytes, not a URL string, response object, or encoded text produced by converting binary data incorrectly. Puppeteer’s page.pdf() can be passed directly. If the input came from a file, read it as bytes; if it came from an HTTP request, obtain the binary response body. Confirm the source opens as a PDF and investigate malformed or encrypted files rather than assuming they are supported.
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 problemsThe output contains pages in the wrong order
Inspect the input array’s order and the page indices passed to copyPages(). Pages are appended in the sequence the code adds them. Reorder the buffers or explicitly construct the desired index sequence.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Output is empty or only some documents appear
Check that every generation promise is awaited and that each generated byte array is pushed into the array before merging. Confirm every source has pages and that the loop processes all inputs. Log source page counts during diagnosis with sourcePdf.getPageCount().
The merged PDF cannot be opened
Write the returned Uint8Array as binary bytes, not as a UTF-8 string. Verify the write or HTTP response completed and that the output is non-empty. Then test each source independently to identify a problematic input.
Fonts or page appearance differ from expectations
Inspect a source PDF before merging. Puppeteer renders print media by default, and its PDF call waits for fonts by default. If screen CSS is required, call emulateMediaType('screen') before page.pdf(); if a font still fails to render, diagnose source-page loading and font availability separately from page copying.
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 →Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Or skip the browser setup
If the actual task is to capture web pages as PDFs rather than merge existing Puppeteer buffers, ScreenshotNeo can return a website capture without setting up a browser. Its screenshot workflow accepts cookie/consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; those cleanup steps can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, with response headers reporting the page verdict and billing status. It also offers an MCP server with screenshot tools for AI agents. The following one-call example saves an image capture; see the ScreenshotNeo documentation for API options and PDF output details.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
ScreenshotNeo includes 1,000 screenshots per month free with no card; paid plans start at $5 for 3,000 screenshots. Those captures are an alternative way to obtain web-page output, not a replacement for merging already-created PDF buffers with pdf-lib. Learn about ScreenshotNeo or sign up for 1,000 free screenshots a month with no card.
Frequently Asked Questions
Can I pass a Node.js Buffer directly to PDFDocument.load()?
Yes. A Node.js Buffer extends Uint8Array, which is an accepted PDF input type.
Does Puppeteer’s page.pdf() return a Buffer?
Its documented return type is Promise
Can I merge PDFs without writing the intermediate files?
Yes. Keep the byte arrays returned by page.pdf() in memory, merge them, and write or send only the final returned bytes.
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.

