import { ChangeDetectionStrategy, Component, 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 type { StageSettings } from '@embedpdf/angular/stage'; import { EpdfRenderLayer, withRender } from '@embedpdf/angular/render'; import { localEngine } from '@embedpdf/engine'; // A preset is an object you keep, and apply with updateSettings(). const READING: Partial = { arrivalAlign: { x: 'start', y: 'start' }, zoomAlign: { x: 'center', y: 'center' }, anchorAlign: { x: 'start', y: 'start' }, }; const PRESENTATION: Partial = { arrivalAlign: { x: 'center', y: 'center' }, zoomAlign: { x: 'center', y: 'center' }, anchorAlign: { x: 'center', y: 'center' }, }; // [!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] @Component({ selector: 'demo-root', imports: [EpdfDocumentGate, EpdfStage, EpdfPageTemplate, EpdfRenderLayer], providers: [ provideEmbedPdf( { engine: () => localEngine(), initialDocuments: [{ source: welcome }] }, // Zoomed in, so a page is wider than the view and you can see where it lands. withStage({ zoom: { level: 1.6 } }), withRender(), ), ], changeDetection: ChangeDetectionStrategy.OnPush, styleUrl: './presets.css', encapsulation: ViewEncapsulation.None, template: ` @let presentation = stage.settings().arrivalAlign.y === 'center';

Loading…

`, }) export class App { protected readonly reading = READING; protected readonly presentationFeel = PRESENTATION; }