Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

PDF Viewer visual not working with base64

Hello everybody,

 

my issue is about the use of PDF Viewer visual, I would like to take it to view a PDF on my report.

 

I read its overview at https://appsource.microsoft.com/en-us/product/power-bi-visuals/WA104382087?tab=Overview and then I looked at a sample report I found on the Web ( https://info.enterprisedna.co/power-bi-custom-visuals/pdf-viewer/ ) explaining how to configure it, and it looked quite easy.

 

As I read, tabular models can't contain more than 30.000 characters, so because length of base64 strings is bigger than 30.000 in the sample report they are divided in 2 different columns, then there is a calculated column which makes the concatenation of the two values getting the base64 value to give as value to the PDF Viewer visual.

 

In my report, I get base64 from a web service I developed. This is my Advanced Editor:

 

 

let
Origine = Sql.Database("pbidev", "tracking_dwh", [Query="select top 5 * from Documents"]),
Step = Table.AddColumn(Origine, "Base64", each Web.Contents("http://localhost:44342/api/values?ky=8D1-478C-B092-9563F526A47A&username=usr&password=pwd")),
#"Modificato tipo" = Table.TransformColumnTypes(Step,{{"Base64", type text}})
in
#"Modificato tipo"

 

 

In this way I get my base64 but because it's too large I created two columns to store it, using this codes and storing first 30.000 characters in the first column and the others in the second one:

 

Base64_1 = LEFT(Query1[Base64], 30000)
Base64_2 = MID(Query1[Base64], 30001, LEN(Query1[Base64])-30000)
 
Finally I created the concatenation:
 
Base64_Total = Query1[Base64_1] & Query1[Base64_2]
 
I don't know why but if I use this last field called Base64_Total in PDF Viewer visual in "PDF Data" field I don't get the PDF and it stays white, showing anything.
 
My doubt is that in the sample report the base64 is already divided while I get it as an entire string, then I part it and then I put it back together, so it could cause the issue, but how can I get a base64 which is already divided from my web service? I have a get there and I can receive just an element as output (my base64) and not the partition into 2 different substrings.
 
Thanks in advance for your help. I appreciate it.
 
Nick
3 REPLIES 3
Anonymous
Not applicable

 

The Pdf documents must be stored in the data model in base64 format, meaning that they must converted to this format before being imported to Power BI. This can be accomplished in many ways, for example in python with a few lines of code:

import base64

with open(<[path to pdf]>, "rb") as pdf_file:
    encoded_string = base64.b64encode(pdf_file.read())

 

In Power BI the Pdf Viewer takes a single field, the column storing the base64 data, as argument:

 

 

When using the Pdf Viewer in Power BI the pdf documents will only be displayed when there is one document selected in current filter context. Otherwise a warning is displayed:

 

 

With one document selected the Pdf Viewer displays pdf documents with controls that enables the user to switch pages and zoom in and out:

On the format pane there are also possibilities to show/hide header controls and overflow scrolling:

 

 

 
Anonymous
Not applicable

Thanks @Anonymous for your answer,

 

what you say is already clear to me. I know the visual requires column storing base64 as argument and I need to select one document at a time, but my issue comes before. As you can see in the Advanced Editor query I pasted in red in my post, documents are already converted in base64 when I come in Power BI, as this step is accomplished by my web service. In the sample report you can find at the link I posted, base64 strings are already parted in 2 different columns and then they are concatenated to get the argument column, but I get my string which is larger than 30.000 characters and it's the max you can store in tabular models, as PDF Viewer visual documentation says.

 

I use a web service because I need to receive and convert documents from another web service. Even if I use your Python query, where should I write that? 

 

Anyway, how can I fix that?

 

Nick 

There is no need to convert the PDF to a Base64 string: https://www.youtube.com/watch?v=TEou0LuPjkA

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.