Document List Panel

This example shows how to add the Document List Panel to the GcPdfViewer, and fill it with the list of predefined PDFs that a user can load from URLs specified by the documentListUrl option.

window.onload = function(){ //GcPdfViewer.LicenseKey = "***key***"; const options = { workerSrc: "/documents-api-pdfviewer/demos/product-bundles/build/gcpdfviewer.worker.js", supportApi: { apiUrl: window.top.SUPPORTAPI_URL, token: window.top.SUPPORTAPI_TOKEN, webSocketUrl: false }, restoreViewStateOnLoad: false }; options.documentListUrl = 'data:,["Hello World|/documents-api-pdfviewer/demos/product-bundles/assets/pdf/helloworld.pdf|Open helloworld.pdf","Wetlands|/documents-api-pdfviewer/demos/product-bundles/assets/pdf/wetlands.pdf|Open wetlands.pdf","Invoice|/documents-api-pdfviewer/demos/product-bundles/assets/pdf/zugferd-invoice.pdf|Open zugferd-invoice.pdf"]'; options.friendlyFileName = ''; const viewer = new GcPdfViewer("#viewer", options); viewer.addDefaultPanels(); const viewerDefault = viewer.toolbarLayout.viewer.default; viewerDefault.splice(viewerDefault.indexOf("open"), 1); const documentListPanelHandle = viewer.addDocumentListPanel(); viewer.onAfterOpen.register(function() { viewer.leftSidebar.menu.panels.open(documentListPanelHandle.id); }); viewer.open("/documents-api-pdfviewer/demos/product-bundles/assets/pdf/viewer-pdf-document-list.pdf"); }
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Document List</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="./src/styles.css"> <script src="/documents-api-pdfviewer/demos/product-bundles/build/gcpdfviewer.js"></script> <script src="/documents-api-pdfviewer/demos/product-bundles/build/init.js"></script> <script src="./src/app.js"></script> </head> <body> <div id="viewer"></div> </body> </html>
#viewer { height: 100%; }