import { ChangeDetectionStrategy, Component, computed, inject, ViewEncapsulation, } from '@angular/core'; import { EpdfDocument, EpdfDocumentGate, EpdfDocuments, provideEmbedPdf, saveFile, } 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 { EpdfSelectionLayer, withSelection } from '@embedpdf/angular/selection'; import { EpdfInteraction, withInteraction } from '@embedpdf/angular/interaction'; import { EpdfAnnotationLayer, withAnnotation } from '@embedpdf/angular/annotation'; import { cloudEngine } from '@cloudpdf/engine'; const report: OpenInput = { kind: 'grant', grant: 'shr__TWhIGdJtaKlcnVgJdg--bcm' }; // The annotations are part of the document: the downloaded PDF has every one. @Component({ selector: 'demo-save-bar', changeDetection: ChangeDetectionStrategy.OnPush, template: `
`, }) export class SaveBar { private readonly documents = inject(EpdfDocuments); protected readonly interaction = inject(EpdfInteraction); protected readonly document = inject(EpdfDocument); protected readonly drawing = computed(() => this.interaction.activeToolId() === 'ink'); protected async download() { saveFile(await this.documents.download(), 'annotated.pdf'); } } @Component({ selector: 'demo-root', imports: [ EpdfDocumentGate, EpdfStage, EpdfPageTemplate, EpdfRenderLayer, EpdfSelectionLayer, EpdfAnnotationLayer, SaveBar, ], providers: [ provideEmbedPdf( { engine: () => cloudEngine(), initialDocuments: [{ source: report }] }, withStage(), withRender(), withInteraction(), withSelection(), withAnnotation(), ), ], changeDetection: ChangeDetectionStrategy.OnPush, styleUrl: './download.css', encapsulation: ViewEncapsulation.None, template: `Loading…