# Add-OfficePdfAttachment

Adds an embedded file attachment to a generated PDF document.

Project

PSWriteOffice

PowerShell document automation across OfficeIMO's document, spreadsheet, presentation, PDF, Project, Access, EPUB, invoicing, and conversion engines.

[View on GitHub](https://github.com/EvotecIT/OfficeIMO/tree/master/PowerShell/PSWriteOffice) [Visit Website](#) [Releases](https://github.com/EvotecIT/PSWriteOffice/releases/tag/v3.0.5) [Changelog](#) [Get package](https://www.powershellgallery.com/packages/PSWriteOffice/0.2.0)

Stars **727**

Forks **84**

Open issues **7**

Total downloads **5,275,783**

Release **OfficeIMO-v3.6.2**

Language: C# Updated: 2026-11-24

Cmdlet 

Aliases: PdfAttachment

**Module**

`PSWriteOffice`

**Aliases**

`PdfAttachment`

**Inputs**

`OfficeIMO.Pdf.PdfDocument`

**Outputs**

`OfficeIMO.Pdf.PdfDocument`

**Source**

[AddOfficePdfAttachmentCommand.cs:23](https://github.com/EvotecIT/PSWriteOffice/blob/main/Sources/PSWriteOffice/Cmdlets/Pdf/AddOfficePdfAttachmentCommand.cs#L23) 

Adds an embedded file attachment to a generated PDF document.

## Syntax

```
Add-OfficePdfAttachment
[-Description <String>]
[-MimeType <String>]
[-Name <String>]
[-PassThru]
[-Path] <String>
[-Relationship <PdfAssociatedFileRelationship>]
[<CommonParameters>]
```

[#](#method-add-officepdfattachment-string-string-string-switchparameter-string-pdfassociatedfilerelationship)

Parameter set: `Context`

```
Add-OfficePdfAttachment
[-Description <String>]
-Document <PdfDocument>
[-MimeType <String>]
[-Name <String>]
[-PassThru]
[-Path] <String>
[-Relationship <PdfAssociatedFileRelationship>]
[<CommonParameters>]
```

[#](#method-add-officepdfattachment-string-pdfdocument-string-string-switchparameter-string-pdfassociatedfilerelationship)

Parameter set: `Document`

## Examples

### Embed source data in a generated PDF.

```powershell
$dataPath = '.\Examples\Documents\ServiceData.json'
Set-Content -Path $dataPath -Value '{ "service": "Directory", "status": "Healthy" }'
New-OfficePdf -Path .\Examples\Documents\PdfWithAttachment.pdf {
    Add-OfficePdfHeading -Text 'Service report'
    Add-OfficePdfAttachment -Path $dataPath -Name 'service-data.json' -MimeType 'application/json' -Description 'Source data used by the report.'
}
```

Embeds a supporting JSON file in the generated PDF.

## Parameters

**-Description String optional**

Optional human-readable attachment description.

**-MimeType String optional**

Optional MIME type for the embedded file.

**-Name String optional**

Optional embedded file name. The source file name is used when omitted.

**-PassThru SwitchParameter optional**

Accepted for compatibility. The replacement document is always emitted when -Document is used.

**-Path String requiredposition: 0aliases: FilePath**

File path to embed in the generated PDF.

**-Relationship PdfAssociatedFileRelationship optional**

Associated-file relationship between the PDF and the embedded file.

Possible values: `Unspecified`, `Source`, `Data`, `Alternative`, `Supplement`, `C2paManifest`

**-Document PdfDocument requiredpipeline: True (ByValue)sets: Document**

PDF document to update outside the DSL context.

## Common Parameters

This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.

For more information, see [about_CommonParameters](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_commonparameters).

Evotec API Reference Copyright 2026 Evotec Services

<!-- PowerForge markdown artifact sha256:1956F7C956E7DCDE762583FD74BE15D78ADC8C4589876694D36C3BBA34A62C86 -->
