-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path01-split.ps1
More file actions
38 lines (31 loc) · 1.48 KB
/
Copy path01-split.ps1
File metadata and controls
38 lines (31 loc) · 1.48 KB
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
# split/01-split.ps1 — split one PDF into several (pdfnative 1.5.0 page-tree)
#
# Renders a four-page document, then splits it two ways: one PDF per page
# (default) and one PDF per --pages range.
#
# Usage:
# pwsh -File samples\split\01-split.ps1
$ErrorActionPreference = 'Stop'
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$RootDir = Split-Path -Parent (Split-Path -Parent $ScriptDir)
$OutputDir = Join-Path $RootDir 'samples\output\split'
New-Item -ItemType Directory -Force -Path (Join-Path $OutputDir 'per-page') | Out-Null
New-Item -ItemType Directory -Force -Path (Join-Path $OutputDir 'per-range') | Out-Null
Write-Host '→ [1/3] Rendering a four-page source…'
& pdfnative render `
--input (Join-Path $RootDir 'samples\split\multipage.json') `
--output (Join-Path $OutputDir 'source.pdf')
Write-Host '→ [2/3] Splitting one PDF per page (default)…'
& pdfnative split `
--input (Join-Path $OutputDir 'source.pdf') `
--output-dir (Join-Path $OutputDir 'per-page') `
--prefix page
Write-Host '→ [3/3] Splitting into two ranges via --pages 1-2,3-4…'
& pdfnative split `
--input (Join-Path $OutputDir 'source.pdf') `
--output-dir (Join-Path $OutputDir 'per-range') `
--pages '1-2,3-4' `
--prefix section
Write-Host " ✓ Per-page: $OutputDir\per-page\"
Write-Host " ✓ Per-range: $OutputDir\per-range\"
Get-ChildItem (Join-Path $OutputDir 'per-page'), (Join-Path $OutputDir 'per-range') -Name