Last active
October 27, 2015 07:20
-
-
Save poizan42/1344818f42acce1724fc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-CroppedText | |
{ | |
$pdftotext="C:\Program Files\xpdf\pdftotext.exe" | |
$bbox=$args[0] | |
$inFile=$args[1] | |
pdfcrop --bbox $bbox $inFile tmp2.pdf | Out-Null | |
& $pdftotext -nopgbrk tmp2.pdf - | Select-Object -First 1 | foreach { $_.Trim() } | |
rm tmp2.pdf | |
} | |
function Get-PageNum | |
{ | |
pdftk $args[0] cat 1-1 output tmp.pdf | Out-Null | |
$pagenum=Get-CroppedText "250 36 260 43" tmp.pdf | |
$iPagenum=0 | |
if ($pagenum -eq $nil -or ![System.Int32]::TryParse($pagenum, [ref]$iPagenum)) | |
{ | |
$pagenum=Get-CroppedText "250 16.5 260 21" tmp.pdf | |
} | |
if ($pagenum -eq $nil -or ![System.Int32]::TryParse($pagenum, [ref]$iPagenum)) | |
{ | |
$pagenum=Get-CroppedText "250 23.5 260 28" tmp.pdf | |
} | |
rm tmp.pdf | |
return $pagenum | |
} | |
$files=ls *.pdf | foreach { $pagenum=Get-PageNum $_.Name; @{pagenum=$pagenum; file=$_.Name} } | |
$files=($files | sort-object -property { [System.Int32]::Parse($_["pagenum"]) }) | |
$f=cat list.txt; pdftk $f cat output VOLII.pdf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment