Commit Graph
53 Commits
Author SHA1 Message Date
aiongg 4bc6768fb0 feat: write vertical story orientation
A text frame's multi-column frame stores a matrix (chunk 0x2DE) that is
the identity for horizontal text and a quarter turn for vertical text.
A story whose frames all have the quarter turn is written Vertical
instead of the Horizontal every sample's IDML has.
2026-10-07 04:27:07 +00:00
aiongg 6a357f4287 feat: write the Kanji page number style
Section style code 0x4C12 is Kanji, shown by the Chinese-numeral folios
of a vertically typeset sample's print PDF. Pages in such a section are
named with Chinese digits, as the folios show.
2026-10-07 04:26:16 +00:00
aiongg 9fef3b0516 feat: read the page binding
DocumentPreference PageBinding comes from the document preferences
(u16 at 64) instead of the value every sample's IDML has. A vertically
typeset sample bound on the right stores 1, RightToLeft.
2026-10-07 04:25:39 +00:00
aiongg 7c89bdfe8a fix: write only colour models the samples show
Code 1 is Spot in two pairs; code 3 has no sample, so its Model is now
left out with a warning instead of written as MixedInkModel.
2026-10-07 04:15:57 +00:00
aiongg a9985b3775 fix: validate every corpus output and fix the two schema failures
compare.py --all now also converts the INDD and INDT files that have no
same-version IDML (any version, either byte order), validates them and
counts converter warnings by kind. validate.sh runs Jing once per schema
instead of once per file, which makes validating the whole corpus take
about 3 minutes.

Two schema failures showed up in files without an IDML:

- Gradient swatch midpoints are stored as positions from the start of
  the gradient. IDML wants them relative to the gap between two stops,
  as for opacity gradient stops. Values outside 13-87 are left out with
  a warning.
- The style kind is a u16, not a u32. One InDesign 7.5 template has a
  non-zero u16 after it, which made 151 character styles paragraph
  styles.
2026-10-07 03:50:08 +00:00
aiongg 1d0e27db32 feat: convert big-endian files from InDesign 3.0 and 4.0
The byte order flag applies to object data only: database pages stay
little-endian. Object data is decoded in the file's byte order, and in
big-endian data the string tag and the flag byte before it are swapped.

The two big-endian samples are also the only files from before
InDesign 7.0, and some of their layouts differ: page transform and
bounds chunks, font records, XML tag names and nodes, story strands and
40-byte guide records are read; text frame settings, document
preferences, a composite font and a section style are left out with a
warning. The 40-byte guides of an InDesign 7.0 file are now read too.

