forked from jdhitsolutions/PSScriptTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makepdf.ps1
39 lines (31 loc) · 1.02 KB
/
makepdf.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
[cmdletbinding(SupportsShouldProcess)]
Param(
[Parameter(HelpMessage = "The path to a json file with the processing data for the folder.")]
[ValidateNotNullOrEmpty()]
[ValidateScript({Test-Path $_})]
[string]$DataPath = ".\adoc-data.json"
)
Write-Verbose "[$(Get-Date)] Importing ruby-related functions"
. C:\scripts\rubydocs.ps1
Write-Verbose "[$(Get-Date)] Importing adoc data from json"
$data = Get-Content $DataPath | ConvertFrom-Json
$adoc = Join-Path -path . -ChildPath "$($data.name).adoc"
Write-Verbose "[$(Get-Date)] Converting $adoc to pdf"
$params = @{
Fullname = $adoc
Passthru = $True
Backend = "pdf"
DocType = "book"
FontDirectory = "c:\gemfonts"
DocumentTheme = $data.theme
Trace = $True
}
if (Test-Path $data.CodeThemePath) {
$params.Add("CodeThemePath")
}
$pdf = Export-ADoc @params
if (Test-Path $pdf) {
Write-Verbose "[$(Get-Date)] Optimizing $pdf"
Optimize-PDF -Fullname $pdf
}
Write-Verbose "[$(Get-Date)] Process complete."