# itextsharp.xmlworker

**Kind:** Service

**Source:** `Pams/Core/Pams.Core/Pams.Core.csproj` (line 1)

**Part of:** [Pams](subsystem-pams)

NuGet package dependency

`itextsharp.xmlworker` is a NuGet package dependency referenced by `Pams.Core.csproj`. It supports XHTML and CSS processing when Pams.Core generates PDF content from markup.

## Diagram

```mermaid
sequenceDiagram
    participant Client
    participant PamsCore as Pams.Core
    participant XMLWorker as itextsharp.xmlworker
    participant PDF as PDF Output

    Client->>PamsCore: Send HTML content
    PamsCore->>XMLWorker: Parse XHTML and CSS
    XMLWorker-->>PamsCore: Render PDF elements
    PamsCore->>PDF: Write generated document
    PDF-->>Client: Return PDF data
```

## Usage

```ts
async function generatePdf(html: string): Promise<Blob> {
  const response = await fetch("/api/documents/pdf", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ html }),
  });

  if (!response.ok) {
    throw new Error("PDF generation failed");
  }

  return response.blob();
}

const pdf = await generatePdf(`
  <html>
    <body>
      <h1>Document title</h1>
      <p>Content rendered by Pams.Core with itextsharp.xmlworker.</p>
    </body>
  </html>
`);
```

## AI Coding Instructions

- Keep `itextsharp.xmlworker` referenced through the `Pams.Core` project dependency rather than from client-side code.
- Pass valid XHTML and supported CSS when generating PDF markup.
- Treat HTML input as untrusted unless it has been validated or sanitized before PDF generation.
- Keep PDF generation logic in the .NET service layer; JavaScript clients should send markup or document data through an application API.

## Used by

1 reference from 1 file. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

### Injected or called by (1)

- `Pams.Core` — `Pams/Core/Pams.Core/Pams.Core.csproj`:1
