Publishing files fall into two groups. Some record what the content means, such as XML, EPUB and HTML. Others record what the page looks like, such as PDF and InDesign files. Formats in the first group carry text, structure and metadata explicitly, so extraction is mostly a matter of reading the markup. Formats in the second group carry positioned glyphs, frames and images, and reading order, headings and paragraphs have to be reconstructed. Knowing which kind of file you hold tells you how much work it will take to turn it into clean, structured text.

This guide explains what each common publishing format contains: PDF (including tagged PDF and PDF/A), XML vocabularies such as JATS, DocBook and NewsML-G2, IDML, INDD, EPUB, SVG and HTML. For each one it covers how text, structure, images and metadata can be extracted, and the mistakes that most often corrupt the output. A comparison table and a practical extraction order follow at the end.

Key takeaways

  • Where you have a choice, extract from the most structured version of a title: XML or EPUB first, then IDML, then tagged PDF, then untagged PDF, with OCR of page images last.
  • An untagged PDF stores glyphs and positions, not paragraphs, so reading order, ligatures, hyphenation and page furniture all have to be repaired during extraction.
  • In IDML, text lives in stories and layout lives in spreads, so you need both to put an article's text into page order.
  • EPUB is a ZIP of XHTML files plus a package document whose spine gives the reading order and whose metadata identifies the publication.
  • Check fonts, linked images and character encoding before bulk extraction, because missing resources cause silent errors.

PDF, tagged PDF and PDF/A

PDF is defined by ISO 32000. ISO 32000-1 covers PDF 1.7 and ISO 32000-2 covers PDF 2.0, first published in 2017 and revised in December 2020. Since April 2023 the PDF Association has made the PDF 2.0 specification freely available to download. PDF is a final-form format, designed to show the same page everywhere.

What it holds. A page's content stream draws glyphs from fonts at precise positions, along with vector graphics and images. As the Library of Congress format description notes, on-screen text is often stored not as characters but as references to glyphs in the fonts used. Document metadata can sit in an XMP packet. Interactive features, attachments and annotations are optional extras.

Tagged PDF adds a logical structure tree (headings, paragraphs, lists, tables, figures) and a reading order on top of the drawn page. Tagging dates from PDF 1.4 and was completely rewritten for PDF 2.0 to retain more of a source document's semantic structure. A tagged file supports text extraction with structure preserved, reflow, search and conversion to HTML or XML. Page furniture can be marked as pagination artifacts, not part of the content, and PDF 2.0 adds artifact subtypes such as page numbers. Many PDFs in archives are untagged, or tagged badly.

PDF/A (ISO 19005) is a constrained PDF for long-term preservation. All fonts must be embedded, encryption is not allowed, the file must not depend on external resources, and XMP metadata is mandatory. Parts 1 to 3 define conformance levels. Level A meets all requirements, including structure. Levels B and U guarantee visual appearance but are less demanding about structural or semantic properties. Level B is the one typically used for PDF/A files created from scanned pages. PDF/A-4, based on PDF 2.0, drops the A, B and U levels.

Common extraction pitfalls:

  • Reading order. In an untagged PDF, text is extracted in the order it was drawn. That may run across columns, put sidebars mid-sentence or emit headers last.
  • Ligatures. A glyph for "fi" or "ffl" can come out as a single ligature character, or as nothing at all if the font lacks a mapping back to Unicode. Normalise ligatures and test for missing characters.
  • Hyphenation. End-of-line hyphens are ordinary characters in the output. Decide on a rule for rejoining words ("infor-" and "mation"), and keep genuine hyphenated compounds intact.
  • Page furniture. Running heads, folios and footers repeat on every page and pollute the text unless you detect and remove them.
  • Image-only pages. A scanned PDF may have no text layer, or a poor OCR layer added years ago. Our guide to OCR for archives explains how to assess it.
  • Encoding. Fonts with custom encodings can extract as gibberish even when the page looks perfect. Spot-check extracted text against the rendered page.

XML vocabularies: JATS, DocBook and NewsML-G2