docs/format/big-endian.md records the evidence. The corpus tests now
cover all byte orders.
2026-10-07 03:11:04 +00:00
aiongg 496c3e5d65 feat: convert the XML structure
Read the XML nodes stored with each story, place their markers in the
story text and write the backing story as XmlStory, with the elements
in it and in the stories they tag. Element Self names follow the node
IDs from the root down. The backing story is added to StoryList.
2026-10-07 02:42:17 +00:00
aiongg b0e0d7f4f6 docs: record why the font family technology suffix is not predicted 2026-10-07 02:27:40 +00:00
aiongg 56b59e1319 fix: count story positions in characters, not UTF-16 units
Text records count UTF-16 code units, but style runs, owned items and
text owners count a surrogate pair as one position. Convert those
positions to UTF-16 offsets so characters outside the Basic Multilingual
Plane keep their formatting and are not split into two replacement
characters.
2026-10-07 02:27:40 +00:00
aiongg 201697c779 feat: convert XML tags
XML tags (class 0xBF19) hold their name in chunk 0xBF2F and refer to an
interface colour in chunk 0x117. Write them in XML/Tags.xml, sorted by
name as IDML lists them.
2026-10-07 01:44:20 +00:00
aiongg 7bde5098a6 feat: convert anchored object offset and vertical alignment
Anchors and object styles hold anchored object settings in chunk
0x2800: the Y offset at 0 and the vertical alignment at 52. Write them
on object styles, and on anchored items where they differ from the
item's object style.
2026-10-07 01:43:24 +00:00
aiongg 537af3af4d feat: convert the bullet character list
The preferences object lists the bullet characters offered for lists in
chunk 0x1A488. Write them as ABullet elements.
2026-10-07 01:42:37 +00:00
aiongg 44c85c5a54 feat: write export options of page items
Every page item in the corpus IDML files from DOM 12 on has the same
ObjectExportOption, and every rectangle, oval and polygon the same
InCopyExportOption. Write them from that observation.
2026-10-07 01:41:55 +00:00
aiongg 32c74f5c6b feat: convert inks and colour groups
Write an Ink for each ink object (class 0x1F07) with its neutral
density, trap order, frequency and angle, and the colour groups listed
in the preferences (chunk 0x1F61) with their swatches.
2026-10-07 01:41:10 +00:00
aiongg 9eba4eea66 feat: convert composite fonts, kinsoku tables and mojikumi tables
Read the composite font and its entries (classes 0xCB02 and 0xCB03):
name, font, style and custom characters, and the kinsoku and mojikumi
tables with the character lists of a custom kinsoku table.
2026-10-07 01:40:31 +00:00
aiongg 3f4a68dfe6 feat: write object style settings for every object style
Object styles other than [None] now get their text frame, story, text
wrap and frame fitting settings, fill, stroke and corner attributes,
applied paragraph style and some category flags from the INDD (chunks
0x1B92B, 0x1B924, 0x285B, 0x50F28, 0x3776, 0x3777, 0x1B92E, 0x1B946),
and the values every such style has in the corpus IDML files, collected
by tools/root_values.py into src/idml/object_style_values.xml. The root
style gets the same INDD values in place of observed ones.
2026-10-07 01:33:21 +00:00
aiongg 4ff4dd03e0 feat: convert frame fitting and clipping path settings
Frame fitting attributes are in the page item attribute list and, for
object styles, in chunk 0x1B956. Write FrameFittingOption on rectangles,
ovals, polygons and object styles, ClippingPathSettings on images, PDF
and EPS graphics from chunk 0x2C1A, and ImageIOPreference on images from
chunk 0x8C39.
2026-10-07 01:26:02 +00:00
aiongg 2694a9ea43 feat: write story preferences and story values every IDML has
Every story in the corpus IDML files has the same StoryPreference and
InCopyExportOption, and the same TrackChanges, StoryTitle,
AppliedNamedGrid, UserText and IsEndnoteStory (the last two from DOM 12
and 15). No INDD field for them is identified, so they are written from
IDML observation.
2026-10-07 01:21:28 +00:00
aiongg c938df6f0b feat: convert page margins, columns and layout grid
Pages store margins (chunk 0x51A) and columns (0x528) with a flag that
says whether they are the page's own; otherwise the master page at the
same position supplies them. Write MarginPreference from the values in
effect and GridDataInformation from chunk 0xCD02.
2026-10-07 01:13:34 +00:00
aiongg 0dc40563ab feat: write preference values that every exported IDML has 2026-10-07 00:35:38 +00:00
aiongg c976451c2f feat: convert cell formatting, cell and table styles, and table attributes 2026-10-07 00:24:59 +00:00
aiongg 9594ac557b feat: convert tint swatches 2026-10-07 00:04:23 +00:00
aiongg ccda8898e9 feat: convert page item transparency: opacity, blend mode and effects 2026-10-06 23:55:15 +00:00
aiongg 146afc2cf7 feat: convert cross-reference formats
Read cross-reference formats (class 0x1355E) and their building blocks
and write them to designmap. Evidence is in
docs/format/cross-references.md.
2026-10-06 23:23:45 +00:00
aiongg 78b05c7687 feat: convert hyperlinks, text sources, destinations and bookmarks
Read hyperlinks (class 0x13501), text sources (0x13502) with their text
ranges from the story's range tree, page and URL destinations and
bookmarks, and write them to designmap and the stories. Evidence is in
docs/format/hyperlinks.md.
2026-10-06 23:16:28 +00:00
aiongg 3ca668e96e feat: convert text variables and their instances
Read text variable definitions (class 0xCAB4) into designmap TextVariable
elements with their settings, and write instances (class 0xCA64) as
TextVariableInstance elements in place of U+0018. Evidence and the
settings left out are in docs/format/text-variables.md.
2026-10-06 23:03:09 +00:00
aiongg 4014eea106 feat: write font families and fonts in Fonts.xml
Read the font records of class 0x3E03 (chunk 0x3E05) and the Typekit IDs
(chunk 0x3EEB), and write FontFamily and Font elements. Evidence and the
fields left out are in docs/format/fonts.md.
2026-10-06 22:55:45 +00:00
aiongg 3490507fbf feat: convert stroke type and stroke alignment
Decode page item attribute 0x6E6E (a reference followed by a built-in
stroke style code) as StrokeType and 0x6E8C as StrokeAlignment, with
evidence from items and from object style attribute lists. Write the 18
built-in stroke styles every exported IDML lists.
2026-10-06 22:28:29 +00:00
aiongg 358fb2dbe1 feat: convert ruler guides
Read guide objects (class 0x3301, chunk 0x3308) from spread layers and
write them as Guide elements in their page: orientation, location, fit to
page, guide type, item layer, and the view threshold and colour values the
samples show. Locations are measured from the spread, and ViewPreference
states RulerOrigin SpreadOrigin to match.
2026-10-06 22:20:45 +00:00
aiongg 36b7ae9eaf feat: write root style values that every exported IDML has
Collect the root style attributes, Properties and child elements that are
the same in every corpus IDML (tools/root_values.py) and write them on the
root paragraph, character, object, cell and table styles. Values read from
the INDD take precedence; values that first appear after DOM 7 are gated
by InDesign version. Also write the default numbering list, and write a
style only once when two style objects share a name.
2026-10-06 22:04:05 +00:00
aiongg 327eaee967 docs: state nested-style evidence in general terms; stop tracking __pycache__ 2026-10-06 21:15:29 +00:00
aiongg d5d2e1451e feat: convert keep lines, nested styles, tab stops, languages and more text attributes
Adds KeepLinesTogether, AllNestedStyles, TabList, AppliedLanguage,
RightIndent, BaselineShift, VerticalScale, NoBreak, OTFFigureStyle,
Position, SingleWordJustification, ParagraphBreakType, rule above
indents and width, RuleBelow and its colour, span columns, paragraph
shading and border on/colour/top/bottom offsets, SameParaStyleSpacing,
grid alignment, text gradient fill, EndJoin, and bullet and numbering
attributes. Four-byte values of numeric attributes are now written,
which fixes DropcapDetail. Evidence is in docs/format/attributes.md.
2026-10-06 21:14:52 +00:00
aiongg 6475d01841 docs: describe evidence from the non-public sample in general terms 2026-10-06 20:31:49 +00:00
aiongg e1acc98fa8 feat: convert start paragraph, drop caps, letter spacing and first baseline offset
Map paragraph attributes 0x1B37 (StartParagraph), 0x1B0D and 0x1B0E
(drop cap characters and lines), 0x1B31 and 0x1B32 (maximum and minimum
letter spacing), and the text frame's first baseline offset code in
chunk 0x2CE. Evidence is recorded in docs/format.
2026-10-06 20:30:55 +00:00
aiongg 18206fca5b feat: convert small caps, jump and bounding-box wrap, and Roman page numbers
Capitalization codes 1 (SmallCaps) and 3 (CapToSmallCap), text wrap
modes 1 (JumpObjectTextWrap) and 3 (BoundingBoxTextWrap) with offsets
stored as left, top, right, bottom, and page number style 0x4C17
(LowerRoman) with Roman page names. Evidence in docs/format.
2026-10-06 19:51:56 +00:00
aiongg b0658ad13a feat: convert text wrap mode of page items and graphics
Read chunk 0x3703 (mode, offsets, flags) and the contour type in chunk 0x373D, and write TextWrapPreference for page items, groups and placed graphics. Modes 0 (None) and 6 (Contour) are written; other modes are left out with a warning. Offsets are written only when all are 0, since their order is not known yet.
2026-10-06 19:02:02 +00:00
aiongg 12611569cf docs: note capitalization codes without IDML evidence 2026-10-06 18:56:13 +00:00
aiongg 950dec81ce feat: convert all sections of a document
Read each section's first page and page number style from chunk 0x4C02, sort sections by their first page, and write one Section per section with its length. Write PageNumberStart only when numbering restarts, and PageNumberStyle only for the Arabic style seen in the corpus. Pages are named by their number in their section.
2026-10-06 18:55:34 +00:00
aiongg 38a9154bc5 feat: write the applied master of master pages
Master pages use the same chunk 0x140F as document pages. Write AppliedMaster and MasterPageTransform for them too: "n" and the identity matrix when the chunk is absent or empty, as in all corpus pairs, and the named master spread otherwise.
2026-10-06 18:48:01 +00:00
aiongg 5c024c0413 feat: convert embedded and pasted graphics with their contents 2026-10-06 18:22:23 +00:00
aiongg 534e37549a feat: convert gradients and corner and gradient item attributes
Read gradient swatches (stops, locations, midpoints, type) and write them
to Graphic.xml after the swatches, as the schema requires. Write
CornerOption, CornerRadius and gradient start and length on page items.
Decode unknown 4-byte attribute values as numbers.
2026-10-06 17:43:37 +00:00
aiongg 69573c8461 feat: convert document and text frame preferences
Write DocumentPreference (page size, facing pages, bleeds, intent) and
TextFramePreference (columns, gutter, column width, vertical
justification, auto-sizing). compare.py now also compares child elements
without Self and the preference elements.
2026-10-06 17:26:36 +00:00
aiongg f6fb4e7ae4 feat: convert tables
Read tables owned by U+0016 in story text: row, column, header and footer
counts, column widths, row heights, cells with their spans, and cell text
assigned through the text owner strand. Write Table, Row, Column and Cell
elements, including tables nested in cells.

