Skip to content

Instantly share code, notes, and snippets.

@peaeater
Created November 29, 2013 17:48
Show Gist options
  • Save peaeater/7709456 to your computer and use it in GitHub Desktop.
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/
# 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