Both Sources Had Bookmarks, the Merge Kept None: Our A+B Run Read Back an Empty Outline

The number that closed today's question: 0 entries from 6. We built two PDFs that each carried a genuine outline — file A with 4 entries including two nested level-2 rows (the same nested shape as our nesting-levels deck), file B with 2 flat level-1 entries — merged them in that order, and read the merged file's outline back: an empty list. Page flow itself was intact (A's three pages then B's two), so the merge output looks normal in a viewer while all six bookmarks are gone. This is the pass-through experiment our round-trip page explicitly left unmeasured: if a source outline is non-empty at merge time, does it come through? Our run says no — not one entry. No prices, no accuracy claims, nothing described as measured that we did not run.

The A+B run, read back line by line

File in our runOutline read-back (verbatim)What it says
Source A: 3 pages, outline set before first save[[1,'A-H1',1],[2,'A-Child',1],[2,'A-Child2',2],[1,'A-H2',3]]A's outline exists on disk with nesting intact
Source B: 2 pages, outline set before first save[[1,'B-Only',1],[1,'B-Second',2]]B's outline also exists — this run differs from yesterday's, where every file on the bench started from the same outline
Merged A+B, read straight from the saved file[]Neither outline made it across; the merge built its output from page objects alone

Why we expected pass-through and did not get it

Yesterday's round trip had one confound: the sources were split before merging, so empty outlines at merge time were expected. Today removed that confound — both sources carried their outlines at the moment of the merge call — and the result did not change. That pins the loss on the merge step itself in our toolchain: insert_pdf copies page content but not the outline tree, and it does so regardless of what the sources hold. Practical consequence for anyone filing or searching merged output: the table-of-contents pane, a converter keying headings off bookmarks, or an archive indexer reads nothing, and nothing on screen warns you. The pages are all there; only the navigation layer is missing.

The one-line rebuild for two sources (and the order bug we avoided)

The fix follows the same pattern as yesterday: hold each source's outline read-back, then write the combined list onto the merged document before saving. One detail our run had to handle that yesterday's did not — page offsets. A's entries pointed at pages 1 and 3, which stay put in A+B order. B's entries pointed at pages 1 and 2 of a five-page B, but in the merged file B's content starts on page 4, so both B targets shift up by 3 before the rebuild lists them. Writing the raw source list without the shift would have produced bookmarks pointing at the wrong pages — we state that as an inference from the page-number arithmetic, not as a measured mis-click, since we did the shift correctly and our read-back came back pointing where we aimed. Our A+B rebuild read back all 6 entries in merged order, A's nested rows first, then both of B's rows at their shifted targets.

Today's run in one picture: two outlined sources in, empty outline out, and the rebuild order with B's page targets shifted by A's page count.
SOURCE A · 4 entries (2 nested) 3 pages · targets p1, p3 SOURCE B · 2 entries (flat) 2 pages · targets p1, p2 MERGED A+B · 5 pages outline read-back: [] 6 bookmarks expected → 0 kept rebuild: A as-is, B targets +3 (A's page count) MERGED_FIXED · 6/6 A rows then B rows, B targets at p4, p5

Quick FAQ

If both PDFs have bookmarks, does merging keep them?

In our run it kept none: two outlined sources merged into a file whose outline read back empty, even though neither source was empty at merge time. A merge combines pages; your bookmark lists need a separate rebuild.

Do merged bookmarks keep their original order?

The only order to report is the one we wrote after rebuilding: A's outline rows first (in A's original order, targets unchanged), then B's rows. The merge tool contributed no ordering because it contributed no bookmarks at all — the order in the fixed file is the order we wrote, verbatim read-back.

My merged file shows views fine. Is anything wrong?

Pages are all present — the loss is invisible in a viewer. Our A+B file opened with five pages of content and an empty bookmark list; the symptom only appears when something reads the outline. If your downstream steps key off bookmarks, check the outline read-back before they run, not after.

What about page numbers in rebuilt bookmarks?

Sources after the first need their targets shifted by the page count of everything before them. In our A+B file, B's rows moved from targets 1–2 to 4–5. We write that as arithmetic we applied and verified by read-back, not as a behavior claim about A+B-style files in general beyond our five-page run.

What we could NOT test — refused to guess

- Whether a merge flag or option in our toolchain exists to copy source outlines without rebuilding — not run. Reason: our runs used plain insert_pdf with no options; enumerating or testing undocumented options was out of scope today, and describing one untested would be a guess.

- Three or more sources in one merge — not run. Reason: today's bench was two sources; A+B offsets, our line for tomorrow: the shift arithmetic extends but we will not claim the extension works until we run it.

- Bookmarks that point at destinations other than pages (named destinations) — not run. Reason: our sources used plain page-target entries; mixed destination types change what the read-back means and we did not build them.

Decision rule this run supports

- Merging outlined PDFs for indexing, archiving, or anything that reads bookmarks: read every source outline before merging, hold the lists, rebuild with first-source offsets unchanged and later-source targets shifted by the pages before them, then read back. Our run kept 0 of 6 without this and 6 of 6 with it.

- Merging where you never look at bookmarks: no action needed from this gap — the pages survive, same as our read-backs showed. Just know the outline pane will be empty.

This page answers the pass-through question the round-trip run left on its not-run list, using the same toolchain and the nested deck from the nesting page. Bookmark pdf2mdtool.com — tomorrow's judge: three sources in one merge, with the shift rule put to the test.