convert() now returns warnings for content it had to leave out, and the
CLI prints them.
2026-10-06 16:57:40 +00:00
aiongg 2da8d4eb7c feat: convert style groups, object styles, master names and sections
Write the style hierarchy with root and nested groups and path-qualified
style references, object styles with AppliedObjectStyle on page items,
master spread names and prefixes, and sections with their numbering.
Keep negative zero in numbers, as IDML does.
2026-10-06 16:45:43 +00:00
aiongg a4d9f0d882 feat: convert placed images, PDF, EPS and SVG with links
Read graphics inside frames (transform, bounds) and their links and link
resource URIs, and write them as Image/PDF/EPS/SVG elements with Link
children. Frames with graphics get ContentType GraphicType.
2026-10-06 16:39:56 +00:00
aiongg 7b7d5c2452 feat: convert items anchored in text
Read the owned-items strand of stories and write anchored page items in
place of their U+FFFC character. Record that the third object tree lists
deleted UIDs, which no live hierarchy references.
2026-10-06 16:37:23 +00:00
aiongg 5f87710d92 feat: convert text formatting
Parse attribute lists in style objects and in paragraph and character
style runs, and write 40 text attributes (font, style, size, leading,
colour, tracking, kerning method, indents, spacing, justification,
underline, rules, hyphenation and more) on styles and text ranges. Read
font family names.

