Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Add-OfficePdfAttachment

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

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>]
#
Parameter set: Context
Add-OfficePdfAttachment [-Description <String>] -Document <PdfDocument> [-MimeType <String>] [-Name <String>] [-PassThru] [-Path] <String> [-Relationship <PdfAssociatedFileRelationship>] [<CommonParameters>]
#
Parameter set: Document

Examples

Authored help example

Embed source data in a generated PDF.

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