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.
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.
It is most suitable to use with small document since columns in tabular models can contain maximum ca 30.000 characters.
The workaround for files that require more characters is to split the strings into multiple columns on import and concatenate them back to their original form in a computed column.
Sample pbix file can be found here: https://github.com/DanielSallander/PowerBI-visuals/tree/master/Pdf-Viewer
Sample pbix contains two examples:
Known issues: