# QR Code

QR code generated from a string value.

> For the complete documentation index, see [llms.txt](/llms.txt). Markdown variants are available by appending `.md` to any docs URL. An agent skill is available at [/.well-known/agent-skills/site-skill.md](/.well-known/agent-skills/site-skill.md).

## Installation

```bash
npx shadcn@latest add @angular-pdfcn/forme/qrcode
```

To install manually, add the dependencies:

```bash
npm install @formepdf/core @formepdf/shared qrcode
```

Then copy these files into your project and update the import paths to match your setup:

- `components/pdf/qrcode/qrcode.ts`
- `lib/resolve-color.ts`
- `components/pdf/theme-provider.ts`
- `lib/pdf-renderer.ts`
- `lib/pdf-primitives.ts`
- `lib/render.ts`
- `lib/pdf-themes/professional.ts`
- `lib/pdf-themes/primitives.ts`
- `types/pdf-themes.ts`
- `types/pdf-components.ts`

## Usage

```ts
import { Component } from "@angular/core";

import { PdfHeading } from "@/components/pdf/heading/heading";
import { PdfQRCode } from "@/components/pdf/qrcode/qrcode";
import { PdfSection } from "@/components/pdf/section/section";
import { PdfStack } from "@/components/pdf/stack/stack";
import { PdfText } from "@/components/pdf/text/text";
import {
  FormeDocument,
  FormePage,
} from "@/lib/pdf-primitives";

@Component({
  imports: [
    FormeDocument,
    FormePage,
    PdfHeading,
    PdfQRCode,
    PdfSection,
    PdfStack,
    PdfText,
  ],
  template: `
    <forme-document>
      <forme-page size="A4" [margin]="40">
        <pdf-section spacing="none">
          <pdf-heading [level]="1">Invoice #12345</pdf-heading>
          <pdf-text>Amount Due: $500.00</pdf-text>
          <pdf-section>
            <pdf-stack direction="horizontal" gap="lg" align="start">
              <pdf-qrcode
                value="https://pdfcn.dev/pay/invoice-12345"
                [size]="100"
                caption="Scan to pay"
              />
              <pdf-qrcode
                value="https://pdfcn.dev/verify/invoice-12345"
                [size]="80"
                caption="Verify document"
              />
            </pdf-stack>
          </pdf-section>
          <pdf-text variant="sm" color="mutedForeground"
            >QR codes are rendered as crisp vector graphics in the generated
            PDF.</pdf-text
          >
        </pdf-section>
      </forme-page>
    </forme-document>
  `,
})
export class QRCodeDemo {}
```

## API Reference

### PdfQRCode

| Input             | Type                       | Default |
| ----------------- | -------------------------- | ------- |
| `value`           | `string`                   | -       |
| `size`            | `number`                   | -       |
| `color`           | `string`                   | -       |
| `backgroundColor` | `string`                   | -       |
| `errorLevel`      | `'L' \| 'M' \| 'Q' \| 'H'` | -       |
| `margin`          | `number`                   | -       |
| `caption`         | `string`                   | -       |