Portfolio Showcase Demo Code Sample

Requirements
View Demo

Easily add support for PDF Portfolios (also known as PDF Packages), allowing users to view and edit each embedded file in its own dynamically generated tab. Attachments can be edited or downloaded individually. The viewer supports a wide range of file types within these portfolios, from Office documents to image formats.


This demo allows you to:

  • Load a default PDF portfolio document with a set of attachments:
    • blank.pdf
    • demo-annotated.pdf
    • memo.docx
    • rendering.jpg
  • Access options to view each attachment in its own tab (use "more options" ... button on the right margin of the attachment)
  • Edit each document and download separately
  • Load your own PDF portfolio to test the capabilities

Implementation steps
To add PDF portfolio support with WebViewer:

Step 1: Choose your preferred web stack
Step 2: Add the ES6 JavaScript sample code provided in this guide

1// ES6 Compliant Syntax
2// Copilot name: GitHub Copilot, version: 1.0.0, model: GPT-4, version: 2024-06, date: 2025-10-28
3// File: showcase-demos/portfolio/index.js
4
5import WebViewer from '@pdftron/webviewer';
6
7WebViewer(
8 {
9 path: '/lib',
10 initialDoc: 'https://apryse.s3.us-west-1.amazonaws.com/public/files/samples/portfolio-sample.pdf',
11 enableFilePicker: true, // Enable file picker to open files. In WebViewer -> menu icon -> Open File
12 fullAPI: true, // Enable the PDF Portfolio
13 licenseKey: 'YOUR_LICENSE_KEY',
14 },
15 document.getElementById('viewer')
16).then((instance) => {
17
18 // Set the toolbar group to the Annotate tools
19 instance.UI.setToolbarGroup('toolbarGroup-Annotate');
20
21 // Enable the Portfolio feature
22 instance.UI.enableFeatures([instance.UI.Feature.Portfolio]);
23
24 // Open the left panel to show the Portfolio tab
25 instance.UI.openElements(['tabPanel']);
26
27 // Set the active left panel to the Portfolio panel when the document is loaded
28 instance.Core.documentViewer.addEventListener('documentLoaded', () => {
29 instance.UI.setActiveLeftPanel('portfolioPanel');
30 });
31
32 console.log('WebViewer loaded successfully.');
33}).catch((error) => {
34 console.error('Failed to initialize WebViewer:', error);
35});

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales