How to merge, split and compress PDFs with desktop tools
Most everyday PDF jobs need no upload to a website. Your operating system can already do some of them, and two free command-line tools handle the rest, so private documents stay on your own computer.
Why do it locally?
Contracts, bank statements, medical letters and ID scans are common PDF contents. When you upload them to an online converter, you rely on that service to delete them. Doing the job on your own machine removes that question. It also works without an internet connection and has no file size limit except your disk.
On a Mac: Preview
Merge
- Open the first PDF in Preview.
- Choose View > Thumbnails to show the page sidebar.
- Drag the second PDF file from Finder into the sidebar, at the position where its pages should go.
- Choose File > Export as PDF and save under a new name, so the original stays unchanged.
Split or extract pages
- Select the pages you want in the thumbnail sidebar (hold Cmd to pick several).
- Drag them to the desktop. Preview creates a new PDF with just those pages.
Compress
Choose File > Export, set the format to PDF, and pick the Reduce File Size Quartz filter. It can shrink scans a lot, but it can also make images too blurry, so check the result before you send it.
On Windows: Print to PDF
Windows includes a virtual printer called Microsoft Print to PDF. It cannot merge files, but it can split them:
- Open the PDF in your browser or PDF reader and choose Print.
- Select Microsoft Print to PDF as the printer.
- Under pages, enter a range such as
3-5. - Print and choose where to save the new file.
Printing to PDF flattens the document: links, form fields and bookmarks may be lost. For merging on Windows, use the command-line tools below or a desktop PDF editor that you trust.
On any system: qpdf and Ghostscript
Both are free, open-source command-line tools available for Windows, macOS and Linux. qpdf restructures PDFs without changing their content; Ghostscript can re-render them, which is what you need for compression.
Merge with qpdf
qpdf --empty --pages report.pdf appendix.pdf -- combined.pdf
Extract pages with qpdf
qpdf report.pdf --pages . 1-3 -- first-three.pdf
qpdf report.pdf --pages . 4-z -- the-rest.pdf
In a page range, . means the input file and z means the last page. To make one file per page, use qpdf --split-pages report.pdf page.pdf.
Compress with Ghostscript
gs -sDEVICE=pdfwrite -dPDFSETTINGS=/ebook -dNOPAUSE -dBATCH \
-sOutputFile=smaller.pdf scan.pdf
The /screen setting gives the smallest files and lowest image quality, /ebook is a middle setting, and /printer keeps more detail. Try /ebook first.
Why compression works: image resolution
A PDF is usually large because of images, especially scans. Compression tools mostly reduce image resolution, measured in dots per inch (dpi), and re-encode the images.
Example. A scan 10 inches wide by about 6.7 inches tall is stored at 3000 × 2000 pixels, which is 300 dpi. Reducing it to 150 dpi gives 1500 × 1000 pixels.
- Before: 3000 × 2000 = 6,000,000 pixels
- After: 1500 × 1000 = 1,500,000 pixels
- Halving the dpi leaves one quarter of the pixels, because both width and height halve.
The file does not shrink by exactly four times, because compression and text also play a part, but the image data drops sharply. 150 dpi is usually readable on screen; keep 300 dpi for printing.
Common mistakes
- Overwriting the original. Always save the result as a new file and check it first.
- Compressing a PDF that has no large images. A text-only PDF is already small, and re-rendering it can lose selectable text or links.
- Merging files with different page sizes and expecting them to print the same.
- Splitting a signed document. Changing the file usually invalidates a digital signature.
Questions
Can I edit the text in a PDF?
A PDF is designed for final layout, so editing text is awkward. If you have the original document, edit that and export a new PDF. LibreOffice Draw can open and edit simple PDFs.
Will merging keep bookmarks and links?
qpdf keeps links within the pages it copies and has options for handling outlines. Print-to-PDF does not. Check the result in a reader before you share it.