XML files record structure directly. Each element says what a piece of text is: a title, an author, a section, a reference. Which vocabulary is used tells you what to expect.

  • JATS (Journal Article Tag Suite, ANSI/NISO Z39.96-2024, version 1.4) is used for journal articles. Its top-level article element must contain front, which holds the journal and article metadata. It may also contain body, back (such as references and appendices), a group of floating figures and tables, and sub-articles or responses. The same element is used for non-research items such as reviews, editorials and obituaries.
  • DocBook is an XML vocabulary for books and documentation. The Library of Congress lists it, alongside TEI, among the widely used book schemas it prefers for digital textual works.
  • NewsML-G2 is the IPTC's XML format for exchanging news. It defines News Items (text, photos, graphics, audio and video), Package Items, Concept Items and Knowledge Items for controlled vocabularies, Planning Items and News Messages. It makes heavy use of controlled vocabularies such as IPTC Media Topics. Version 2.36, approved by the IPTC Standards Committee in October 2026 and released in November, adds properties for describing how AI was used to create or enhance content.

A minimal JATS skeleton shows how cleanly XML separates metadata from content:

<article article-type="research-article">
  <front><!-- journal and article metadata: title, authors, dates, identifiers --></front>
  <body><!-- sections, paragraphs, figures, tables --></body>
  <back><!-- references, acknowledgements, appendices --></back>
</article>

Pitfalls. Validate against the schema or DTD before trusting a file, because local customisations and invalid files are common. Resolve entity references and character encoding explicitly. Check that images referenced from the XML actually exist alongside it. Decide which elements become retrievable text and which become metadata fields. Our guide to metadata for publishers covers the field design.

IDML and INDD: InDesign files

INDD is Adobe InDesign's native, binary document format. It is closely tied to the version of InDesign that created it and difficult for other programs to read. In practice, getting content out of an INDD file means opening it in InDesign and exporting it, usually to IDML, PDF or EPUB.

IDML (InDesign Markup Language) is the XML-based alternative, designed for exchange between InDesign versions and with other software. An IDML file is a ZIP package containing:

Part Contents
designmap.xml The entry point: spread order, references to stories and resources, document settings
Spreads/ One file per spread: page items, frames, positions and geometry, but no text
Stories/ One file per story: the text with paragraph and character formatting, tables, footnotes and anchored objects
MasterSpreads/ Master pages: running heads, page numbers, backgrounds and grids
Resources/ Styles, fonts, colours and swatches, and preferences
XML/ Tag definitions, tag-to-style mappings and unplaced XML content (BackingStory.xml)
META-INF/ Container information pointing to designmap.xml

The key idea is that text lives in stories and layout lives in spreads. A text frame doesn't contain text. It points to a story through its ParentStory attribute. Several frames can point to the same story, which is how one article flows (or "threads") across pages.

Pitfalls:

  • Story order is not reading order. Story files are referenced, not sequenced. To put text into page order, walk the spreads in the order designmap.xml gives, find each text frame and follow it to its story. Then de-duplicate stories that thread across several frames.
  • Master page content. Running heads and folios come from master spreads. Exclude them from body text, but consider keeping them as metadata, such as section names.
  • Fonts. Fonts.xml records the fonts the layout expects, but the font files themselves normally live on the system. Missing fonts don't prevent text extraction from IDML, but any rendering or PDF export made without them will not match the original layout.
  • Linked images. Placed images are usually referenced by file path and stored outside the package. Only embedded images travel inside it. Collect the linked image files with the document, or the images will be missing.
  • Hidden content. Items on the pasteboard, hidden layers and hidden conditional text can all hold text that never appeared in print. Decide whether to keep it.

EPUB, HTML and SVG

EPUB 3 (the current W3C Recommendation is EPUB 3.3) is a ZIP-based container with the extension .epub. A META-INF/container.xml file points reading systems to the package document. That document holds the publication metadata, the manifest listing every resource, and the spine, which gives the default reading order. Content documents are XHTML or SVG. A navigation document provides the table of contents. Required metadata includes a unique identifier (dc:identifier), a title (dc:title) and a language (dc:language).

To extract an EPUB, read the package document, follow the spine in order and parse each XHTML file. The structure is usually good: headings, paragraphs and lists are real HTML elements. Pitfalls include text set as images, decorative or repeated content in every chapter, and files that conform to EPUB 2 or proprietary variants.

HTML is similar. The Library of Congress lists XHTML or HTML with a DOCTYPE declaration and stylesheets as acceptable formats for textual works. Web-archived HTML often carries navigation, adverts and scripts around the article itself, so you need boilerplate removal.

