Files
grabowski a2cedcdd7e
CI / secret scan (push) Successful in 5s
CI / fmt, clippy, tests (push) Successful in 39s
Phase 5: the Immigration Bureau's forms, filled in from the records
A Forms tab on each person fills in TM.7, STM.2, STM.9, STM.11 and STM.1
for an extension of stay, TM.47 for a 90-day report and TM.8 for a re-entry
permit. The Bureau's blank pages (forms/, with their sources and checksums)
go unchanged into a new PDF, and the values are written on the dotted lines
in Sarabun; boxes are ticked and the title circled where a form asks.
scripts/gen_layout.py measures the blanks into src/papers/layout.rs.

The tab says what would stay blank and links to where it is added. What only
the application says (the date, the office, the reason, the days, a trip) is
carried in the links and never stored. The extension's five forms also come
in one PDF. Opening or downloading a form is audited as entity "form" with
the forms' codes, never their values.

Migration 0005 adds what STM.1 and STM.11 ask of the company (capital,
revenue, equity, staff, a coordinator), a work permit's salary and contract
dates, and where an arrival came from. The Nix package now takes forms/.
2026-11-18 12:30:03 +07:00

4.0 KiB

The blank forms

The Immigration Bureau's forms that the app fills in (src/papers), kept unchanged as the Bureau publishes them. The app lays each page into a new PDF and writes the values on its dotted lines, so a filled-in form looks like one filled in by hand, only legible.

They come from the downloads of Immigration Division 1 at https://bangkok.immigration.go.th/en/downloads_en/, fetched on November 18, 2026. The STM forms are the versions of 2025. The forms are the Bureau's own, for every immigration office; Chiang Mai Immigration's website offers no downloads of its own.

Form File What it is SHA-256
TM.7 tm7.pdf Application for extension of temporary stay 93bcd4b4fda4a9e88329e313112a6bd6d17a8f604f16392734f72a647fc8b62d
STM.2 stm2.pdf Acknowledgment of the conditions of a temporary stay 0675fcd31ad6ee5ad50ca38f0ba115a82378e81faa7cab1aea22dbfb5335c35e
STM.9 stm9.pdf Acknowledgment of the penalties for overstay c9939371a18e4b8cd74b2a8bc88377ac39f53d9a8049dc28b832917e300eccb6
STM.11 stm11.pdf Consent to the checking of the application 41b86da3094ec86837512f0d3b84871dd75ffed8c70fcd415a33d26704d74612
STM.1 stm1.pdf Certificate of employment, from the employer 591484049f81d8c3c86bc118413b85521fa8935e2d00a7b85c48747e3d790cf1
TM.47 tm47.pdf Notification of staying longer than 90 days 2208dc2aa65f82dc8e2129759d6eb2e8bf1185b271c4e02c3803a527dd5ccbac
TM.8 tm8.pdf Application for a re-entry permit 2bcd666622f0aa99e16e4bcbac8d3eec8c06566d620e3a3d7d9799aaab41920a

Where the values go

scripts/gen_layout.py finds the dotted lines and the boxes in these PDFs and writes src/papers/layout.rs, which says where each value goes. TM.47 has no dotted lines, so its blanks are measured from the lines drawn on it. scripts/form_blanks.py lists a form's dotted lines with their labels, which helps when a form changes:

uv run --with pymupdf python scripts/form_blanks.py forms/tm7.pdf
uv run --with pymupdf python scripts/gen_layout.py

gen_layout.py formats its output with rustfmt, so a rerun on the same forms gives the same file. When the Bureau publishes a new version of a form, replace the file, run gen_layout.py again, update the table above, and check every page of the filled-in form against the blank before the change goes live.

The font

The values are written in Sarabun Regular (fonts/Sarabun-Regular.ttf), the font the forms themselves use, by Cadson Demak, under the SIL Open Font License 1.1 (fonts/OFL.txt), from https://github.com/google/fonts/tree/main/ofl/sarabun.