import { ChangeDetectionStrategy, Component, computed, inject, signal, ViewEncapsulation, } from '@angular/core'; import { EpdfDocumentGate, provideEmbedPdf } from '@embedpdf/angular/runtime'; import type { OpenInput } from '@embedpdf/angular/runtime'; import { EpdfFonts, injectFontCss, withFonts } from '@embedpdf/angular/fonts'; import { localEngine } from '@embedpdf/engine'; // [!doc-source welcome] 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()) }; }; // [!/doc-source] // Type in any font the document can be written in, drawn as the engine will write it. @Component({ selector: 'demo-root', imports: [EpdfDocumentGate], providers: [ provideEmbedPdf( { engine: () => localEngine(), initialDocuments: [{ source: welcome }] }, withFonts(), ), ], changeDetection: ChangeDetectionStrategy.OnPush, styleUrl: './draw.css', encapsulation: ViewEncapsulation.None, template: `

Characters no font has show as boxes, as the engine writes them.

Loading…

`, }) export class App { private readonly fonts = inject(EpdfFonts); protected readonly font = signal('times-roman'); // The font's CSS, its programs mounted while this component lives. protected readonly css = injectFontCss(() => this.font()); protected readonly choosable = computed( () => this.fonts.list()?.fonts.filter((entry) => entry.canChoose) ?? [], ); }