Compress a PDF to 2 MB on Windows, offline, and check the size before you upload
A file Windows shows as 1.95 MB can still be refused. Measured on an 8-page survey with 16 photos, with a free Python script and with PDF Compressor.
We make PDF Compressor, the app this guide uses. The free methods come first; every step shown in PDF Compressor was checked in the app itself, and the screenshots come from the real app with invented sample data.
Short answer
Aim under 2,000,000 bytes. A site that says 2 MB may count 2,000,000 or 2,097,152 bytes, and Windows shows sizes in units of 1,024, so a file of 2,050,000 bytes shows as 1.95 MB and can still be refused. For free, a Python script with pypdf can lower the picture quality step by step until the saved file is under the limit: as run below, it brought an 8-page survey with 16 photos from 5,836,995 to 1,638,286 bytes. PDF Compressor takes the target in MB, shows the exact new size before saving and draws every saved page again to check it.
What 2 MB means to an upload form
Upload forms rarely say how they count. 2 MB can mean 2 x 1,000,000 = 2,000,000 bytes, or 2 x 1,048,576 = 2,097,152 bytes. Windows counts in units of 1,024, so its numbers look smaller than the same file counted in millions of bytes. On 30 November 2026 we made files of exact sizes and read the size Windows gives them (the Size detail of File Explorer, read through the Windows shell; our test PC displays French, so it wrote 1,95 Mo):
- 2,050,000 bytes: 1.95 MB. Under 2 MB for Windows, but over a limit of 2,000,000 bytes.
- 1,990,000 bytes: 1.89 MB. Under both.
- 1,638,286 bytes (the file our script saved below): 1.56 MB.
A file under 2,000,000 bytes passes either way of counting. To see the exact number of bytes, open the file's Properties in File Explorer: it shows it in brackets after the size. The script below prints sizes in bytes, so there is nothing to convert.
Method 1 (free): a Python script that stops under the limit
pypdf, a free Python library, can re-encode the pictures in a PDF as JPEG at a quality you choose and merge identical objects; its page on reducing file size notes that this does not always make a file smaller. Our script tries one setting after another, mildest first, and saves the first result under the byte limit. Save it as fit_pdf.py:
# fit_pdf.py: make a PDF fit a size limit by re-encoding its pictures (pypdf + Pillow).
# Usage: py fit_pdf.py input.pdf output.pdf 2000000
import io
import sys
from pypdf import PdfWriter
src, dst, limit = sys.argv[1], sys.argv[2], int(sys.argv[3])
steps = [(1.0, 85), (1.0, 70), (0.75, 70), (0.5, 70), (0.5, 50), (0.35, 50), (0.25, 40)]
for scale, quality in steps:
writer = PdfWriter(clone_from=src)
for page in writer.pages:
for img in page.images:
picture = img.image
if scale < 1:
picture = picture.resize((max(1, round(picture.width * scale)),
max(1, round(picture.height * scale))))
img.replace(picture, quality=quality)
writer.compress_identical_objects(remove_duplicates=True, remove_unreferenced=True)
buffer = io.BytesIO()
writer.write(buffer)
size = buffer.tell()
print(f"scale {scale:.2f}, JPEG quality {quality}: {size:,} bytes")
if size <= limit:
with open(dst, "wb") as out:
out.write(buffer.getvalue())
print(f"saved {dst}")
break
else:
print("no step fits the limit: nothing saved")
It needs pypdf and Pillow (py -m pip install pypdf pillow). We ran it on 30 November 2026 with Python 3.12.13, pypdf 6.21.1 and Pillow 13.0.0, on a copy of an invented garden survey: 8 pages with 16 photos at 300 dpi, 5,836,995 bytes. From the folder that holds both files:
py fit_pdf.py "Garden survey - Willow Lane (photos).pdf" "Garden survey (2 MB).pdf" 2000000
scale 1.00, JPEG quality 85: 5,142,601 bytes
scale 1.00, JPEG quality 70: 1,638,286 bytes
saved Garden survey (2 MB).pdf
It took 2.3 seconds on our test PC. The photos kept their full size (2063 x 1375 pixels); only their JPEG quality went down. We had PDFium (through pypdfium2) draw every page of the saved file: all 8 opened, and pypdf read the same text on all 8 pages as before. Open the result and look at the photos before you send it: the script does not judge quality, it only counts bytes. For another limit, change the last number, for example 5000000 for 5 MB. The script writes over a file with the output name without asking, so give it a new name, and do not use it on a digitally signed PDF: a re-encoded copy loses the signature.
Other free tools, not run here
- Ghostscript rewrites a PDF with presets such as /screen (pictures at 72 dpi), /ebook (150 dpi) and /printer or /prepress (300 dpi). It has no setting for a target size: you try presets until one fits.
- qpdf can recompress images that are not already JPEG as JPEG (--optimize-images); since qpdf 12.1, adding --jpeg-quality also recompresses JPEG pictures at the quality you give. It also recompresses streams (--recompress-flate), and it has no target size either.
- Most online compressors upload your file and work on it on their servers. PDF24's online tool, for example, says files are processed on its servers in Germany and deleted after one hour.
Neither Ghostscript nor qpdf was installed on our test PC; we did not run them or any online compressor.
Method 2: set a 2 MB target with PDF Compressor
PDF Compressor is our Windows app for making PDFs smaller offline. With Target size, you type the limit in MB per PDF and it gives each PDF the best picture quality that fits, measured on the saved file. Its help text says 1 MB = 1,000,000 bytes, so the result also fits a site that counts 1,048,576. The screenshots below come from version 1.0.0 (evaluation build), with the same invented survey and a one-page quote of 1,320 bytes.
- Add the PDFs and type the target. With Target size and At most 2 MB per PDF, the preview showed the survey at 640.5 KB, 89% smaller, "fits 2 MB", before anything was saved, with a page and a close-up of a photo before and after.
- Compress. The results said "Compressed 1 of 2 PDFs" and "All 8 pages checked". The survey came out at 655,838 bytes, with its 16 photos re-encoded at JPEG quality 80 and scaled from 300 to 200 dpi on the page (1375 x 917 pixels); its text was the same as before. The quote, already under the target, was reported as "Already compact: under the target size" and not copied.
- Check the originals. Both sample files had the same SHA-256 after the run as before it: the app only reads them.



The app shows sizes in units of 1,024 like Windows (655,838 bytes is 640.5 KB) and counts the target in millions of bytes. In our run it chose 200 dpi with JPEG quality 80 and ended far under 2 MB, at 640.5 KB, while the free script kept the photos at full resolution and landed nearer the limit. If a portal wants one file, merge the PDFs first: see our guide to merging PDFs without uploading them. For scans to send by email, see reducing a scanned PDF for email.
Limitations
- No method can promise a size: it depends on what is in the PDF. A file of text and drawings has little to gain from picture settings.
- The script uses one quality for every picture and does not judge how the result looks; it only handles pictures. We ran it on one PDF of colour photos: pictures with transparency or in black and white may not re-encode as JPEG, and we did not test them.
- PDF Compressor never re-encodes text and fonts. If even its smallest version is larger than the target, it saves that one and the results say so. Requirements: Windows 10 (22H2) or 11, 64-bit, 4 GB RAM.
- We did not run Ghostscript, qpdf or an online compressor, and we tested one survey, not every kind of PDF.
References
- pypdf documentation: Reduce PDF file size
- Ghostscript documentation: High Level Devices
- qpdf documentation: Running qpdf
- PDF24 Tools: Compress PDF