### Getting Started with Sign Here Widget POC Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/signing/sign-here-upgraded/README.md Follow these steps to set up and run the Sign Here Widget Proof of Concept on your local machine. Ensure Node.js is installed before proceeding. ```Shell npm i ``` ```Shell npm run copy-assets ``` ```Shell npm run start ``` -------------------------------- ### Getting Started: Running the Nutrient Document Generator POC Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/document-generator-vanillajs/README.md To run the Nutrient Document Generator proof-of-concept locally, you will need an up-to-date installation of Node.js. First, configure the server port in the `.env` file, then use npm to install dependencies and start the server. ```Shell PORT=8080 ``` ```Shell npm start ``` -------------------------------- ### Setup and Run Annotation Comments POC Project Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/comment-annotations/README.md Provides step-by-step instructions to clone the repository, navigate into the project directory, install dependencies, add required assets, and start the development server for the Annotation Comments POC application. ```bash git clone https://github.com/Siddharth2001-July/annotation-comments ``` ```bash cd annotation-comments ``` ```bash npm install ``` ```bash npm run add-assets ``` ```bash npm run start ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/create-annotation-from-clipboard/README.md Installs all required Node.js packages and project dependencies using npm. ```sh npm install ``` -------------------------------- ### Initialize and Load PSPDFKit in Electron Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/windows/pspdfkit-with-winui3/PSPDFKit-WinUI3-example/Assets/index.html This JavaScript snippet initializes PSPDFKit within an Electron application. It defines an asynchronous 'load' function that handles unloading any existing PSPDFKit instance before loading a new document. The configuration specifies the document path and the container element. The 'window.onload' event is used to trigger the loading of 'document.pdf' when the application starts. ```JavaScript let instance = null; async function load(document) { if (instance) { PSPDFKit.unload(instance); hasUnsavedAnnotations = false; instance = null; } const configuration = { document, container: "#root", // Add when using a license key // licenseKey: "LICENSE KEY GOES HERE", }; instance = await PSPDFKit.load(configuration); } window.onload = () => load("./document.pdf"); ``` -------------------------------- ### Run Local Development Server Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/signing/signing-demo-complete/README.md Starts the Next.js development server locally, allowing you to access the project in your browser. ```Shell npm run dev ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/signing/signing-demo-complete/README.md Installs all required Node.js project dependencies listed in package.json using npm. ```Shell npm i ``` -------------------------------- ### Serve Production Build Preview Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/text-2-speech/README.md This command starts a local server to preview the production-ready build of the Text2Speech application, allowing verification of the optimized assets before actual deployment. ```sh npm run preview ``` -------------------------------- ### Redirect Browser to PSPDFKit Web Examples using JavaScript Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/snipping-annotation/public/Examples.html This JavaScript snippet programmatically redirects the current browser window to the PSPDFKit for Web example projects gallery. It's a common method for automatic navigation, ensuring users land on the correct resource. ```JavaScript window.location.href = "https://pspdfkit.com/guides/web/current/pspdfkit-for-web/example-projects/" ``` -------------------------------- ### Run Development Server Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/create-annotation-from-clipboard/README.md Starts the local development server for the application, typically accessible via a web browser. ```sh npm run dev ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/redact-one-by-one/README.md Command to install all required Node.js dependencies for the project using npm. ```sh npm install ``` -------------------------------- ### Run Development Server Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/signing/clientside-digital-sigature/README.md Commands to start the local development server for the Nutrient PDF Viewer application. ```Shell npm run dev # or yarn dev ``` -------------------------------- ### Start Development Server Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/redact-one-by-one/README.md Command to start the local development server for the application, typically accessible via `http://localhost:5173`. ```sh npm run dev ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/signing/clientside-digital-sigature/README.md Commands to install the necessary Node.js packages for the project using npm or yarn. ```Shell npm install # or yarn install ``` -------------------------------- ### Verify `serve` package installation Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/comments-status/README.md Checks if the global `serve` package is installed on the system by querying its version. This package is a prerequisite for running the project. ```bash serve --version ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/document-editor/save-selected-page-from-document-editor/README.md Installs all necessary Node.js packages and dependencies for the project using npm. ```Shell npm install ``` -------------------------------- ### Run PSPDFKit Snipping Annotation Development Server Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/snipping-annotation/README.md This command starts the local development server for the PSPDFKit Snipping Annotation application, typically accessible via a web browser at `http://localhost:5173`. ```sh npm run dev ``` -------------------------------- ### Verify Global Serve Package Installation Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/comment-annotations/README.md Checks if the global `serve` package is installed on the system, which is a prerequisite for running the development server. ```bash serve --version ``` -------------------------------- ### Install Node.js Project Dependencies Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/speech-2-text/README.md This command installs all required Node.js packages and dependencies for the Speech2Text project. It should be executed after cloning the repository to ensure all necessary libraries are available. ```bash npm install ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/snipping-annotation/README.md This command installs all necessary Node.js packages and dependencies for the PSPDFKit Snipping Annotation project, as defined in the `package.json` file. ```sh npm install ``` -------------------------------- ### Run Development Server Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/get-all-annotations-boundingBox/README.md Starts the local development server for the application, making it accessible in a web browser at http://localhost:5173 for real-time development and testing. ```sh npm run dev ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/get-all-annotations-boundingBox/README.md Installs all necessary Node.js and npm dependencies for the project, ensuring all required packages are available for development and production builds. ```sh npm install ``` -------------------------------- ### Basic CSS Styling for PSPDFKit Container Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/windows/pspdfkit-with-winui3/PSPDFKit-WinUI3-example/Assets/index.html This CSS snippet provides essential styling for the HTML body and the '#root' container, ensuring it fills the viewport and is ready to host the PSPDFKit viewer. It also hides the header element. ```CSS html, body { margin: 0; padding: 0; background: #f6f7fa; } header { display: none; } #root { width: 100vw; height: 100vh; } ``` -------------------------------- ### Install Node.js Project Dependencies Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/text-2-speech/README.md This command installs all necessary Node.js packages and libraries defined in the project's package.json file, ensuring all required dependencies are available for development and production builds. ```sh npm install ``` -------------------------------- ### Install FileSaver.js and TypeScript Definitions Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/snipping-annotation/public/file-saver/README.md Provides commands for installing the FileSaver.js library using npm for Node.js projects and Bower for front-end projects. Additionally, it shows how to install TypeScript type definitions for better development experience. ```bash # Basic Node.JS installation npm install file-saver --save bower install file-saver ``` ```bash # Additional typescript definitions npm install @types/file-saver --save-dev ``` -------------------------------- ### Run Speech2Text Development Server Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/speech-2-text/README.md This command starts the local development server for the Speech2Text application. Once running, the application can be accessed in a web browser, typically at a local address like 'http://localhost:3000' or similar, allowing for development and testing. ```bash npm run dev ``` -------------------------------- ### Run Development Server Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/document-editor/save-selected-page-from-document-editor/README.md Starts the local development server, making the application accessible in a web browser, typically at http://localhost:5173. ```Shell npm run dev ``` -------------------------------- ### Configure PSPDFKit License Key Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/signing/clientside-digital-sigature/README.md Guide to set up the PSPDFKit license key as an environment variable in a .env file for application configuration. ```Shell VITE_lkey=your_pspdfkit_license_key ``` -------------------------------- ### Install Project Dependencies with npm Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/customise-annotation-sidebar/README.md This command installs all necessary project dependencies listed in the `package.json` file using npm, ensuring the application has all required modules to run. ```sh npm install ``` -------------------------------- ### Run Text2Speech Development Server Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/text-2-speech/README.md This command starts the local development server for the Text2Speech application, typically enabling hot-reloading and providing a local URL (e.g., http://localhost:5173) for testing and development purposes. ```sh npm run dev ``` -------------------------------- ### Clone PSPDFKit Snipping Annotation Repository Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/snipping-annotation/README.md This command clones the PSPDFKit-SnippingAnnotation project repository from GitHub to your local machine and navigates into the project directory, preparing for further setup. ```sh git clone https://github.com/Narashiman-K/PSPDFKit-SinppingAnnotation.git cd PSPDFKit-SinppingAnnotation ``` -------------------------------- ### Clone Text2Speech Repository Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/text-2-speech/README.md This command clones the Text2Speech project repository from GitHub to your local machine and then changes the current directory to the newly cloned project folder, preparing for dependency installation. ```sh git clone https://github.com/Narashiman-K/Text2Speech.git cd Text2Speech ``` -------------------------------- ### Clone Git Repository and Navigate Directory Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/customise-annotation-sidebar/README.md This command sequence clones the project repository from GitHub and changes the current directory into the newly cloned project folder, preparing for dependency installation. ```sh git clone https://github.com/Narashiman-K/SidebarShowAnnotationTextNotType.git cd SidebarShowAnnotationTextNotType ``` -------------------------------- ### Saving Text Content to a File Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/snipping-annotation/public/file-saver/README.md This JavaScript example illustrates how to save a text string as a file using FileSaver.js. It constructs a Blob containing 'Hello, world!' with UTF-8 encoding and then triggers a download named 'hello world.txt'. This snippet assumes FileSaver is globally available or already imported. ```js var blob = new Blob(["Hello, world!"], {type: "text/plain;charset=utf-8"}); FileSaver.saveAs(blob, "hello world.txt"); ``` -------------------------------- ### Saving Text with FileSaver.js (CommonJS) Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/snipping-annotation/public/file-saver/README.md This JavaScript example demonstrates how to save a simple text string to a file using FileSaver.js with CommonJS `require()` syntax. It creates a Blob object with the text content and then uses `saveAs()` to prompt the user to download it as 'hello world.txt'. ```js var FileSaver = require('file-saver'); var blob = new Blob(["Hello, world!"], {type: "text/plain;charset=utf-8"}); FileSaver.saveAs(blob, "hello world.txt"); ``` -------------------------------- ### Saving Canvas Content as an Image Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/snipping-annotation/public/file-saver/README.md This JavaScript example shows how to save the content of an HTML canvas element as an image file. It uses `canvas.toBlob()` to convert the canvas drawing into a Blob, which is then passed to `saveAs()` to initiate the download as 'pretty image.png'. Note that `canvas.toBlob()` might require a polyfill for older browsers. ```js var canvas = document.getElementById("my-canvas"); canvas.toBlob(function(blob) { saveAs(blob, "pretty image.png"); }); ``` -------------------------------- ### Build and Preview Production Application Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/speech-2-text/README.md These commands first create a production-ready build of the application and then serve it locally for preview purposes. After execution, the optimized application will be accessible in a web browser at 'http://localhost:4173'. ```bash npm run build npm run preview ``` -------------------------------- ### Build and Serve Production Application Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/redact-one-by-one/README.md Commands to create a production-ready build of the application and then serve it locally for preview, usually on `http://localhost:4173`. ```sh npm run build npm run preview ``` -------------------------------- ### Clone Project Repository Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/signing/signing-demo-complete/README.md Clones the Signing Demo project repository from GitHub to your local machine. ```Shell git clone https://github.com/Siddharth2001-July/signing-demo-baseline ``` -------------------------------- ### Build and Serve Production Application Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/get-all-annotations-boundingBox/README.md Commands to create a production-ready build of the application and then serve it locally for preview, allowing verification of the optimized output. ```shell script npm run build npm run preview ``` -------------------------------- ### Serve Production Build Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/create-annotation-from-clipboard/README.md Serves the previously created production build of the application locally, allowing for testing of the deployed version. ```sh npm run preview ``` -------------------------------- ### Clone Project Repository Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/create-annotation-from-clipboard/README.md Clones the project repository from GitHub and navigates into the project directory. ```sh git clone https://github.com/Narashiman-K/PastefromClipbordonPDFasAnnotation.git cd PastefromClipbordonPDFasAnnotation ``` -------------------------------- ### Serve PSPDFKit Snipping Annotation Production Build Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/snipping-annotation/README.md This command serves the previously built production version of the PSPDFKit Snipping Annotation application, making it accessible locally, typically at `http://localhost:4173`. ```sh npm run preview ``` -------------------------------- ### Clone Speech2Text Project Repository Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/speech-2-text/README.md This command clones the Speech2Text project repository from GitHub and navigates into the newly created project directory. It's the essential first step to set up the development environment. ```bash git clone https://github.com/Narashiman-K/Speech2Text.git cd Speech2Text ``` -------------------------------- ### Build Application for Production Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/create-annotation-from-clipboard/README.md Creates an optimized production build of the application. This command compiles and bundles the source code for deployment. ```sh npm run build ``` -------------------------------- ### Clone Project Repository Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/signing/clientside-digital-sigature/README.md Instructions to clone the Nutrient PDF Viewer repository from GitHub and navigate into the project directory. ```Shell git clone https://github.com/PSPDFKit/awesome-nutrient.git cd web/signing/clientside-digital-sigature ``` -------------------------------- ### Build and Serve Production Application Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/document-editor/save-selected-page-from-document-editor/README.md Creates an optimized production build of the application and then serves it locally for preview, usually at http://localhost:4173. ```Shell npm run build npm run preview ``` -------------------------------- ### Clone Project Repository Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/get-all-annotations-boundingBox/README.md Clones the GetAllAnnotationBoundingBox project repository from GitHub and navigates into its directory, preparing for local development. ```sh git clone https://github.com/Narashiman-K/GetAllAnnotationBoundingBox.git cd GetAllAnnotationBoundingBox ``` -------------------------------- ### Copy PSPDFKit Web SDK Assets Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/signing/signing-demo-complete/README.md Copies the PSPDFKit Web SDK library assets from the node_modules directory to the public directory, making them accessible for the web application. ```Shell cp -R ./node_modules/pspdfkit/dist/pspdfkit-lib public/pspdfkit-lib ``` -------------------------------- ### Build and Serve Production Application Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/customise-annotation-sidebar/README.md These commands first create an optimized production build of the application, then serve the built files, making the application ready for deployment or previewing its final state. ```sh npm run build npm run preview ``` -------------------------------- ### Build PSPDFKit Snipping Annotation for Production Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/snipping-annotation/README.md This command compiles the PSPDFKit Snipping Annotation application for production deployment, optimizing it for performance and size. ```sh npm run build ``` -------------------------------- ### User Interface Definition Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/signing/signing-demo-complete/README.md Defines the structure of the `User` interface, outlining the properties for user roles, unique identifiers, names, and emails within the signing process. ```APIDOC User (Interface): role: string Description: Specifies the role of the user. Users with the role of 'Editor' possess capabilities to add new signing fields, additional signers, etc. id: string Description: Specifies the unique id of user. name: string Description: Specifies the name of the user. email: string Description: Specifies the email of the user. ``` -------------------------------- ### Build Text2Speech for Production Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/text-2-speech/README.md This command compiles and optimizes the Text2Speech application for production deployment, generating minified and optimized assets ready for serving in a live environment. ```sh npm run build ``` -------------------------------- ### Copy PSPDFKit Library Assets Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/create-annotation-from-clipboard/README.md Copies the PSPDFKit Web SDK library assets from `node_modules` to the `public` directory, making them accessible for the web application. ```sh cp -R ./node_modules/pspdfkit/dist/pspdfkit-lib public/pspdfkit-lib ``` -------------------------------- ### JavaScript Function to Transition and Initialize DOCX Editor Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/document-generator-vanillajs/README.md Defines the `goDocxEditor` JavaScript function, which manages the transition to the DOCX editing step. This function checks if the editor is initialized, displays a transition message, then asynchronously exports a template to DOCX, populates it with data using PSPDFKit, imports the generated DOCX, and finally initializes the Document Authoring Editor with the document. It concludes by ending the transition. ```JavaScript function goDocxEditor() { if(editGeneratedDocxSection.dataset.initialized === "no") { initDocxEditor(); } startTransition("Opening generated DOCX file..."); const editorElement = editGeneratedDocxSection.getElementsByClassName('nutri-editor')[0]; (async () => { // get template & resolve to DOCX if(APP.docxDocument == null) { const templateBuffer = await APP.templateDocument.exportDOCX(); const docxBuffer = await PSPDFKit.populateDocumentTemplate({ document: templateBuffer }, APP.dataJson); const docxDocument = await APP.docAuthSystem.importDOCX(docxBuffer); APP.docxDocument = docxDocument; } // initialize editor const editor = await APP.docAuthSystem.createEditor(editorElement, { document: APP.docxDocument }); APP.docxEditor = editor; // transition in endTransitionTo(editGeneratedDocxSection); })(); } ``` -------------------------------- ### SignDemo Component Properties Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/signing/signing-demo-complete/README.md Documentation for the properties accepted by the reusable `SignDemo` component, which is responsible for rendering the signing interface and utilizing the PSPDFKit SDK. ```APIDOC SignDemo Component Properties: allUsers: User[] Description: An array of type `User` containing all the users involved in the document signing process. user: User Description: An object of type `User` representing the currently logged-in user. ``` -------------------------------- ### Copy PSPDFKit Library Assets to Public Directory Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/speech-2-text/README.md This command copies the necessary PSPDFKit Web SDK library assets from the 'node_modules' directory to the 'public/pspdfkit-lib' directory. This step is crucial for the application to properly access and utilize PDF rendering capabilities. ```bash cp -R ./node_modules/pspdfkit/dist/pspdfkit-lib public/pspdfkit-lib ``` -------------------------------- ### Detecting UI Load with MutationObserver in JavaScript Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/viewer/detecting-when-the-viewer-UI-loads.md This approach listens for changes in the DOM, specifically for the addition of elements with the `PSPDFKit-Page` class. It's a more general method that doesn't rely on Nutrient-specific APIs, providing a flexible way to detect UI readiness by observing DOM mutations. ```javascript function attachPageLoadObserver() { const pageClassSelector = 'PSPDFKit-Page' // Select the entire DOM for observing: const target = document.querySelector('body'); // Create a new observer instance: const observer = new MutationObserver(function() { if (document.getElementsByClassName(pageClassSelector)) { console.log("Page loaded!"); // Do something ... observer.disconnect(); } }); // Start the observer observer.observe(target, { childList: true }); } … attachPageLoadObserver() … ``` -------------------------------- ### Clone Project Repository Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/redact-one-by-one/README.md Instructions to clone the Redact One by One project repository from GitHub and navigate into its directory. ```sh git clone https://github.com/Narashiman-K/Redact_onebyone_PSPDFKit.git cd Redact_onebyone_PSPDFKit ``` -------------------------------- ### HTML DOM Structure for Document Editor/Viewer Section Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/document-generator-vanillajs/README.md Illustrates the HTML structure for a single step in the application, specifically step 4, which is designed to host a document editor or viewer. Each section includes a `div` with class `nutri-editor` for editor initialization and `button` elements with `data-action` attributes for navigation and document generation. ```HTML

