How to Convert Base64 to PDF Using Power BI?

Last week, while working on Power BI, I received a request to convert Base64 to a PDF file. The requirement was to decode a text file containing a PDF encoded in Base64 format and display that PDF within Power BI.

In this Power BI tutorial, I will explain how to convert Base64 to PDF using Power BI.

Convert Base64 to PDF Using Power BI

Here is the text file, which is encoded in base64 format. Check the screenshot below.

Generate PDF from base64 using Power bi

Now follow the below steps:

Import Text file into Power BI

1. Copy all the base64 text and paste it into a new Excel workbook.

How to convert base64 file into pdf file

You might think we can directly import the text file into Power BI, but when you import the text file, some characters might not import correctly.

2. Copy the base64 in Excel sheet 1 and add a new sheet in the new sheet peste in Transpose, like the screenshot below.

Embedding Base64-encoded PDFs in Power BI reports

3. Now, we give the column a name. When you copy and paste the text into the Excel file, it is stored in 21 rows, although this may vary depending on your PDF.

Here, I gave the column names from A1 to A21 and changed the sheet name to ‘base64,’ as shown in the screenshot below. After that, save and close the Excel file.

Power BI Base 64 pdf

4. Now open Power BI Desktop and get that Excel file. Select the base64 sheet, then click on Transform Data.

Microsoft Power BI Report Builder to render base64 to pdf

5. The Power Query Editor will open here under the Transform tab. Click Use First Row as Headers.

view PDF in power bi from base64

6. Under the File tab, click Close & Apply.

How to convert base64 file into pdf file using Power BI

Combine all the Column using Power BI DAX

You can see the column in the Date pane. Now, we create a new column combining all columns using the Dax expression below.

PDF = [A1] & [A2] & [A3] & [A4] & [A5] & [A6] & [A7] & [A8] & [A9] & [A10] & [A11] & [A12] & [A13] & [A14] & [A15] & [A16] & [A17] & [A18] & [A19] & [A20] & [A21]
view pdf in pdf viewer control using base64

Add PDF Viewer in Power BI Desktop

We have now added a PDF viewer to Power BI. To do this, click Get more visuals under the Visual gallery.

Before that, log in to Power BI Desktop with your school or organization account.

Media in Base64 Power BI

In the Search bar, search for a PDF viewer and select the PDF viewer shown in the screenshot below.

Base64 Encoding for PDF in Power BI

Add the Pdf Viewer to the Power BI Desktop.

How can I generate base64 to pdf

You can see a pop-up message that you successfully imported.

How can I convert Base64 ot PDF

Then, add the Pdf Viewer and the PDF column to the PDF Base64 Data.

Generate PDF from base64 using Power BI desktop

After that, you can see the PDF in the Pdf Viewer.

Convert Base64 to PDF in Power BI

I hope you follow all the steps to convert base64 to PDF using Power BI Desktop. Feel free to comment if you have any doubts or questions about this topic or related topics.

You may also like to read:

>

Build a High-Performance Project Management Site in SharePoint Online

User registration Power Apps canvas app

DOWNLOAD USER REGISTRATION POWER APPS CANVAS APP

Download a fully functional Power Apps Canvas App (with Power Automate): User Registration App

Power Platform Tutorial FREE PDF Download

FREE Power Platform Tutorial PDF

Download 135 Pages FREE PDF on Microsoft Power Platform Tutorial. Learn Now…