import { ChangeDetectionStrategy, Component, inject, input, ViewEncapsulation, } from '@angular/core'; import { EpdfDocument, EpdfDocumentGate, EpdfDocuments, EpdfDocumentScope, 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 { cloudEngine } from '@cloudpdf/engine'; const welcome: OpenInput = { kind: 'grant', grant: 'shr_gvpJcG1ULUMon19C0D1wODSY' }; const article: OpenInput = { kind: 'grant', grant: 'shr_v09cJHOmj3C8vrfUlZNTDyqX' }; // The same component in both panes: each talks to the document its [epdfDocumentScope] names. @Component({ selector: 'demo-header', changeDetection: ChangeDetectionStrategy.OnPush, template: `
{{ document.name() }} {{ document.pageCount() }} pages {{ percent(stage().zoomLevel()) }}%
`, }) export class Header { readonly stage = input.required(); protected readonly document = inject(EpdfDocument); protected percent(zoomLevel: number): number { return Math.round(zoomLevel * 100); } } @Component({ selector: 'demo-root', imports: [ EpdfDocumentScope, EpdfDocumentGate, EpdfStage, EpdfPageTemplate, EpdfRenderLayer, Header, ], providers: [ provideEmbedPdf( { engine: () => cloudEngine(), initialDocuments: [ { source: welcome, name: 'Guide' }, { source: article, name: 'Article' }, ], }, withStage(), withRender(), ), ], changeDetection: ChangeDetectionStrategy.OnPush, styleUrl: './scope.css', encapsulation: ViewEncapsulation.None, template: `
@for (document of documents.documents(); track document.id) {
}

Opening…

`, }) export class App { protected readonly documents = inject(EpdfDocuments); }