Read with pdf.js in your browser

PDF to XML — text, positions, bookmarks, links and form fields

Turn a PDF into well-formed XML you can feed to a script, a database or another tool. Choose lines, paragraphs or text with exact positions, keep two-column pages in reading order, and add the document details, bookmarks, links and form values. The XML updates as you change a setting.

See how it works
  • PDF not uploaded to our server
  • Five XML structures
  • Two-column pages in order
  • Checked as well-formed

Convert PDF to XML

Add a PDF, choose the structure and what to include, then download or copy the XML.

Your PDF is read in this tab and isn't uploaded to our server.

Drop a PDF here

or browse your files. Password-protected PDFs work too.

Page 1

What this tool does

A PDF is made to be looked at. XML is made to be read by software.

This tool takes the text a PDF holds and writes it into tidy elements, in reading order, with as much or as little detail as your next step needs.

What you get

  • Text as lines, paragraphs, or lines and pieces with x, y, width, height and size.
  • Two-column pages written one column at a time, with headings across both kept in place.
  • Title, author, dates and PDF version; bookmarks with their page numbers; links with the text they cover; form fields with their values.
  • Gujarati, Hindi and other scripts kept as written, in UTF-8.
  • Characters XML can't hold removed and counted, and the result read back by your browser to check it is well-formed.
  • A preview that changes as you change a setting, so you see the XML before you save it.

What it can't do

  • Read scanned pages. They have no text; use PDF OCR first.
  • Rebuild tables as rows and cells. A table comes out as lines; use the positions to rebuild it in code.
  • Export images, drawings, colours or font names.
  • Follow your own schema. The element names are fixed; an XSLT can rename them afterwards.

How to convert a PDF to XML in three steps

Open, choose, save.

Open the PDF

Drop it on the box or press Select a PDF. If it is locked, type its password. The XML appears straight away, next to your pages.

Choose what goes in

  • The structure: lines, paragraphs or positions.
  • The reading order and which pages.
  • Details, bookmarks, links and form fields.

Download or copy

Check the preview, then press Download XML for a .xml file, or Copy XML to paste it into your editor.

  • No sign-up
  • Not uploaded to our server

Which settings for your PDF

Common jobs and what to choose for each.

Your PDFWhat you needWhat to set
Invoices or statements from one supplierPick out the number, date and total in a scriptLines with position, Straight across. The same fields sit at the same x and y on every invoice.
Research paper or newsletter in two columnsThe text in the order people read itParagraphs, Columns first, Leave out repeated headers on.
Filled-in application or tax formThe answers, field by fieldForm fields on. Each field's name and value is in a <field> on its page.
A manual or book with a table of contentsIts chapters and where they startBookmarks on; Pages 1 if you only need the outline.
A report to load into a database or search indexOne record per pageSimple, Indent off for the smallest file.
A layout you want to rebuild on the webEvery piece of text and its boxText pieces with position.

The details

How the text is put in order

A PDF stores text as pieces placed on the page, not as lines or paragraphs. This is how they are put back together.

Lines

Pieces that overlap by at least half their height belong to one line, so a raised 2 in mc² stays in its line. Pieces are joined left to right, with a space wherever there is a visible gap.

Columns

An empty vertical strip in the middle half of the page, with full lines of text on both sides, marks two columns. Up to three are found. A line that crosses the strip, such as a heading, keeps its place.

Paragraphs

A new paragraph starts after a gap larger than about two thirds of a line, at a change of text size, or at the top of a new column. A word split with a hyphen at a line end, like docu- ment, is joined again.

Positions

In points from the top-left of the page as you see it. Pages turned in the PDF are measured after turning, and text running sideways is grouped along its own direction.

Headers and footers

When you choose to leave them out, a line at the top or bottom of the page that repeats on at least half the pages (3 or more) is dropped, as are lone numbers like 12 or Page 3 of 9.

Valid XML

&, < and quotes are escaped. Control characters some PDFs carry in their text are removed and counted, because XML 1.0 can't hold them. The finished file is read back by your browser before you see "Checked".

When the XML isn't what you expected

What usually causes it, and what to change.

Problem
Why it happens
Fix

Pages are empty

The pages are pictures, usually a scan or a photo.

Run PDF OCR to add text, then convert the new copy.

Two columns mixed together

Reading order is Straight across, or the columns have no clear gap between them.

Choose Columns first. The page card says "columns" when they were found.

Odd letters or boxes

The PDF's fonts don't say which letters their shapes are, common in older Indian-language PDFs.

The text can't be recovered as written; OCR on a picture of the page usually reads it.

Password isn't accepted

Passwords are case-sensitive, and some banks use your date of birth or PAN in a set format.

Check Caps Lock and the format in the email or letter that came with the PDF.

&amp; in the text

That is how XML writes &; < and quotes are escaped the same way.

Nothing to fix: any XML reader turns them back into the characters.

Cleaner XML every time

Small choices that make the file easier to work with.

Start with Lines

It is the easiest to read and check; switch to positions only if your script needs them.

Drop headers for text work

Repeated titles and page numbers get in the way of search and summaries.

Keep them for invoices

An invoice number in the header may be exactly what you are looking for.

Turn indent off for big files

The XML is the same, without the spaces and line breaks between elements.

Convert only the pages you need

Type 3-5 in Pages for a smaller file and a quicker check.

Check one page full size

Open a page next to the XML to be sure the order matches what you see.

Common questions about PDF to XML

If something's not covered here, the sections above likely have it.

Which structure should I pick?

Lines for most uses: one element per line, in reading order. Paragraphs when you want running text without line breaks. Lines with position or Text pieces with position when a script needs to know where text sits, for example to find a total on an invoice. Simple writes one text element per page and opens in our XML to PDF tool.

How are two-column pages handled?

With Reading order set to Columns first, the tool looks for an empty vertical strip that splits the page into side-by-side columns of text. When it finds one, the left column is written first, then the right; a heading across both stays where it is. Tables with short cells are not treated as columns, so their rows stay together. Straight across reads every line from left to right instead.

What do the x, y, width and height numbers mean?

They are in points (1/72 inch), measured from the top-left corner of the page as it is shown, with any page rotation applied. Size is the text height in points. The page element carries its own width and height, so you can turn the numbers into percentages.

Does it include images, tables or fonts?

No. Images and drawings are left out, and a table comes out as lines of text, not rows and cells. Only a general font family such as serif or sans-serif is known from the PDF, so no font names are given.

Can it convert a scanned PDF?

A scan holds pictures of pages, not text, so those pages come out empty and the tool says so. Run the file through PDF OCR first to add a text layer, then convert the new copy.

What happens with a password-protected PDF?

You are asked for the password in the page. It is used by pdf.js in this tab to open the file and is not saved. If a PDF only has an owner password that limits printing or copying, it opens without asking.

Is my PDF uploaded?

No. The page loads pdf.js from our server, then reads your PDF and writes the XML in your browser. The PDF is not uploaded to our server, and Start over or closing the tab clears it.