DEV Community

Cover image for How to make a scanned PDF small enough to email
Hanako H.
Hanako H.

Posted on

How to make a scanned PDF small enough to email

Six pages photographed on a phone and turned into one PDF can weigh more than the mail service will accept. Many stop at 25 MB, and an attachment grows by about a third when it is encoded for mail, so a 30 MB file is well over. The usual fix is an online compressor, which means uploading the document, a lease in the example below, to someone else's server. The PDF Editor in the osFoundry desktop app does it on the computer instead, in three steps. The example is a 6-page lease scanned on a phone, a made-up document for this demonstration, and it goes from 30.7 MB to 1.0 MB.

The 6-page scan open in the PDF Editor

See what the file is made of

Open the PDF in the PDF Editor (Canvas, then PDF Editor), click All tools, then Compress a PDF, then Advanced optimization. The PDF Optimizer dialog has an Audit space usage button at the bottom left. It adds the file up by kind of content.

The Space Audit table: images are 99.99% of the file

For the lease, Images are 32,225,071 of 32,227,412 bytes, 99.99%. The text and everything else weigh a few kilobytes. Each page is a photo about 3,000 pixels wide, and the photos are the file. This is typical of PDFs made from phone photos, and it is why a text document exported from a word processor is tiny while a scan of the same page is not. If the audit shows something else taking the space, shrinking the images will not help much. Click OK to return to the dialog.

Check the image settings

The dialog's Images tab shows the settings. By default, color and grayscale images drawn at more than 225 ppi are resampled to 150 ppi and saved as JPEG at Medium quality.

The PDF Optimizer image settings: 150 ppi above 225, JPEG, Medium

The ppi that matters is how densely the page draws the image, not what the camera reported. A 3,024-pixel-wide photo drawn across an 8.5-inch page is about 356 ppi, a lot more than reading needs, and 150 is plenty for text on a screen or on a printout. The line under the settings says that each image is measured where the pages draw it, and that an image is replaced only if the new version is smaller, so a file that was already small is not made bigger. The defaults were right for this file, so nothing was changed. Click OK.

Open the copy

The editor saves a new file next to the original, named like the original with "(optimized)" added, here en (optimized).pdf. The copy is 1.0 MB, against 30.7 MB for the original, about 97% smaller. The original file is not changed.

Open the copy and zoom in. Each page is now an image of 1275 × 1700 pixels, 150 ppi on the page, instead of 3024 × 4032.

The optimized copy zoomed in: the text is still sharp

Read the contract text at 125% and compare it with the original before sending: this is lossy compression, and the check takes seconds. At 150 ppi the printed text stays sharp. If a document has fine print or small handwriting, the same dialog can be run again from the original with a higher ppi, for example 200, to trade some size for detail.

The 1.0 MB copy is attached to the mail; the 30.7 MB original stays in its folder.

The PDF Editor is part of the osFoundry desktop app, which is free for macOS, Windows and Linux from the download page, and it works on files that stay on the computer; the local-first page explains what that means.

Top comments (0)