import { ChangeDetectionStrategy, Component, computed, inject, 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 { EpdfAnnotation, EpdfAnnotationLayer, withAnnotation } from '@embedpdf/angular/annotation'; import { localEngine } from '@embedpdf/engine'; const report = async (): Promise => { const response = await fetch('https://www.embedpdf.com/pdfs/report.pdf'); return { kind: 'bytes', id: 'report', bytes: new Uint8Array(await response.arrayBuffer()) }; }; @Component({ selector: 'demo-status', changeDetection: ChangeDetectionStrategy.OnPush, template: `

{{ text() }}

`, }) export class Status { private readonly annotation = inject(EpdfAnnotation); protected readonly text = computed(() => { const selected = this.annotation.selected(); if (this.annotation.status() === 'loading') return 'Loading the annotations…'; if (selected.length > 0) return `Selected: ${selected.map((a) => a.subtype).join(', ')}`; return 'Click an annotation to select it'; }); } @Component({ selector: 'demo-root', imports: [ EpdfDocumentGate, EpdfStage, EpdfPageTemplate, EpdfRenderLayer, EpdfSelectionLayer, EpdfAnnotationLayer, Status, ], providers: [ provideEmbedPdf( { engine: () => localEngine(), initialDocuments: [{ source: report }] }, withStage(), withRender(), withInteraction(), withSelection(), withAnnotation(), ), ], changeDetection: ChangeDetectionStrategy.OnPush, styleUrl: './layer.css', encapsulation: ViewEncapsulation.None, template: `

Loading…

`, }) export class App {}