tools/compare.py now also compares text range attributes at matching text
offsets; every mapped attribute matches the reference in all ranges.
2026-10-06 16:33:53 +00:00
aiongg 0e20d76f2a feat: convert colours, fill and stroke, and style hierarchy
Decode colour swatches (name, model, space, values, override, flags) and
the None swatch, and write them to Graphic.xml. Parse attribute lists and
write page item fill colour and tint, stroke colour and weight, and miter
limit. Write BasedOn of root styles as a string, as IDML does. Write forced
line breaks as U+2028 and keep surrogate pairs intact across text runs.

Document the object, chunk and attribute formats with their evidence.
2026-10-06 16:25:07 +00:00
aiongg 1d96bb61ae feat: read the class and unclassed-UID trees
The master page holds three tree roots and counts: objects, the class of
each UID, and UIDs without a class. Database::class_of returns an
object's class ID, and `indd objects` prints it.
2026-10-06 16:01:30 +00:00
aiongg 326a851346 feat: read the object database
Decode the database pages: page trailers and types, the logical page
table, the object B+ tree keyed by (UID, segment), data pages, slotted
pages and continued records. Database::object returns any object's byte
stream. Add `indd objects` and `indd object` commands.

Every object of all 351 little-endian corpus files reads without an
inconsistency. Big-endian databases report Unsupported for now.

Add a project CLAUDE.md with the clean-room rules.
2026-10-06 15:57:48 +00:00