Forum Discussion
How to Import PDF in Single Column
- 1 year ago
The only built-in connector is Pdf.Tables, and I do not believe there is any way to prevent it from parsing the PDF content into a table of tables of page text and tables (charts, etc.). You may want to look into using Power Query R or Python.
That said, here is a general set of PQ transformations you can use to convert the default Pdf.Tables parsing into a something similar to Lines.FromBinary, which I think is what you are asking for.
let // Load the PDF file a location // Note: Use File.Contents for local files Source = Web.Contents( "https://file-examples.com/storage/feeed4f6296807c3196e058/2017/10/file-example_PDF_1MB.pdf" ), // Parse the PDF file to extract its content PdfParse = Pdf.Tables(Source), // Filter the parsed content to get only the pages GetPagesOnly = Table.SelectRows(PdfParse, each ([Kind] = "Page")), // Combine all the separate tables of page content into one table for the whole file CombineAllPageContent = Table.Combine(GetPagesOnly[Data]), // Merge all columns into a single column (called "Merged") MergeAllPageColumns = Table.CombineColumns( CombineAllPageContent, Table.ColumnNames(CombineAllPageContent), Combiner.CombineTextByDelimiter("", QuoteStyle.None), "Merged" ) in MergeAllPageColumnsQuick visual of the steps to see what the above is doing:
The only built-in connector is Pdf.Tables, and I do not believe there is any way to prevent it from parsing the PDF content into a table of tables of page text and tables (charts, etc.). You may want to look into using Power Query R or Python.
That said, here is a general set of PQ transformations you can use to convert the default Pdf.Tables parsing into a something similar to Lines.FromBinary, which I think is what you are asking for.
let
// Load the PDF file a location
// Note: Use File.Contents for local files
Source = Web.Contents(
"https://file-examples.com/storage/feeed4f6296807c3196e058/2017/10/file-example_PDF_1MB.pdf"
),
// Parse the PDF file to extract its content
PdfParse = Pdf.Tables(Source),
// Filter the parsed content to get only the pages
GetPagesOnly = Table.SelectRows(PdfParse, each ([Kind] = "Page")),
// Combine all the separate tables of page content into one table for the whole file
CombineAllPageContent = Table.Combine(GetPagesOnly[Data]),
// Merge all columns into a single column (called "Merged")
MergeAllPageColumns = Table.CombineColumns(
CombineAllPageContent,
Table.ColumnNames(CombineAllPageContent),
Combiner.CombineTextByDelimiter("", QuoteStyle.None),
"Merged"
)
in
MergeAllPageColumns
Quick visual of the steps to see what the above is doing: