Skip to content

Commit

Permalink
Adds Orientation GlobalOption
Browse files Browse the repository at this point in the history
Fixes #5
  • Loading branch information
iainbrighton committed May 25, 2016
1 parent 65af821 commit db29320
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Functions/GlobalOption.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions Functions/GlobalOption.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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')
)
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions Resources.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -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}'.
Expand Down

0 comments on commit db29320

Please sign in to comment.