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 { withInteraction } from '@embedpdf/angular/interaction'; import { EpdfForm, EpdfFormLayer, withForm } from '@embedpdf/angular/form'; import { localEngine } from '@embedpdf/engine'; // [!doc-source forms] const forms = async (): Promise => { const response = await fetch('https://www.embedpdf.com/pdfs/forms.pdf'); return { kind: 'bytes', id: 'forms', bytes: new Uint8Array(await response.arrayBuffer()) }; }; // [!/doc-source] const COLORS = [ ['Accent', null], ['Orange', '#ea580c'], ['Green', '#16a34a'], ] as const; @Component({ selector: 'demo-root', imports: [EpdfDocumentGate, EpdfStage, EpdfPageTemplate, EpdfRenderLayer, EpdfFormLayer], providers: [ provideEmbedPdf( { engine: () => localEngine(), initialDocuments: [{ source: forms }] }, withStage(), withRender(), withInteraction(), // The colors the viewer draws around fields; `null` follows the viewer's accent. withForm({ fields: { border: '#ea580c' } }), ), ], changeDetection: ChangeDetectionStrategy.OnPush, styleUrl: './colors.css', encapsulation: ViewEncapsulation.None, template: `
Edges
@for (color of colors; track color[0]) { }
Focus
@for (color of colors; track color[0]) { }

Loading…

`, }) export class App { protected readonly form = inject(EpdfForm); protected readonly colors = COLORS; }