import { ChangeDetectionStrategy, Component, signal, 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 { 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] @Component({ selector: 'demo-root', imports: [EpdfDocumentGate, EpdfStage, EpdfPageTemplate, EpdfRenderLayer], providers: [ provideEmbedPdf( { engine: () => localEngine(), initialDocuments: [{ source: welcome }] }, // Facing pages with a roomy margin, and one rule for a narrow Stage: a thin // margin and one page at a time. The rule has a name, so the UI can read it too. withStage({ padding: 24, spread: 'odd', responsive: [ { name: 'compact', when: { maxWidth: 600 }, settings: { padding: 4, spread: 'none' } }, ], }), withRender(), ), ], changeDetection: ChangeDetectionStrategy.OnPush, styleUrl: './responsive.css', encapsulation: ViewEncapsulation.None, template: ` @let compact = stage.activeRules().includes('compact'); @let padding = stage.settings().padding;
compact {{ compact ? 'on' : 'off' }} padding {{ typeof padding === 'number' ? padding : 'by side' }} · spread {{ stage.settings().spread }}

Loading…

`, }) export class App { protected readonly narrow = signal(false); }