How to setup PDF viewer custom visual

Hi All,
I am trying to setup PDF viewer custom visual in my report but I am stuck. I think this visual utilizes PDF JS from base64 encoded strings. How can we do automate through power query ? please share a code or a way I can do.

Thank you,

Hi @khurram,

Welcome to the forum.

Not familiar with this visual, looked it up, seems converting can be done in for example Python and C# maybe there are more details in the GitHub repository. Below you can also find a link to a sample PBIX maybe that’s helpful.

.
This visual utilizes the PDF JS javascript library (https://mozilla.github.io/pdf.js/) to display PDF documents from base64 encoded strings.

The visual reads pdfs from the Power BI data model which requires the documents to be converted into base64 encoded strings before imported into the data model.

Converting pdfs to base64 strings can be accomplished in a number of ways.

For example in Python:

import base64

with open(<[path to pdf]>, “rb”) as pdf_file:

base64String = base64.b64encode(pdf_file.read())

In C#:

using System;

using System.IO;

string pdf_file = <[path to pdf]>;

Byte[] bytes = File.ReadAllBytes(pdf_file);

String base64String = Convert.ToBase64String(bytes);

The visual is restricted to display one pdf at a time and will display a warning otherwise.

Sample pbix file can be found here:

HI @khurram

I haven’t used it either and second @Melissa in that regard. I thought you might also want to have a look at this blog too

PDF Viewer custom visual

Thanks and all the best

Najah

Still I am trying to achieve it. It’s very tricky, I believe…

Just found an article that might be of intrest to you.

It demonstrates how you can use an M query that reads all the data from all of the files in the folder and converts them using: Binary.ToText(BinaryIn, BinaryEncoding.Base64) to store them as text in a table.

.
I hope this is helpful

Hi @khurram we’ve noticed that no response has been received from you since the 19th of March. We just want to check if you still need further help with this post? In case there won’t be any activity on it in the next few days, we’ll be tagging this post as Solved. If you have a follow question or concern related to this topic, please remove the Solution tag first by clicking the three dots beside Reply and then untick the checkbox. Thanks!