import { ChangeDetectionStrategy, Component, 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 { EpdfInteraction, withInteraction } from '@embedpdf/angular/interaction'; import { EpdfAnnotationLayer, withAnnotation, withFilePicker } from '@embedpdf/angular/annotation'; import { localEngine } from '@embedpdf/engine'; const approvals = async (): Promise => { const response = await fetch('https://www.embedpdf.com/pdfs/approvals.pdf'); return { kind: 'bytes', id: 'approvals', bytes: new Uint8Array(await response.arrayBuffer()) }; }; const TOOLS = [ { id: 'pointer', label: 'Select' }, { id: 'stamp', label: 'Stamp' }, { id: 'attachment', label: 'Attach a file' }, ]; @Component({ selector: 'demo-toolbar', changeDetection: ChangeDetectionStrategy.OnPush, template: ` `, }) export class Toolbar { protected readonly interaction = inject(EpdfInteraction); protected readonly tools = TOOLS; constructor() { // On load: the stamp tool is active. this.interaction.activateTool('stamp'); } } @Component({ selector: 'demo-root', imports: [ EpdfDocumentGate, EpdfStage, EpdfPageTemplate, EpdfRenderLayer, EpdfSelectionLayer, EpdfAnnotationLayer, Toolbar, ], providers: [ provideEmbedPdf( { engine: () => localEngine(), initialDocuments: [{ source: approvals }] }, withStage(), withRender(), withInteraction(), withSelection(), withAnnotation(), // The browser's file dialog, for the stamp and attachment tools of every document. withFilePicker(), ), ], changeDetection: ChangeDetectionStrategy.OnPush, styleUrl: './file-picker.css', encapsulation: ViewEncapsulation.None, template: `

Loading…

`, }) export class App {}