import { ChangeDetectionStrategy, Component, computed, 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 { EpdfRender, EpdfRenderLayer, withRender } from '@embedpdf/angular/render'; import { cloudEngine } from '@cloudpdf/engine'; const welcome: OpenInput = { kind: 'grant', grant: 'shr_gvpJcG1ULUMon19C0D1wODSY' }; const BUDGETS = [320, 640, 1280]; @Component({ selector: 'demo-root', imports: [EpdfDocumentGate, EpdfStage, EpdfPageTemplate, EpdfRenderLayer], providers: [ provideEmbedPdf( { engine: () => cloudEngine(), initialDocuments: [{ source: welcome }] }, // Zoomed in, where the budget and the tiles show. withStage({ zoom: { level: 2 } }), withRender(), ), ], changeDetection: ChangeDetectionStrategy.OnPush, styleUrl: './budget.css', encapsulation: ViewEncapsulation.None, template: ` Budget @for (width of budgets; track width) { {{ width }} px } Tiles On Off − {{ percent(stage.zoomLevel()) }}% + Loading… `, }) export class App { protected readonly render = inject(EpdfRender); protected readonly budgets = BUDGETS; protected readonly maxWidth = computed(() => this.render.settings().fullPage.maxWidth); protected readonly tiles = computed(() => this.render.settings().tiles !== false); protected percent(zoomLevel: number): number { return Math.round(zoomLevel * 100); } }
Loading…