Public/New-PCWordTheme.ps1
|
function New-PCWordTheme { <# .SYNOPSIS Writes the neutral default theme document. .DESCRIPTION Creates a .docx that defines every style the renderer can map onto, with plain formatting and A4 pages. Open it in Word, restyle it to your identity, and pass it as -Theme. The style names are the contract; the formatting is yours. .PARAMETER Path Where to write the theme .docx. .PARAMETER Force Overwrite an existing file. #> [CmdletBinding(SupportsShouldProcess)] [OutputType([System.IO.FileInfo])] param( [Parameter(Mandatory, Position = 0)] [string]$Path, [switch]$Force ) if ((Test-Path -LiteralPath $Path) -and -not $Force) { throw "Theme already exists: $Path. Use -Force to overwrite." } if (-not $PSCmdlet.ShouldProcess($Path, 'Write default theme')) { return } $full = [IO.Path]::GetFullPath((Join-Path (Get-Location) $Path | ForEach-Object { if ([IO.Path]::IsPathRooted($Path)) { $Path } else { $_ } })) [PowerCraft.Word.Core.Theme.DefaultTheme]::Create($full) Get-Item -LiteralPath $full } |