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 { withInteraction } from '@embedpdf/angular/interaction'; import { EpdfSelectionLayer, withSelection } from '@embedpdf/angular/selection'; import { EpdfAnnotationLayer, withAnnotation } from '@embedpdf/angular/annotation'; import { standardCommands, withCommands } from '@embedpdf/angular/commands'; import { EpdfToolbar, EpdfToolbarCommandTemplate, group, item, } from '@embedpdf/angular/toolbar'; import type { BarSchema } from '@embedpdf/angular/toolbar'; 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()) }; }; // Your icons, by the names the standard commands give them. const ICONS: Record = { 'previous-page': '‹', 'next-page': '›', 'zoom-out': '−', 'zoom-in': '+', 'fit-width': '↔', pointer: '↖', pan: '✥', highlight: '▍', underline: 'U̲', ink: '〰', download: '↓', print: '⎙', }; const bar: BarSchema = { id: 'main', sections: { start: [group('pages', ['page:previous', 'page:next'])], center: [ group('zoom', [ 'zoom:out', item('zoom:in', { variants: ['icon+label', 'icon'] }), item('zoom:fit-width', { variants: ['icon+label', 'icon'], importance: 2 }), ]), ], end: [ group('tools', ['tool:pointer', 'tool:pan', 'tool:highlight', 'tool:underline', 'tool:ink'], { collapse: 'menu', }), group('document', [item('document:download', { importance: 5 }), 'document:print']), ], }, }; @Component({ selector: 'demo-root', imports: [ EpdfDocumentGate, EpdfStage, EpdfPageTemplate, EpdfRenderLayer, EpdfSelectionLayer, EpdfAnnotationLayer, EpdfToolbar, EpdfToolbarCommandTemplate, ], providers: [ provideEmbedPdf( { engine: () => localEngine(), initialDocuments: [{ source: welcome }] }, withStage(), withRender(), withInteraction(), withSelection(), withAnnotation(), withCommands({ commands: standardCommands }), ), ], changeDetection: ChangeDetectionStrategy.OnPush, styleUrl: './basic.css', encapsulation: ViewEncapsulation.None, template: `

Loading…

`, }) export class App { protected readonly bar = bar; protected readonly icons = ICONS; protected readonly width = signal(100); }