import { ChangeDetectionStrategy, Component, signal, ViewEncapsulation } from '@angular/core'; import { EpdfDocumentGate, 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 { EpdfSelectionLayer, withSelection } from '@embedpdf/angular/selection'; import { withInteraction } from '@embedpdf/angular/interaction'; import { EpdfAnnotationLayer, EpdfAnnotationTemplate, withAnnotation, type Annotation, } from '@embedpdf/angular/annotation'; import { cloudEngine } from '@cloudpdf/engine'; const proposal: OpenInput = { kind: 'grant', grant: 'shr_qnqHtCNRpzz-s7DPFBIbuOAF' }; @Component({ selector: 'demo-root', imports: [ EpdfDocumentGate, EpdfStage, EpdfPageTemplate, EpdfRenderLayer, EpdfSelectionLayer, EpdfAnnotationLayer, EpdfAnnotationTemplate, ], providers: [ provideEmbedPdf( { engine: () => cloudEngine(), identity: { userId: 'u_381', displayName: 'Dana Smith' }, initialDocuments: [{ source: proposal }], }, withStage(), withRender(), withInteraction(), withSelection(), withAnnotation(), ), ], changeDetection: ChangeDetectionStrategy.OnPush, styleUrl: './renderers.css', encapsulation: ViewEncapsulation.None, template: ` Your look The PDF's look Turn the view @if (mine()) { {{ initials(annotation) }} } Loading… `, }) export class App { protected readonly mine = signal(true); // Kept in a field, the same function on every page: the layer registers each look once. protected readonly isNote = (annotation: Annotation) => annotation.subtype === 'text'; protected initials(annotation: Annotation) { return (annotation.author ?? '?') .split(' ') .map((word) => word[0]) .join(''); } }
Loading…