-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
New-InternalPDFPage.ps1
45 lines (42 loc) · 1.25 KB
/
New-InternalPDFPage.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
function New-InternalPDFPage {
[CmdletBinding()]
param(
[string] $PageSize,
[switch] $Rotate,
[nullable[float]] $MarginLeft,
[nullable[float]] $MarginRight,
[nullable[float]] $MarginTop,
[nullable[float]] $MarginBottom
)
if ($PageSize -or $Rotate) {
if ($PageSize) {
$Page = [iText.Kernel.Geom.PageSize]::($PageSize)
} else {
$Page = [iText.Kernel.Geom.PageSize]::Default
}
if ($Rotate) {
$Page = $Page.Rotate()
}
}
if ($Page) {
$null = $Script:PDF.AddNewPage($Page)
} else {
$null = $Script:PDF.AddNewPage()
}
$Script:Document = [iText.Layout.Document]::new($Script:PDF)
if ($Script:Document) {
if ($MarginLeft) {
$Script:Document.SetLeftMargin($MarginLeft)
}
if ($MarginRight) {
$Script:Document.SetRightMargin($MarginRight)
}
if ($MarginTop) {
$Script:Document.SetTopMargin($MarginTop)
}
if ($MarginBottom) {
$Script:Document.SetBottomMargin($MarginBottom)
}
}
}
Register-ArgumentCompleter -CommandName New-InternalPDFPage -ParameterName PageSize -ScriptBlock $Script:PDFPageSize