How Vue 3 and pdf-lib Enable Browser-Based PDF Splitting by File Size
A developer tutorial on DEV Community outlines how to build a browser-based PDF splitter that divides files by target size using Vue 3 and the pdf-lib library. Unlike splitting by page count, size-based splitting is complex because PDF file size varies widely depending on image resolution, font embedding, and content type. The proposed approach uses greedy page accumulation, incrementally saving the PDF after each page addition to estimate byte size rather than relying on simple arithmetic. When a page would push the current chunk over the size limit, the tool closes that file and begins a new one, ensuring no pages are lost even if a single page exceeds the target. The finished tool packages all output chunks into a ZIP file and includes user-selectable compression levels and a progress indicator for handling large documents.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in