In the browser
@inkoxide/angular/browser renders in a Web Worker, with
@inkoxide/wasm installed:
injectPdf(document, options?)renders the document (a value, a signal, or a function that reads signals) at once and whenever it changes, and givesblob,url,safeUrl(trusted for<iframe [src]>),loadinganderroras signals, andupdate(). Call it in an injection context; destroying the injector stops the render and revokes the URL.- Three directives, for the elements they drive:
<iframe [inkPdfViewer]="document">shows the PDF in the browser's viewer ([inkPdfViewerToolbar]="false"hides its toolbar);<a [inkPdfDownload]="document" inkPdfDownloadFile="invoice.pdf">downloads it once it has rendered (aria-disableduntil then);#link="inkPdfDownload"giveslink.pdf, the state;<ng-container *inkBlobProvider="document; let pdf">shows its content with the state.
renderToBlobandrenderToStream(a web stream).
import { Component, input } from '@angular/core';
import { InkPdfDownload, InkPdfViewer } from '@inkoxide/angular/browser';
import { Receipt } from './receipt';
@Component({
selector: 'app-preview',
imports: [InkPdfViewer, InkPdfDownload],
template: `
<iframe [inkPdfViewer]="document()" title="Receipt"></iframe>
<a [inkPdfDownload]="document()" inkPdfDownloadFile="receipt.pdf">Download</a>
`,
})
export class Preview {
readonly customer = input.required<string>();
readonly document = () => ({ component: Receipt, inputs: { customer: this.customer() } });
}
They render again only when the document is another one: another component, or other input
values. The directives are declared as a library compiled for linking is, so the application's
Angular build links them. Where the engine and the fonts come from, a CDN and Content Security
Policy are in the React guide's
In the browser;
an application compiled ahead of time needs no 'unsafe-eval'.
Tailwind in an Angular CLI build
In a browser, @inkoxide/tailwind loads Tailwind's compiler (about 90 KB with brotli) unless the
build replaces it with a table of the classes the sources use: its esbuild plugin,
inkoxideTailwindEsbuild, does that (@inkoxide/tailwind).
The Angular CLI's application builder takes no esbuild plugins of its own;
@angular-builders/custom-esbuild
(of your Angular major version) adds them:
// angular.json, the build target of the application
"builder": "@angular-builders/custom-esbuild:application",
"options": {
"plugins": ["./esbuild/inkoxide-tailwind.ts"]
// … the application builder's own options, as before
}
// esbuild/inkoxide-tailwind.ts
import { inkoxideTailwindEsbuild } from '@inkoxide/tailwind/plugin';
// The templates' classes, in the components' inline templates and .html files.
export default inkoxideTailwindEsbuild({ sources: ['src'] });
The plugin acts on the browser bundles and leaves the server's (ng build with SSR) alone, which
keeps the compiler. The conformance tests build an application this way. Without it, the templates get the same classes, with the compiler loaded in
the browser.
Synced from packages/angular/GUIDE.md in the inkoxide repository.