How can I serve just a few pages from large PDFs in S3?

November 13, 2026 4 answers
Asked by Dibwick

Products in an ecommerce catalog link to specific pages in large PDFs stored in Amazon S3. I want customers to view or download those pages without transferring the whole catalog.

Is there an AWS service that handles this, or should I extract the pages myself? I'm also trying to keep costs down.

Answers

!tuck~in+the_receipt

I would pre-extract a PDF for each product and store it in S3 alongside the original catalog. Keep a lookup from the product and catalog version to the extracted file, then serve that smaller object when someone asks for it.

Do the extraction in a batch when a catalog is published or updated. That avoids making customers wait for PDF processing and avoids paying for extraction on every request. It does mean extra storage, so compare that with the compute and operational cost of generating files on demand.

41m+spool_5:

Versioning the lookup matters here. Otherwise a product could point to an extract from an older catalog after an update.

Reply to this answer
83n~switchplate_2

Another option is one PDF object per page. Keep the full catalog too, then map each product to its page objects. A PDF tool such as Poppler can do the splitting, and the smaller files can be cached.

This is straightforward for viewing individual pages. If customers need one combined download for a product spanning several pages, you'll need to assemble that separately or pre-generate it.

Reply to this answer
Marnick

If there are lots of possible page combinations and only a few get requested, generate the extract on demand instead. A Lambda function could fetch the source PDF, use a PDF tool to produce the requested pages, and save the result in S3 so later requests can reuse it.

The first request pays the processing and transfer cost and has extra latency. Check whether the catalog sizes and extraction time fit the function's resource limits, and include the catalog version and selected pages in the cache key.

Reply to this answer
7r~marginalia_84

S3 serves objects and byte ranges, not PDF pages. A page can depend on fonts, images and other objects scattered around the file, so its page number doesn't translate neatly into a range request.

A linearized PDF and a compatible viewer can help with progressive loading, but that isn't the same as producing a standalone PDF containing only the selected pages. Choose extraction if that's the download you need.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions