import { Component, computed, inject } from '@angular/core'; import { EpdfDocumentGate, provideEmbedPdf, type OpenInput } from '@embedpdf/angular/runtime'; import { EpdfAnnotationLayer, withAnnotation } from '@embedpdf/angular/annotation'; import { EpdfInteraction, withInteraction } from '@embedpdf/angular/interaction'; import { EpdfRenderLayer, withRender } from '@embedpdf/angular/render'; import { EpdfSelectionLayer, withSelection } from '@embedpdf/angular/selection'; import { EpdfPageTemplate, EpdfStage, withStage } from '@embedpdf/angular/stage'; import { localEngine } from '@embedpdf/engine'; const welcome = async (): Promise => { const response = await fetch('https://www.embedpdf.com/pdfs/welcome.pdf'); return { kind: 'bytes', id: 'welcome', bytes: new Uint8Array(await response.arrayBuffer()) }; }; @Component({ selector: 'app-root', imports: [ EpdfDocumentGate, EpdfStage, EpdfPageTemplate, EpdfRenderLayer, EpdfSelectionLayer, EpdfAnnotationLayer, ], providers: [ provideEmbedPdf( { engine: () => localEngine(), initialDocuments: [{ source: welcome }], }, withStage(), withRender(), withInteraction(), withSelection(), withAnnotation(), ), ], template: ` `, }) export class App { private readonly interaction = inject(EpdfInteraction); protected readonly highlighting = computed(() => this.interaction.activeToolId() === 'highlight'); protected toggleHighlight() { this.interaction.activateTool(this.highlighting() ? 'pointer' : 'highlight'); } }