프로젝트 기록

PROJECT RECORD

Combining 2,134 archived web files into reading PDFs

EN 한국어

My saved classical-text study material was scattered across MHTML files. The format bundles a web page and its resources into one archive, but separate files were awkward to read as a book. I wanted PDFs I could read in sequence, grouped by folder and supplied with bookmarks.

The target was one archive file per PDF page, retaining the proportions of the screen rather than reflowing the material onto A4 sheets. I specified the menus and headers to remove. AI coding assistance helped build the conversion script and investigate rendering failures.

Finding elements rather than cropping coordinates

The unwanted controls did not occupy identical positions in every file. The cleanup code locates headers and study tools by element identifiers and removes footer blocks beginning with known labels. That gave it more context than a fixed crop distance. Cleanup happens in the page being rendered; the script does not save over the original MHTML.

Filenames are naturally sorted, treating embedded numbers as numbers so that section 2 precedes section 10. The merge step then adds a bookmark at the first page contributed by each file.

Measuring content before setting the PDF size

Removing a menu can leave an empty container that still affects the page height. The revised measurement looks at the ends of visible leaf elements containing text or images. It allows 24 pixels below the content and, within the normal height range, another 8 pixels for printing differences. Rendering remains at scale 1.

A separate problem involved a style-injection call that did not finish for MHTML. The final script creates the style element directly and fixes the document height to the measured value. That addresses a different failure from the few extra pixels that produced an unwanted second sheet. Very tall inputs have a fallback, so one file per page is a target to verify for this collection, not a universal guarantee.

Keeping the intermediate PDFs

Individual PDFs are stored separately and read again for the merge. On resumption, an existing file above a minimum size is skipped, avoiding a complete rerender after a late interruption. File size is only a reuse check; it does not establish that the PDF’s content is correct.

The 15 August run recorded four merged files of 82, 149, 884 and 1,019 pages, totalling 2,134. A read-only check of the preserved inputs and PDF structures on 7 September found 2,134 MHTML files, 2,134 PDF pages and the same number of bookmark entries.

The run’s zero-failure figure counts reported conversion errors. It is not a page-by-page finding that no text was omitted or clipped. The September check likewise counted files, pages and bookmarks; it did not repeat a full visual audit.

The result is four private reading files. External use was not measured, and redistribution rights for the sources and converted files remain unverified. No source text, page images or downloads are included here. I reorganised the reading order and file format rather than creating or releasing the underlying material.

연구 목록 · 작업 목록

Research index · Work index

Discover more from Woong Works

Subscribe now to keep reading and get access to the full archive.

Continue reading