import { ChangeDetectionStrategy, Component, ViewEncapsulation } from '@angular/core'; import { createCapabilityToken, EpdfDocumentGate, provideEmbedPdf, } from '@embedpdf/angular/runtime'; import type { OpenInput } from '@embedpdf/angular/runtime'; import { EpdfPageChrome, EpdfPageTemplate, EpdfStage, withStage } from '@embedpdf/angular/stage'; import type { StageCapability } from '@embedpdf/angular/stage'; import { EpdfRenderLayer, withRender } from '@embedpdf/angular/render'; import { localEngine } from '@embedpdf/engine'; // The strip is a second view of the document, with its own token and settings. const ThumbsToken = createCapabilityToken('stage-thumbs'); // [!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, EpdfPageChrome, EpdfRenderLayer], providers: [ provideEmbedPdf( { engine: () => localEngine(), initialDocuments: [{ source: welcome }] }, withStage(), // the main view withStage({ id: 'stage-thumbs', token: ThumbsToken, interaction: false, // a drag doesn't select text or draw zoomGestures: false, // a pinch doesn't resize the thumbnails zoom: { pageWidth: 96 }, gap: { px: 12 }, padding: 10, pageFrame: { bottom: 20 }, // room for the page number // A wide, short strip (on a phone) lines the thumbnails up in a row. responsive: [{ when: { orientation: 'landscape' }, settings: { layout: 'horizontal' } }], }), withRender(), ), ], changeDetection: ChangeDetectionStrategy.OnPush, styleUrl: './thumbnail-strip.css', encapsulation: ViewEncapsulation.None, template: `
{{ page.pageIndex() + 1 }}

Loading…

`, }) export class App { protected readonly thumbsToken = ThumbsToken; }