In this article, we will use the Nutrient Web SDK, an external JavaScript PDF library, to preview PDF files in Power Pages.
Goal

Stepwise Implementation
1 - Create Custom Table
I have created custom table named "DocTable" and created a File data type column in it.
Upload pdf file from Form.

2 - Enable Web API Access to Table
Enable Web API access for the table so that the file content can be retrieved using JavaScript.
Go to Site Settings from Power Pages Advanced Configuration
Add or update settings to allow Web API access for your table
Ensure the required columns (including the file column) are exposed.
3 - Assign Permissions and Web Roles to Table
You can set this from Table Permissions from Power Pages Advanced Configurations.
You can assign web roles from Power Pages Studio.
4 - Integrate Nutrient Web SDK (via CDN)
Add script reference in HTML file
<script src="https://cdn.cloud.pspdfkit.com/[email protected]/nutrient-viewer.js"></script>Code Section
1 - HTML
<script src="https://cdn.cloud.pspdfkit.com/[email protected]/nutrient-viewer.js"></script>
<div class="row sectionBlockLayout text-start" style="min-height: auto; padding: 8px;">
<div style="width:100%; height:900px; overflow:hidden;">
<div id="pspdfkit" style="width:100%; height:100%;"></div>
</div>
</div>2 - JS
(function (webapi, $) {
function safeAjax(ajaxOptions) {
var deferredAjax = $.Deferred();
shell
.getTokenDeferred()
.done(function (token) {
if (!ajaxOptions.headers) {
$.extend(ajaxOptions, {
headers: {
__RequestVerificationToken: token,
},
});
} else {
ajaxOptions.headers["__RequestVerificationToken"] = token;
}
$.ajax(ajaxOptions)
.done(function (data, textStatus, jqXHR) {
validateLoginSession(data, textStatus, jqXHR, deferredAjax.resolve);
})
.fail(deferredAjax.reject);
})
.fail(function () {
deferredAjax.rejectWith(this, arguments);
});
return deferredAjax.promise();
}
webapi.safeAjax = safeAjax;
})((window.webapi = window.webapi || {}), jQuery);
Join the conversation! Your thoughts help the community grow.