(4/5) Edit Generated DOCX

``` -------------------------------- ### Run Development Server with npm Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/customise-annotation-sidebar/README.md This command initiates the development server, typically configured to watch for file changes and provide hot-reloading, making it suitable for active development. The application will be accessible via a local URL. ```sh npm run dev ``` -------------------------------- ### Copy PSPDFKit Web SDK Assets Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/snipping-annotation/README.md This command copies the PSPDFKit Web SDK library assets from the `node_modules` directory to the `public/pspdfkit-lib` directory, making them accessible for the web application. ```sh cp -R ./node_modules/pspdfkit/dist/pspdfkit-lib public/pspdfkit-lib ``` -------------------------------- ### Copy Nutrient Web SDK Assets Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/redact-one-by-one/README.md Command to copy the PSPDFKit Web SDK library assets from `node_modules` to the `public` directory, making them accessible to the web application. ```sh cp -R ./node_modules/pspdfkit/dist/pspdfkit-lib public/pspdfkit-lib ``` -------------------------------- ### Initialize Template Editor Step in JavaScript Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/document-generator-vanillajs/README.md This JavaScript function, `initTemplateEditor`, handles the initialization of the template editor step (step 2) in the application. It attaches a `doButtonAction` event listener to all buttons within the `editTemplateSection`. The function destroys the existing `APP.templateEditor` to release resources before performing actions based on the button's `data-action` attribute, such as navigating back to template selection or moving to the JSON data editor. This ensures proper memory management and DOM element cleanup during step transitions. ```javascript function initTemplateEditor() { const doButtonAction = e => { const action = e.target.dataset.action; APP.templateEditor.destroy(); if(action == "back-to-template-selection") { APP.templateDocument = null; goTemplatesSelection(); } else if(action == "to-json-data") { goDataEditor(); } }; const buttons = editTemplateSection.getElementsByTagName('button'); for (let button of buttons) { button.addEventListener("click", doButtonAction); } editTemplateSection.dataset.initialized = "yes"; } ``` -------------------------------- ### Redirect to PSPDFKit Web API Documentation Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/snipping-annotation/public/Documentation.html This JavaScript snippet redirects the user's browser to the PSPDFKit Web API documentation page. It is typically used as a fallback or an immediate navigation action. ```JavaScript window.location.href = "https://pspdfkit.com/api/web/" ``` -------------------------------- ### Clone Git Repository Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/document-editor/save-selected-page-from-document-editor/README.md Clones the SaveSelectedPagefromDocumentEditor project repository from GitHub to your local machine and navigates into its directory. ```Shell git clone https://github.com/Narashiman-K/SaveSelectedPagefromDocumentEditor.git cd SaveSelectedPagefromDocumentEditor ``` -------------------------------- ### Saving Files from a URL with FileSaver.js Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/snipping-annotation/public/file-saver/README.md This JavaScript snippet demonstrates how to save a file directly from a URL using FileSaver.js. The library handles the download process, attempting to use `a[download]` for same-origin URLs or fetching via CORS for cross-origin resources, then saving the data as 'image.jpg'. ```js FileSaver.saveAs("https://httpbin.org/image", "image.jpg"); ``` -------------------------------- ### Detecting UI Load with renderPageCallback in JavaScript Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/viewer/detecting-when-the-viewer-UI-loads.md This method allows you to know when each page has been rendered by utilizing the `renderPageCallback` configuration option within PSPDFKit's load function. It's suitable for scenarios where you need page-specific rendering completion notifications. ```javascript let globalInstance; PSPDFKit.load({ ...baseOptions, renderPageCallback: function (ctx, pageIndex, pageSize) { if (pageIndex === globalInstance.totalPageCount - 1) { alert("last page loaded"); } } }).then((instance) => { globalInstance = instance; }); ``` -------------------------------- ### Importing saveAs Function (ES Module) Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/snipping-annotation/public/file-saver/README.md This JavaScript snippet shows how to import the `saveAs` function from the `file-saver` library using ES module syntax. This is the recommended way to include the library in modern JavaScript applications. ```js import { saveAs } from 'file-saver'; ``` -------------------------------- ### Saving a File Object with FileSaver.js Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/snipping-annotation/public/file-saver/README.md Demonstrates how to create a new `File` object and save it using `FileSaver.saveAs()`. It notes that older browsers like IE and Edge may require using `Blob` objects instead. The filename can be specified during construction or changed via the second argument of the `File` constructor. ```js // Note: Ie and Edge don't support the new File constructor, // so it's better to construct blobs and use saveAs(blob, filename) var file = new File(["Hello, world!"], "hello world.txt", {type: "text/plain;charset=utf-8"}); FileSaver.saveAs(file); ``` -------------------------------- ### Detecting FileSaver.js Support Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/snipping-annotation/public/file-saver/README.md This JavaScript snippet demonstrates how to feature-detect whether FileSaver.js (or rather, the underlying Blob API) is supported in the current browser environment. It attempts to create a new Blob object and catches any errors, setting a boolean flag accordingly. ```js try { var isFileSaverSupported = !!new Blob; } catch (e) {} ``` -------------------------------- ### FileSaver.js saveAs() API Reference Source: https://github.com/pspdfkit/awesome-nutrient/blob/master/web/annotation/snipping-annotation/public/file-saver/README.md This entry describes the `saveAs()` function's signature in FileSaver.js. It accepts a Blob, File, or URL as the data to be saved, an optional filename, and an optional options object which can include `autoBom` for Unicode text encoding hints. ```APIDOC FileSaver saveAs(Blob/File/Url, optional DOMString filename, optional Object { autoBom }) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.