Integrate CloudPDF inside your Angular App
If you already have an Angular project you want to integrate with CloudPDF, then you can simply add the CloudPDF Javascript library as a dependency to your project. Let's walk through all the steps to get CloudPDF integrated into your project!
1. Add CloudPDF as a dependency
Now add CloudPDF as a dependency to your project. Launch the terminal (command prompt or similar on Windows), point it to your project location, and run the following command:
Using Yarn
yarn add @cloudpdf/viewer
Using NPM
npm install @cloudpdf/viewer --save
2. Render CloudPDF
import { Component, ViewChild, ElementRef, AfterViewInit } from "@angular/core";import CloudPdfViewer from "@cloudpdf/viewer";@Component({selector: "app-root",templateUrl: "./app.component.html",styleUrls: ["./app.component.css"]})export class AppComponent implements AfterViewInit {@ViewChild("viewer", { static: false }) viewer: ElementRef;ngAfterViewInit(): void {CloudPdfViewer({documentId: "eee2079d-b0b6-4267-9812-b6b9eadb9c60",darkMode: true},this.viewer.nativeElement).then((instance) => {});}}
- documentId After you upload your document to CloudPDF you will receive a documentId. How to upload a document?
- darkMode You can set the viewer to light or dark mode by changing this variable to true or false
To view all the options go to viewer options
NOTE: In this example we set our document security to public. After uploading a document, the document is by default set on non-public to guarantee security. To view a document that is not public you must first create a signature on your server or you can change the security settings on a document.