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 { localEngine } from '@embedpdf/engine'; const proposal = async (): Promise => { const response = await fetch('https://www.embedpdf.com/pdfs/proposal.pdf'); return { kind: 'bytes', id: 'proposal', bytes: new Uint8Array(await response.arrayBuffer()) }; }; @Component({ selector: 'demo-root', imports: [ EpdfDocumentGate, EpdfStage, EpdfPageTemplate, EpdfRenderLayer, EpdfSelectionLayer, EpdfAnnotationLayer, EpdfAnnotationTemplate, ], providers: [ provideEmbedPdf( { engine: () => localEngine(), 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: `
@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(''); } }