Created
November 29, 2013 17:48
-
-
Save peaeater/7709456 to your computer and use it in GitHub Desktop.
Converts PDF to 300 dpi DJVU. Requires pdf2djvu => https://code.google.com/p/pdf2djvu/
This file contains 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
# convert pdf to djvu | |
# accepts a .pdf input, outputs a 300dpi .djvu, returns djvu full name | |
# requires pdf2djvu | |
param( | |
[Parameter(Mandatory=$true,ValueFromPipeline=$true,Position=0)] | |
[ValidateScript({[System.IO.Path]::GetExtension($_) -eq ".pdf"})] | |
[string]$in, | |
[Parameter(Mandatory=$false,ValueFromPipeline=$true,Position=1)] | |
[ValidateScript({[System.IO.Path]::GetExtension($_) -eq ".djvu"})] | |
[string]$out | |
) | |
process | |
{ | |
$file = new-object System.IO.FileInfo($in) | |
$input = ('"{0}"' -f $file.FullName) | |
$output = $out | |
if (!$output) { | |
$output = ('{0}\{1}.djvu' -f $file.DirectoryName, $file.BaseName) | |
} | |
$args = "-o `"$output`" -d 300 --words --no-metadata --no-hyperlinks --no-outline --pageid-template={page}.djvu --crop-text $input" | |
write-host $args | |
start-process pdf2djvu $args -wait -NoNewWindow | |
return $output | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment