Building the SugarDoc HWP viewer, from design review to hostile files
We picked an engine that opened 221 of 222 Korean HWP files, then built and shipped an Android document viewer with an AI agent in October 2026. Eight parts, in build order.
What this series found
- Before any code, three judges with different roles scored three agent-written designs in 59 minutes. The market-minded judge ranked first a design that would crash on every document opened from KakaoTalk, Korea's main messenger, and the review surfaced 23 gaps in the final plan. (Part 1: three designs, three judges)
- The open-source rhwp engine, running in a WebView, opened 221 of 222 HWP and HWPX files on a Galaxy S21 (October 3, 2026). Drawing only the visible pages of a 384-page file cut renderer memory from 2.8 GB to 255 MB. (Part 2: rhwp measured)
- The same .hwpx arrived with Hancom's MIME type from Samsung My Files and as application/octet-stream from Chrome. A viewer that accepts only document MIME types drops out of the "Open with" list, so we fixed the manifest against an 18-row intent matrix. (Part 3: hwpx and intent filters)
- androidx.pdf runs your Application.onCreate in its isolated process too. A release build without a first-line guard never opened a PDF and never reported an error; with the guard, a 5-page PDF opened in 81 ms on the same phone. (Part 4: the isolated process)
- A save gate that diffs edited files record by record blocked both form-field documents we tried. Rather than loosen the gate, we shipped 1.1.0 with editing behind a build flag and turned a narrower edit on nine days later. (Part 6: the edit save gate)
This series is for Android developers building an app that opens HWP files, Korea's common word-processor format, or PDFs. If you are choosing a rendering engine, start with Part 2; if files shared from other apps never reach yours, start with Part 3. If you plan to let an AI agent design the app, read Part 1 first. For release checks, read Part 5 on PDF save (BACK pressed at 7 points, 0 empty files left), Part 7 on Hancom compatibility (all 7 edited files opened) and Part 8 on a set of 50 hostile documents, in that order.
Series contents
- Part 1Three agent designs, three judges: the market judge alone would have picked the one that crashed on every KakaoTalk file
Before coding a document viewer, 3 agent designs competed and 3 judges scored them.
- Part 2Building an Android HWP viewer: rhwp in a WebView, measured on 222 documents
The open-source rhwp engine in an Android WebView opened 221 of 222 Korean HWP/HWPX files on a Galaxy S21; a 384-page file needed virtual scrolling.
- Part 3On Android, HWPX can arrive as application/octet-stream: an 18-row intent matrix and the intent filter that fits it
The same .hwpx reached our viewer as a Hancom MIME type from Samsung My Files and as application/octet-stream from Chrome and Files.
- Part 4androidx.pdf beta01 runs your Application.onCreate a second time, in an isolated process, and the PDF silently never opens
androidx.pdf beta01 parses PDFs in an isolated process that also runs your Application.onCreate.
- Part 5We pressed BACK at seven moments before shipping one 'Save as PDF' button
We pressed BACK at 7 delays during a direct SAF Save as PDF on a release build.
- Part 6We built an edit feature and shipped it switched off: the HWP save gate that caught a form-field bug
A gate that diffs edited HWP files record by record caught a form-field bug.
- Part 7Seven edited HWP files in Hancom's Android apps: 7 of 7 opened, and the re-save waited for a human sign-in
Seven HWP files edited by SugarDoc, checked in Hancom's two Android apps on a Galaxy S21: all 7 opened cleanly; 2 of 2 re-saved after the operator signed in.
- Part 8A malicious file set for a document viewer: ZIP bombs, CFB loops and XSS, generated and wired into tests
Our Korean document viewer generates 50 hostile files in Python and checks each verdict in unit tests.