import { ChangeDetectionStrategy, Component, computed, effect, inject, input, untracked, viewChild, 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 { EpdfAnnotation, EpdfAnnotationLayer, withAnnotation, type AnnotationProperty, type LineEnding, } from '@embedpdf/angular/annotation'; import { localEngine } from '@embedpdf/engine'; // [!doc-source layout] const layout = async (): Promise => { const response = await fetch('https://www.embedpdf.com/pdfs/layout.pdf'); return { kind: 'bytes', id: 'layout', bytes: new Uint8Array(await response.arrayBuffer()) }; }; // [!/doc-source] // One control per property, by the control it asks for. @Component({ selector: 'demo-control', changeDetection: ChangeDetectionStrategy.OnPush, template: ` @if (property(); as property) { @if (property.control === 'color') { @if (property.allowsNone) { } } @else if (property.control === 'number') { {{ isMixed() ? 'mixed' : shown() }} } @else if (property.control === 'choice' && property.key === 'lineEndings') { } @else if (property.control === 'choice' && property.key === 'borderStyle') { } @else if (property.control === 'choice') { } @else if (property.control === 'flag') { } @else if (property.control === 'textFormat') { } @else if (property.control === 'text') { } @else if (property.control === 'link') { } } `, }) export class Control { readonly property = input.required(); protected readonly annotation = inject(EpdfAnnotation); private readonly panel = this.annotation.selection.properties; protected readonly value = computed(() => this.panel().values[this.property().key]); protected readonly isMixed = computed(() => this.panel().mixed.includes(this.property().key)); protected readonly stringValue = computed(() => { const value = this.value(); return typeof value === 'string' ? value : null; }); protected readonly numberValue = computed(() => { const value = this.value(); return typeof value === 'number' ? value : null; }); /** The value as a readout or a `