Project

PSWriteOffice

PowerShell document automation across Word, Excel, PowerPoint, PDF, Reader, Confluence, Visio, and open text formats.

Stars 159
Forks 14
PowerShell Gallery downloads 158,661
Release v3.0.5
Language: C# Updated: 2026-09-03

API Reference

Cmdlet

Add-OfficePdfAttachment

Aliases: PdfAttachment
Namespace PSWriteOffice
Aliases
PdfAttachment
Inputs
OfficeIMO.Pdf.PdfDocument
Outputs
OfficeIMO.Pdf.PdfDocument

Adds an embedded file attachment to a generated PDF document.

Remarks

Adds an embedded file attachment to a generated PDF document.

Examples

Authored help example

Embed source data in a generated PDF.

PS>


$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.

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.

Syntax

Add-OfficePdfAttachment [-Description <String>] [-MimeType <String>] [-Name <String>] [-PassThru] -Path <String> [-Relationship <Unspecified>] [<CommonParameters>]
#
Parameter set: Context

Parameters

Description String optionalposition: namedpipeline: False
Optional human-readable attachment description.
MimeType String optionalposition: namedpipeline: False
Optional MIME type for the embedded file.
Name String optionalposition: namedpipeline: False
Optional embedded file name. The source file name is used when omitted.
PassThru SwitchParameter optionalposition: namedpipeline: False
Accepted for compatibility. The replacement document is always emitted when -Document is used.
Path String requiredposition: 0pipeline: Falsealiases: FilePath
File path to embed in the generated PDF.
Relationship PdfAssociatedFileRelationship optionalposition: namedpipeline: Falsevalues: 6
Associated-file relationship between the PDF and the embedded file.
Possible values: Unspecified, Source, Data, Alternative, Supplement, C2paManifest

Outputs

OfficeIMO.Pdf.PdfDocument

Add-OfficePdfAttachment [-Description <String>] -Document <PdfDocument> [-MimeType <String>] [-Name <String>] [-PassThru] -Path <String> [-Relationship <Unspecified>] [<CommonParameters>]
#
Parameter set: Document

Parameters

Description String optionalposition: namedpipeline: False
Optional human-readable attachment description.
Document PdfDocument requiredposition: namedpipeline: True (ByValue)
PDF document to update outside the DSL context.
MimeType String optionalposition: namedpipeline: False
Optional MIME type for the embedded file.
Name String optionalposition: namedpipeline: False
Optional embedded file name. The source file name is used when omitted.
PassThru SwitchParameter optionalposition: namedpipeline: False
Accepted for compatibility. The replacement document is always emitted when -Document is used.
Path String requiredposition: 0pipeline: Falsealiases: FilePath
File path to embed in the generated PDF.
Relationship PdfAssociatedFileRelationship optionalposition: namedpipeline: Falsevalues: 6
Associated-file relationship between the PDF and the embedded file.
Possible values: Unspecified, Source, Data, Alternative, Supplement, C2paManifest

Outputs

OfficeIMO.Pdf.PdfDocument