From db29320072a70188e8601d3829687844b460a7e5 Mon Sep 17 00:00:00 2001 From: Iain Brighton Date: Wed, 25 May 2016 21:22:25 +0100 Subject: [PATCH] Adds Orientation GlobalOption Fixes #5 --- Functions/GlobalOption.Tests.ps1 | 6 ++++++ Functions/GlobalOption.ps1 | 10 ++++++++++ Resources.psd1 | 1 + 3 files changed, 17 insertions(+) diff --git a/Functions/GlobalOption.Tests.ps1 b/Functions/GlobalOption.Tests.ps1 index b4e065d..0784bfc 100644 --- a/Functions/GlobalOption.Tests.ps1 +++ b/Functions/GlobalOption.Tests.ps1 @@ -65,6 +65,12 @@ InModuleScope 'PScribo' { $pscriboDocument.Options['PageWidth'] | Should Be 215.9; $pscriboDocument.Options['PageHeight'] | Should Be 355.6; } + + It 'sets page orientation to US Legal Landscape' { + GlobalOption -PageSize Legal -Orientation Landscape; + $pscriboDocument.Options['PageHeight'] | Should Be 215.9; + $pscriboDocument.Options['PageWidth'] | Should Be 355.6; + } It 'sets page margin to 1/2 inch using 36pt.' { GlobalOption -Margin 36; diff --git a/Functions/GlobalOption.ps1 b/Functions/GlobalOption.ps1 index 7c80cd1..c512335 100644 --- a/Functions/GlobalOption.ps1 +++ b/Functions/GlobalOption.ps1 @@ -24,6 +24,8 @@ function GlobalOption { [Parameter(Mandatory, ValueFromPipelineByPropertyName, ParameterSetName = 'CustomMargin')] [System.UInt16] $MarginLeftAndRight, ## Default page size [Parameter(ValueFromPipelineByPropertyName)] [ValidateSet('A4','Legal','Letter')] [System.String] $PageSize = 'A4', + ## Page orientation + [Parameter(ValueFromPipelineByPropertyName)] [ValidateSet('Potrait','Landscape')] [System.String] $Orientation = 'Potrait', ## Default document font(s) [Parameter(ValueFromPipelineByPropertyName)] [System.String[]] $DefaultFont = @('Calibri','Candara','Segoe','Segoe UI','Optima','Arial','Sans-Serif') ) @@ -86,6 +88,14 @@ function GlobalOption { $pscriboDocument.Options['PageHeight'] = 279.4; } } #end switch + ## Convert page size + ($localized.DocumentOptionPageSize -f $Orientation) | WriteLog; + if ($Orientation -eq 'Landscape') { + ## Swap the height/width measurements + $pageHeight = $pscriboDocument.Options['PageHeight']; + $pscriboDocument.Options['PageHeight'] = $pscriboDocument.Options['PageWidth']; + $pscriboDocument.Options['PageWidth'] = $pageHeight; + } ($localized.DocumentOptionPageHeight -f $pscriboDocument.Options['PageHeight']) | WriteLog; ($localized.DocumentOptionPageWidth -f $pscriboDocument.Options['PageWidth']) | WriteLog; } #end process diff --git a/Resources.psd1 b/Resources.psd1 index e57c382..93b4700 100644 --- a/Resources.psd1 +++ b/Resources.psd1 @@ -31,6 +31,7 @@ DocumentOptionPageRightMargin = Setting page right margin to '{0}'mm. DocumentOptionPageBottomMargin = Setting page bottom margin to '{0}'mm. DocumentOptionPageLeftMargin = Setting page left margin to '{0}'mm. DocumentOptionPageSize = Setting page size to '{0}'. +DocumentOptionPageOrientation = Setting page orientation to '{1}'. DocumentOptionPageHeight = Setting page height to '{0}'mm. DocumentOptionPageWidth = Setting page width to '{0}'mm. DocumentOptionDefaultFont = Setting default font(s) to '{0}'.