import { ChangeDetectionStrategy, Component, computed, inject, input, signal, ViewEncapsulation, } from '@angular/core'; import { EpdfDocument, EpdfDocumentGate, EpdfDocuments, EpdfViewer, provideEmbedPdf, } from '@embedpdf/angular/runtime'; import type { OpenInput } from '@embedpdf/angular/runtime'; import { EpdfPageTemplate, EpdfStage, withStage } from '@embedpdf/angular/stage'; import { EpdfRenderLayer, withRender } from '@embedpdf/angular/render'; import { EpdfInteraction, withInteraction } from '@embedpdf/angular/interaction'; import { EpdfAnnotationLayer, withAnnotation } from '@embedpdf/angular/annotation'; import { EpdfForm, EpdfFormLayer, withForm } from '@embedpdf/angular/form'; import { cloudEngine } from '@cloudpdf/engine'; const engine = cloudEngine(); const loan: OpenInput = { kind: 'grant', grant: 'shr_WGj1goAtlNN_fQ5OswPrbJQM' }; // Who the document's groups are: your app's own list. The PDF holds only each field's group id. const signers = [ { id: 'borrower', label: 'Dana Smith', color: '#2563eb' }, { id: 'approver', label: 'Ada Lovelace' }, // a color is picked for it ]; // The sender places fields for both signers. Each signer fills in and signs their own, and your // app knows who each of them is. const see = ['doc.open', 'doc.render', 'doc.download', 'doc.forms.read']; const people = { sender: { name: 'The sender', scope: [ ...see, 'doc.forms.modify', 'fields:set-group:group=borrower', 'fields:set-group:group=approver', ], identity: null, }, borrower: { name: 'Dana Smith', scope: [...see, 'fields:fill:group=borrower', 'fields:sign:group=borrower'], identity: { userId: 'u_381', displayName: 'Dana Smith', email: 'dana@fernquill.example', organization: 'Fernquill Ltd', title: 'Operations', }, }, approver: { name: 'Ada Lovelace', scope: [...see, 'fields:fill:group=approver', 'fields:sign:group=approver'], identity: { userId: 'u_412', displayName: 'Ada Lovelace', email: 'ada@fernquill.example', organization: 'Fernquill Ltd', title: 'Finance', }, }, }; type Person = keyof typeof people; // A signing tool for each kind of value: a text box that says what it is for. const VALUE_TOOLS = [ ['signer-name', 'Name'], ['signer-email', 'Email'], ['signer-organization', 'Organization'], ['signer-organization-title', 'Title'], ['signer-date-signed', 'Date signed'], ] as const; /** The sender picks who the next field is for and what it is for, and clicks the page. */ @Component({ selector: 'demo-sender-toolbar', changeDetection: ChangeDetectionStrategy.OnPush, template: `
`, }) export class SenderToolbar { protected readonly form = inject(EpdfForm); protected readonly interaction = inject(EpdfInteraction); protected readonly tools = VALUE_TOOLS; constructor() { // Start by placing name fields for the first signer. this.form.setDesignGroup('borrower'); this.interaction.activateTool('signer-name'); } } /** A signer starts: the app fills in what it knows about them, in their own fields, as one change. */ @Component({ selector: 'demo-signer-bar', changeDetection: ChangeDetectionStrategy.OnPush, template: ` `, }) export class SignerBar { readonly person = input.requiredOpening…