Came across an interesting question on stackoverflow this morning, so I thought I’d give it a shot. Turned out to be an exciting morning of learning and a pretty lengthy response that I thought I’d cross-post to keep a copy for myself. If you have any suggestions for improvement, please feel free to contribute to the thread. Thanks!
This uses the PDF.js project by Mozilla. Here’s a quick recipe of what you may need.
- Create a File Browse page item and set the Storage Type to
- Create a page button to submit the page.
- Create a Classic Report region and enter the following query:
- Add a virtual column and set the HTML Expression:
<button type="button" class="btn-preview-pdf" data-id="#ID#">Preview</button>
- Create a region and enter the following in the Source:
Create a Click dynamic action.
a. Set the selection Type to
b. Enter the jQuery Selector
var fileId = $(this.triggeringElement).data('id');
For the action, also set the Affected Elements:
a. Selection Type:
b. jQuery Selector:
Follow Joel Kallman’s post on creating a link to download a file. You will need an Application Process (
DOWNLOADPDF) and an Application Item (
FILE_ID) The modified code for the Application Process
DOWNLOADPDFlooks like this:
Note that this is a very basic prototype. The preview only allows you to view the first page. You will need to figure out the API and then do the necessary to allow multipage viewing.