PDF Marked Content
PDF Marked Content is a mechanism for attaching arbitrary properties to regions of a content stream without affecting rendering. Marked content sequences (delimited by BMC/BDC and EMC operators) can tag content regions with a role (such as Span or Artifact) and a property dictionary, enabling structure tree linking, accessibility tagging, and optional content grouping within the page stream.
PDF marked content sequences are delimited regions within a page content stream — or a form XObject content stream — that associate metadata, tags, or properties with a range of PDF drawing operators. Marked content is the foundational mechanism for two of the most important PDF capabilities: <strong>tagged PDF structure</strong> (which links the structure tree to visible page content for accessibility and reflow) and <strong>optional content</strong> (which associates drawing operators with OCG layers that can be shown or hidden).
Every element in a <a href="https://pdftheguide.com/glossary/pdf-tag-tree" target="_blank" rel="noopener">tagged PDF's structure tree</a> that corresponds to visible content on the page is connected to that content via a marked content sequence. Every operation in a layered PDF that belongs to a specific <a href="https://pdftheguide.com/glossary/pdf-optional-content-group" target="_blank" rel="noopener">optional content group</a> is enclosed in a marked content sequence that identifies the layer. Understanding marked content is essential for working with PDF accessibility, layers, and the internal structure of complex PDFs.
Marked content operators
Three pairs of operators bracket and close marked content sequences in a PDF content stream:
<strong>BMC (Begin Marked Content)</strong> — <code>/tag BMC</code> Begins a marked content sequence with a tag name and no associated properties. Used for simple structural markers where no properties are needed.
<strong>BDC (Begin Dictionary Content)</strong> — <code>/tag <<properties>> BDC</code> or <code>/tag /PropertyListName BDC</code> Begins a marked content sequence with a tag name and an inline property dictionary, or with a reference to a named property list in the page's resource dictionary under /Properties. The dictionary typically contains a Marked Content Identifier (<code>/MCID</code>) for tagged PDF, or an optional content group reference (<code>/OC</code>) for layer membership.
<strong>EMC (End Marked Content)</strong> — <code>EMC</code> Closes the most recently opened marked content sequence. Marked content sequences can be nested — each EMC closes one level.
<strong>MP (Marked Content Point)</strong> — <code>/tag MP</code> A marked content point that marks a position in the stream rather than a range. Used for artifacts like page transitions and structural markers with no associated content operators. Rare in modern PDFs.
<strong>DP (Defined Point)</strong> — <code>/tag <<properties>> DP</code> — The point equivalent of BDC.
Example — a tagged paragraph with MCID 3: <pre><code>/P <</MCID 3>> BDC BT /F1 12 Tf 72 720 Td (This is a paragraph.) Tj ET EMC</code></pre>
Marked content in tagged PDF
In a tagged PDF, every piece of visible content that is part of the logical document structure — headings, paragraphs, list items, table cells — is enclosed in a BDC/EMC pair with a <code>/MCID</code> property. The MCID is an integer that uniquely identifies the marked content sequence within the page.
The structure tree references marked content sequences through <strong>Marked Content Reference (MCR)</strong> objects: <code><< /Type /MCR /Pg pageRef /MCID 3 >></code>. The MCR links the structure element (e.g., a /P paragraph element) to the actual text operators on the page.
<strong>Artifact marked content</strong> — Content that is decorative, presentational, or auxiliary (headers, footers, page numbers, decorative rules, background images) is marked as an artifact rather than given a structure tag. Artifact marking tells screen readers to skip this content:
<code>/Artifact <</Type /Pagination /Subtype /Header>> BDC</code> <code>... header content operators ...</code> <code>EMC</code>
Standard artifact types: <code>/Pagination</code> (headers, footers, page numbers), <code>/Layout</code> (decorative rules, column separators), <code>/Page</code> (background imagery), <code>/Background</code>.
<strong>Nesting and boundaries</strong> — Marked content sequences can be nested but must be properly closed. Each BDC or BMC requires exactly one EMC. Structure element content can span multiple marked content sequences (even on multiple pages in a tagged PDF, a single structure element's content can be distributed across multiple MCIDs). The structure tree maintains the logical grouping; the MCIDs provide the page-content linkage.
Marked content in optional content (layers)
<a href="https://pdftheguide.com/glossary/pdf-optional-content-group" target="_blank" rel="noopener">Optional Content Groups (OCGs)</a> — PDF layers — use marked content to associate drawing operators with a specific layer. The <code>/OC</code> property in a BDC sequence identifies the OCG:
<code>/OC /Drawings BDC</code> <code>... all drawing operators for the "Drawings" layer ...</code> <code>EMC</code>
The <code>/Drawings</code> name references the OCG object via the page's /Properties resource dictionary. When the layer is hidden, the viewer skips all drawing operators within the <code>/OC /Drawings BDC ... EMC</code> sequence.
<strong>Interaction with tagged PDF</strong> — A document can use both structure tags (for accessibility) and optional content markers (for layers) in the same content stream. In this case, marked content sequences can be nested: a tagged structure element's BDC/EMC can contain an OC-marked sequence, or vice versa. PDF viewers must correctly handle both simultaneously — showing/hiding layer content while also providing the structure tree for accessibility.
<strong>Optional Content Membership Dictionaries (OCMD)</strong> — More complex layer visibility conditions (show if layer A is on AND layer B is off) use OCMDs referenced from marked content sequences, enabling complex conditional content behaviour without requiring separate content streams per visibility state.
Frequently asked questions
What is an MCID and how is it used?
MCID (Marked Content Identifier) is an integer value stored in the property dictionary of a BDC marked content sequence that uniquely identifies that sequence within its page. Each content sequence that corresponds to a structure element in the document's logical structure gets a unique MCID on its page. The structure tree element (e.g., a /P paragraph) contains a Marked Content Reference (MCR) object that specifies the page reference (/Pg) and the MCID (/MCID) — this MCR is how the abstract structure tree connects to the actual drawing operators on the physical page. MCIDs are per-page — the same integer can be reused on different pages without conflict. Structure elements that span multiple pages have multiple MCRs, each pointing to the appropriate page and MCID for that page's portion of the element.
How do I find marked content sequences in a PDF?
You can inspect marked content sequences by examining the decompressed page content streams. With qpdf: qpdf --qdf --object-streams=disable input.pdf output.qdf produces a human-readable version of the PDF where all streams are decompressed. Search the output for BMC, BDC, and EMC operators to see marked content sequences. In Adobe Acrobat Pro: Tools > Accessibility > Reading Order opens a panel that visually highlights the marked content regions on the page and shows their tag types. The Tags panel (View > Show/Hide > Navigation Panes > Tags) shows the complete structure tree with links between structure elements and their marked content sequences. For programmatic inspection, pypdf provides access to page content streams via page.extract_text() and lower-level object access.