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 { EpdfInteraction, withInteraction } from '@embedpdf/angular/interaction'; import { EpdfAnnotation, EpdfAnnotationLayer, withAnnotation } from '@embedpdf/angular/annotation'; import { localEngine } from '@embedpdf/engine'; // [!doc-source sketch] const sketch = async (): Promise => { const response = await fetch('https://www.embedpdf.com/pdfs/sketch.pdf'); return { kind: 'bytes', id: 'sketch', bytes: new Uint8Array(await response.arrayBuffer()) }; }; // [!/doc-source] @Component({ selector: 'demo-after-drawing', changeDetection: ChangeDetectionStrategy.OnPush, template: `
{{ interaction.activeToolId() === 'square' ? 'Drawing' : 'Selecting' }}
`, }) export class AfterDrawing { protected readonly annotation = inject(EpdfAnnotation); protected readonly interaction = inject(EpdfInteraction); protected readonly afterCreate = computed(() => this.annotation.settings().afterCreate); constructor() { // The rectangle tool is active on load. this.interaction.activateTool('square'); } } @Component({ selector: 'demo-root', imports: [ EpdfDocumentGate, EpdfStage, EpdfPageTemplate, EpdfRenderLayer, EpdfAnnotationLayer, AfterDrawing, ], providers: [ provideEmbedPdf( { engine: () => localEngine(), initialDocuments: [{ source: sketch }] }, withStage(), withRender(), withInteraction(), withAnnotation(), ), ], changeDetection: ChangeDetectionStrategy.OnPush, styleUrl: './after-create.css', encapsulation: ViewEncapsulation.None, template: `

Loading…

`, }) export class App {}