Tiling PDF

Divide large PDF into tiles on multiple page to allow print on small-size paper, suit for map and civil drawing

--by Captdam @ Oct 16, 2025 Nov 1, 2024

[en] Here is the English version of this article

【中】 这里是这篇文章的中文版

Index

Example

You can try this application in the following window (an embedded GitHub page). Open a PDF file, set up the horizontal and vertical tiling count, then click "Tile". All computations are performed locally on your computer in your browser. No one knows what you did (including what PDF you opened), except you opened this page, the embedded GitHub page and downloaded the PDF-Lib.

How It Work

Let’s imagine every page in a PDF file to be a canvas. Elements like text and images are placed on the canvas at their coordinates.

PDF files come with some boxes defining some margins. One of them is the Media Box. When opening and rendering pages of a PDF file, anything outside the Media Box will not be rendered.

In most cases, the Media Box has the same size as the canvas. This makes sense because we want the canvas to be exactly the same size as the render result. So, we can save the canvas size.

But, now, we want to only render a small area of the big canvas. We can define a smaller Media Box. Keep the interesting content inside the small Media box; Whatever outside of the small Media Box will be discarded. What makes this method elegant is that we do not need to worry about the elements (text and images) on the canvas. Just leave them as-is.

For example, if we want to divide the length and width of a page to make 4 sub-pages, we can make 4 copies of that page. Then, define a Media Box at the top-left corner to make the first sub-page; define a Media Box at the top-right corner to make the second sub-page; define a Media Box at the bottom-left corner to make the third sub-page; define a Media Box at the bottom-right corner to make the fourth sub-page.

Development

I wrote this web app to help me print large-size drawings on small-size paper to allow me to work with the drawing.

Some drawings are created with large sizes to contain more information on one page. For example, the dimension of ANSI E paper is 34” by 44”. Large drawing is convenient if it can be printed on the designated paper size. However, most home printers can only work with letter size (11” by 8.5”) paper (or similar size like A4); some office printers can handle Ledger size (11” by 17”) paper. To print larger, one must get a professional printer, which is expensive; or go to a print shop, which is inconvenient.

Let me use the City of Windsor’s map as an example. When I try to print it, I can only print it on one page. As the screenshot below shows, the text will be extremely small on the paper; hence, unreadable.

Screenshot when printing large map
Screenshot when printing large map - Map of City of Windsor

I can select a large paper in the print dialog but load my printer with small-size paper. In this way, I can rely on the printer to tiling the large file into multiple small-size papers. Definitely, this is not an elegant solution. I cannot preview the result on my screen, it requires some guess-and-try to print the file correctly.

Another way is to use software to pre-process the file. The software will divide the large file into multiple smaller ones first. Then, we can print the result as normal files. One example is to use the convert command that comes with imagemagick to tiling the image, for example: convert -extract 4800x3600+4800+7200 src.png tile2x3.png. However, this solution requires Linux (or WSL) and installing the software on the computer.

It is also possible to use some online tools. It is convenient because no software is installed, it works for both computer and phone (or anything that has a web browser and has internet access). However, this solution may be prohibited if the file has confidential content, such as engineering drawing.

Therefore, I decided to write this software myself. This software uses PDF-Lib (which I used in my previous project Titleblock Editor) to tile PDF files on a user's computer in an internet browser.

Screenshot when printing large map after tiling
Screenshot when printing large map after tiling