SVG is an XML language for vector and mixed vector-raster graphics, used for diagrams, maps, infographics and illustrations. The SVG 2 specification, now at W3C Candidate Recommendation stage, stores text in text elements as character data. The specification notes that this keeps the text accessible to visually impaired users, findable by search engines, and searchable and selectable in viewers. The common pitfall is text converted to outlines (paths) before export. It looks identical but contains no characters, so labels in diagrams need OCR or are lost. SVG title and desc elements can carry useful descriptions.

Comparing the formats

Format Text Structure Images Metadata Main extraction risk
Untagged PDF Positioned glyphs None explicit Embedded Optional XMP Reading order, ligatures, hyphens, page furniture
Tagged PDF Glyphs plus structure tree Headings, paragraphs, tables, figures Embedded XMP Poor or inconsistent tagging
PDF/A As PDF, fonts embedded Full at level A only Embedded XMP mandatory Level B scans may have no usable text
JATS, DocBook, NewsML-G2 Explicit elements Rich, schema-defined Usually referenced Rich and structured Invalid files, missing referenced assets
IDML Stories Styles, frames, threads Usually linked by path Limited Reconstructing reading order, missing links
INDD Inside InDesign only As IDML once exported Linked or embedded Limited Needs InDesign to export
EPUB 3 XHTML HTML elements, spine order In the package Package metadata Text in images, EPUB 2 variants
HTML Markup HTML elements Referenced Varies Boilerplate and scripts
SVG text elements Graphic groups Vector, can embed raster title, desc, metadata Text converted to outlines

A practical extraction order

When the same title exists in several formats, as it often does in a publisher's archive, use the most structured source:

  1. XML (JATS, DocBook, NewsML-G2 or an in-house schema) if it was maintained as the source of truth.
  2. EPUB 3, which is usually well structured and includes metadata.
  3. IDML, or INDD exported to IDML, for print-only titles. You get the full text and styles, and styles map well to headings.
  4. Tagged PDF, after checking the tag quality on samples.
  5. Untagged PDF, with layout analysis and clean-up.
  6. OCR of page images, when nothing else exists.

Whatever the source, record which format and version each record came from, and keep the link to the original file and page. When the text will feed retrieval systems, keep headings and section boundaries. They make much better split points than fixed character counts, as our guide to chunking documents explains.

How Druid Learning helps

Druid Learning is an AI archival processing platform, based in Dublin and New York, that turns content archives into AI-ready datasets. It processes formats including PDF, XML, IDML, INDD, SVG and EPUB, as well as OCR scans, WAV, MP3 and MP4. Its Archive Optimization product turns archives in any format into an indexed, labelled dataset. For the Irish educational publisher CJ Fallon, Druid Learning processed 50,000 resources and mapped them to the curriculum. The platform has processed more than 10 million assets and handles content in over 140 languages.

Frequently asked questions

Why does text copied from a PDF come out in the wrong order?

Most PDFs record where each glyph is drawn on the page, not the order a person reads them. Unless the file is tagged with a logical structure and reading order, extraction tools must guess, and they often read across columns or put sidebars in the middle of paragraphs. Tagged PDF, available since PDF 1.4 and rewritten in PDF 2.0, stores structure and reading order explicitly. It is the better source when tagging is done properly.

What is the difference between INDD and IDML?

INDD is InDesign's native binary document format. It is closely tied to the software version that created it and hard for other programs to read. IDML is an XML-based package designed for exchange: a ZIP file containing separate XML files for spreads, stories, master pages, styles and resources. Because IDML is readable XML, scripts can extract text and styles without InDesign. INDD files usually have to be opened in InDesign and exported first.

Is PDF/A better than ordinary PDF for extracting text?

Not necessarily. PDF/A guarantees that a file will look the same in the future: fonts are embedded, encryption is banned and XMP metadata is required. Only conformance level A also requires the logical structure that makes extraction reliable. Level B, typical for scanned documents, guarantees appearance but may contain only page images. Always check whether a PDF/A file has a usable text layer.

What is the easiest publishing format to extract structured text from?

Well-formed XML maintained as the source of truth, such as JATS for journal articles, is usually easiest. Every title, author, section and reference is already labelled. EPUB 3 is a close second, because its content is XHTML with a package document that defines metadata and reading order. Layout formats such as PDF and InDesign files need more reconstruction, and scanned page images need OCR.

Sources