https://store-images.s-microsoft.com/image/apps.51852.12f78759-28dc-401f-b54f-a6ea24360c9d.9670edec-c55e-4ea3-a0b1-f454456e87bd.b87b4798-beec-4b25-b9d0-b945af21a5fd

Pdf Viewer

โดย DS Analytics AB

Microsoft PBI Certified
(17 คะแนน)
ดาวน์โหลดตัวอย่างคำแนะนำ

This visual utilizes PDF JS to display PDF documents from base64 encoded strings.

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.

The Pdf Viewer is available in both a free version and in a licensed version.
In the licensed version there are these additional options:

  • Export documents to file. 

  • Use measures, for both the base 64 data and for the exported file name.

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.

Using measures however gives more flexibility since strings can be concatenated using for instance CONCATENATEX. 

Sample pbix file can be found here: Pdf-Viewer/samplePdfViewer at main · DanielSallander/Pdf-Viewer (github.com)

Sample pbix contains two examples:

  • Example 1: Showing two pdf documents with multiple pages.
  • Example 2: Showing table with invoices which displays pdf on hover and possibility to drillthrough for full pdf document. This example has the scroll bar option and header option disabled for the hovered pdf.

Known issues:

  • There are some compatibily issues with Internet Explorer 11 and earlier
  • If other zoom than 100% is selected it will be reset to 100% when switching pages

ความสามารถในการมองเห็น

สรุปย่อ

https://store-images.s-microsoft.com/image/apps.42753.12f78759-28dc-401f-b54f-a6ea24360c9d.9670edec-c55e-4ea3-a0b1-f454456e87bd.4b64a8ad-5692-4798-a6af-07caa7852791
https://store-images.s-microsoft.com/image/apps.43169.12f78759-28dc-401f-b54f-a6ea24360c9d.9670edec-c55e-4ea3-a0b1-f454456e87bd.92b3e010-9dd4-4cab-b2c6-015fbc847a3b
https://store-images.s-microsoft.com/image/apps.65362.12f78759-28dc-401f-b54f-a6ea24360c9d.9670edec-c55e-4ea3-a0b1-f454456e87bd.7c9922fe-b69f-4924-a0d3-c99107440ecc