Round-Trip Split + Merge Wiped Our Outline to Zero Entries — One set_toc Line Brought All 4 Back

The number that started this run: 0 bookmarks after merge. We built a 4-page PDF whose outline carried 4 entries (2 level-1 rows, 2 nested level-2 rows) — the same nested deck shape we measured on the nesting-levels page — split it into three single-page parts, merged the parts back together, and read the outline from the saved merged file: an empty list. The page content returned intact (1729 B versus 2466 B originals, all four pages present), so nothing on screen announces the loss. Writing the 4-entry list back with one set_toc call before saving produced a 2340 B file whose outline read back identical, entry for entry. Everything below is a verbatim readback from today's runs; the empty-split-parts finding answers the question we left on the metadata page's not-run list. No accuracy claims, no prices, and nothing we did not execute is described as if we did.

The round trip, read back step by step (today's run)

Step in our runOutline read-back (verbatim)File sizeWhat it says
Source deck: 4 pages, outline set with 2×L1 + 2×nested L2 entries before first save[[1,'Intro',1],[2,'Child A',1],[2,'Child B',2],[1,'Details',3]]2466 BThe outline exists and is nested exactly as written
Split into three single-page parts; read each part's outline from its saved file[] in all three parts812 B eachSplitting already strips the outline — this was on yesterday's not-run list and it is now measured
Merge the three parts back into one file; read its outline[] — empty after merge1729 BPage content survives the round trip; the outline does not, so the merge output gave no warning either
Same merged document, plus one set_toc call with the 4-entry list before saving; read it backThe same 4 entries, identical order and nesting2340 BThe rebuild reads back clean — the fix is one line, at write time, same pattern as the title fix we ran on the metadata page

Why the outline vanishes in both steps (what the run shows)

Same shape as the title loss we measured earlier: outline data does not live on the page — it lives in a separate tree, and both the splitter and the merger here built their output from page objects alone. Our run pins the timing: the outline was already gone at the split step (all three parts read back empty), so by merge time there was nothing left to carry forward. This matches the behavior we documented on the split-and-merge comparison page for content, but extends it one level deeper: viewers show merged pages fine, and the symptom shows up later, in whatever reads bookmarks — a table of contents pane, a converter that labels headings from the outline, or a filing system.

The one-line rebuild, and what it does NOT restore

merged.set_toc([[1,'Intro',1],[2,'Child A',1],[2,'Child B',2],[1,'Details',3]]) — called on the merged document object before saving. Our fixed file read back all 4 entries identical, nested rows and all, and the size landed at 2340 B. What the line does not do, per this run: it cannot invent the outline for you. If you no longer hold the source outline list (for example, the parts came from someone else), you must read it from those sources before they are split, because measure says the parts will not carry it. The instruction table for the list is the source's own get_toc output — our earlier bookmark-rebuild page used exactly that read-back as the rebuild input.

Our round-trip run in one picture: outline present at the source, empty in every split part and in the merged output, present again after the one-line set_toc rebuild.
Before: 4 entries (2×L1 + 2×L2) source 2466 B · outline read: 4 rows SOURCE · outline 4/4 split 3 parts · outline [] [] [] each part 812 B, zero rows merge MERGED · outline 0/4 1729 B, pages intact one set_toc call MERGED_FIXED · outline 4/4 read back 2340 B · identical to source list

Quick FAQ

Do bookmarks survive splitting a PDF?

In our run they did not survive at all: all three split parts read back an empty outline, even the part holding the source's level-1 rows. Treat the parts as outline-less from the moment you save them, and keep the source's outline list if you plan to rebuild.

Does merging afterwards fix the outline?

No. Our merged output read back 0 entries because by then every source part carried an empty outline. Merging never adds bookmarks; it can only pass through what the sources have — and ours had none.

How do I keep my outline through a split-and-merge workflow?

Read the outline from the source before splitting, hold that read-back list, then call the rebuild with that exact list on the merged document before saving. Our round trip restored all 4 entries with one call, identical readback, at 2340 B.

Does the fixed merged file differ in other ways?

Size moved 1729 B → 2340 B in our run — the extra space is the outline structure itself. Page content was identical across the whole round trip in our reads; we did not diff beyond the outline, page count, and file size, and we will not claim anything about fields we did not measure.

What we could NOT test — refused to guess

- Outline recovery in a single split step (writing the part files while re-adding only their own slice of the outline) — not run. Reason: our split saved files first and checked after; a write-time re-add was not configured, and describing a configuration we did not execute is a guess.

- pypdf's behavior in the same round trip — not run today. Reason: today's bench was PyMuPDF only; the metadata page showed the two libraries diverge at write time, so we will not transfer today's PyMuPDF numbers to pypdf.

- Whether page-target annotations inside the outline (links on page text pointing at outline targets) survive the round trip — not run. Reason: our source outline carried navigation data only; annotation targets are a different structure we did not place in the test deck.

Decision rule this run supports

- Round-tripping PDFs through split + merge and the output feeds anything that reads bookmarks: read the source outline first, hold the list, rebuild before saving — one call, read it back. Our run shows every other step in the round trip reports empty.

- Splitting for archival parts only: nothing to do on outline — you are choosing to drop it knowingly, and the parts still open with all their pages (812 B each read back clean).

- Merging files that DO each carry outlines: today's run does not cover whether a merge passes a non-empty source outline through. That sits unmeasured on the not-run list until we execute it.

This page uses the nested-outline deck measured on the nesting-levels page and closes the outline question the metadata fix page listed as not-run. Bookmark pdf2mdtool.com and follow along.