import { ChangeDetectionStrategy, Component, computed, effect, inject, input, 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 { withSearch } from '@embedpdf/angular/search'; import { annotationKey, EpdfAnnotation, EpdfAnnotationLayer, withAnnotation, } from '@embedpdf/angular/annotation'; import { EpdfRedaction, withRedaction } from '@embedpdf/angular/redaction'; import { cloudEngine } from '@cloudpdf/engine'; const welcome: OpenInput = { kind: 'grant', grant: 'shr_gvpJcG1ULUMon19C0D1wODSY' }; /** Next to ``: `
`. */ @Component({ selector: 'div[demoPendingMarks]', changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'panel' }, template: `
{{ count() }}
`, }) export class PendingMarks { readonly stage = input.required(); // pending(): the marks not applied yet, in page order. protected readonly redaction = inject(EpdfRedaction); protected readonly key = annotationKey; protected readonly count = computed(() => { const count = this.redaction.pendingCount(); return `${count} ${count === 1 ? 'mark' : 'marks'}`; }); } @Component({ selector: 'demo-root', imports: [ EpdfDocumentGate, EpdfStage, EpdfPageTemplate, EpdfRenderLayer, EpdfAnnotationLayer, PendingMarks, ], providers: [ provideEmbedPdf( { engine: () => cloudEngine(), initialDocuments: [{ source: welcome }] }, withStage(), withRender(), withInteraction(), withSearch(), withAnnotation(), withRedaction(), ), ], changeDetection: ChangeDetectionStrategy.OnPush, styleUrl: './review.css', encapsulation: ViewEncapsulation.None, template: `

Loading…

`, }) export class App { private readonly redaction = inject(EpdfRedaction); private readonly annotation = inject(EpdfAnnotation); private started = false; constructor() { // On load: the cover's subtitle, and every "Adobe" in the document. effect(() => { if (this.annotation.status() !== 'ready' || this.started) return; this.started = true; void this.redaction .markArea(0, { x: 44, y: 318, width: 206, height: 50 }) .then(() => this.redaction.markMatches({ text: 'Adobe' })); }); } }