/** * Your own components in ``: `epdfToolbarItem`, `epdfPanel` and `epdfRegion` * put them in the viewer, `EpdfToolbarItemContext` says where an item sits (and follows the bar * to a rail when the viewer narrows), and ``, ``, `` and * `` are the viewer's own, `active` too. `components.test.ts` drives it. */ import { boot } from './boot'; import { Component, inject, signal } from '@angular/core'; import { EpdfButton, EpdfIcon, EpdfMenu, EpdfMenuItem, EpdfPanel, EpdfPdfViewer, EpdfRegion, EpdfToolbarItem, EpdfToolbarItemContext, } from '@embedpdf/viewer-angular'; import type { LayoutFunction, Viewer } from '@embedpdf/viewer-angular'; import { checkRecord } from './check'; export interface ComponentsRecord { viewer: Viewer | null; /** What each `` picked said, in order. */ readonly picked: string[]; setWidth(width: string): void; } const record = checkRecord({ viewer: null, picked: [], setWidth: () => {} }); /** Where its toolbar item sits, as the item context says it. */ @Component({ selector: 'app-where', template: ` {{ item.orientation() }} `, }) export class Where { protected readonly item = inject(EpdfToolbarItemContext); } /** Two sizes, as the item context picks: the toolbar must measure the one it draws. */ @Component({ selector: 'app-sized', template: ` Sized `, }) export class Sized { protected readonly item = inject(EpdfToolbarItemContext); } const layout: LayoutFunction = (base, env) => { const placed = base .add({ custom: 'where' }, { to: 'main', section: 'start' }) .add( { custom: 'sized', variants: ['full', 'short'], command: 'zoom:in' }, { to: 'main', section: 'start' }, ) .add({ custom: 'zoom-in' }, { to: 'main', section: 'start' }) .add({ custom: 'share' }, { to: 'main', section: 'start' }) .add({ custom: 'toggle' }, { to: 'main', section: 'end' }) .addPanel('notes', { side: 'end', title: 'Notes', icon: 'book' }) .add('panel:notes', { to: 'main', section: 'end' }); return env.width < 900 ? placed.place('main', 'start') : placed; }; @Component({ selector: 'app-root', imports: [ EpdfPdfViewer, EpdfToolbarItem, EpdfPanel, EpdfRegion, EpdfButton, EpdfIcon, EpdfMenu, EpdfMenuItem, Where, Sized, ], template: `
Acme Contracts
Copy link Email a link Show notes
`, }) export class App { protected readonly layout = layout; protected readonly width = signal('100%'); protected readonly night = signal(false); constructor() { record.setWidth = (width) => this.width.set(width); } protected ready(viewer: Viewer): void { record.viewer = viewer; } protected pick(name: string): void { record.picked.push(name); } } boot(App);