Importing tabular data from a pdf - new
Newer versions of Excel and Power BI have a PDF connector, which reads tables straight out of a PDF document. This page uses it to bring tabular data from a PDF into Excel, without the Word conversion that older versions needed.

The method has two parts:
- Import the PDF into Power Query with the PDF connector.
- Clean and reshape the data in Power Query as usual.
1. The example file
Section titled “1. The example file”The example uses a PDF that lists the US states and their two-letter abbreviations:
The top of its first page looks like this. The table is laid out as two pairs of columns side by side:

- Save a copy of the PDF somewhere you can find it.
2. Import the PDF into Power Query
Section titled “2. Import the PDF into Power Query”- On Excel’s Data tab, choose Get Data ➔ From File ➔ From PDF.

Browse to the PDF and open it. Power Query reads the file and opens the Navigator, which lists each table it found and each page of the document. Here it finds one table on page 1, Table001, and one page, Page001.

Click an item to preview it, or tick Select multiple items to pick several. Load sends the selection straight to Excel, while Transform Data opens it in the Power Query Editor for cleaning first.
3. Clean the data
Section titled “3. Clean the data”Choose Table001 and click Transform Data. The table opens in the editor in four columns, with the headings in the first row:

- In Applied Steps, rename the last step, which is usually Changed Type, to All4Columns, so that later steps can refer to it by name.
- Select the first two columns, which are the ones to keep, then right-click and choose Remove Other Columns:

- On the Transform tab, click Use First Row as Headers.
- Filter the STATE column to remove blank rows and the row holding the heading DIRECTIONAL ABBREVIATIONS. The resulting step looks like this:
= Table.SelectRows(#"Promoted Headers", each ([STATE] <> "" and [STATE] <> "DIRECTIONAL#(lf)ABBREVIATIONS"))The #(lf) in the text stands for the line break that splits the heading over two lines in the PDF.
- Rename this step First2Columns.
- Click the fx button beside the formula bar to add a new step, and enter this formula, which goes back to the All4Columns step and keeps the other two columns:
= Table.SelectColumns(All4Columns,{"Column3", "Column4"})- Click Use First Row as Headers again.
- Filter the STATE column to remove blank rows and the row holding the heading SECONDARY ADDRESS UNIT INDICATORS:
= Table.SelectRows(#"Promoted Headers1", each ([STATE] <> "" and [STATE] <> "SECONDARY ADDRESS#(lf)UNIT INDICATORS"))- Rename this step Second2Columns.
4. Append the two halves
Section titled “4. Append the two halves”- Click the fx button again, and enter this formula to append the two halves into one table:
= Table.Combine({First2Columns, Second2Columns})- Rename the step AllData.
Loaded to Excel, the result is a single list of states and abbreviations:

5. The finished query
Section titled “5. The finished query”The whole query, as shown in the Advanced Editor, looks like the code below. The file path in the first step will be different on your computer.
let Source = Pdf.Tables(File.Contents("C:\Users\...Abbreviation-List.pdf"), [Implementation="1.2"]), Table001 = Source{[Id="Table001"]}[Data], All4Columns = Table.TransformColumnTypes(Table001,{{"Column1", type text}, {"Column2", type text}, {"Column3", type text}, {"Column4", type text}}), #"Select Columns" = Table.SelectColumns(All4Columns,{"Column1", "Column2"}), #"Promoted Headers" = Table.PromoteHeaders(#"Select Columns", [PromoteAllScalars=true]), First2Columns = Table.SelectRows(#"Promoted Headers", each ([STATE] <> "" and [STATE] <> "DIRECTIONAL#(lf)ABBREVIATIONS")), #"Select Columns1" = Table.SelectColumns(All4Columns,{"Column3", "Column4"}), #"Promoted Headers1" = Table.PromoteHeaders(#"Select Columns1", [PromoteAllScalars=true]), Second2Columns = Table.SelectRows(#"Promoted Headers1", each ([STATE] <> "" and [STATE] <> "SECONDARY ADDRESS#(lf)UNIT INDICATORS")), AllData = Table.Combine({First2Columns, Second2Columns})in AllData6. Reading a range of pages
Section titled “6. Reading a range of pages”Pdf.Tables also takes optional settings in its second argument. Two of them, StartPage and EndPage, limit the import to a range of pages, which helps with a long document. Edit the Source step’s formula to add them, as in this example:
Pdf.Tables(File.Contents("C:\Sample.pdf"), [StartPage=5, EndPage=10])The Pdf.Tables reference lists the other settings.
The PDF used on this page comes from Matt Allington’s post Import Tabular Data from PDF using Power Query on Excelerator BI.