Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Produce a canvas structure XML (which djvulibre calls 'hidden text') file per page from a DJVU file. Output name includes total page count of input file, and page number of current page. Requires djvutoxml =>
# extract hidden text xml per page from djvu
# requires djvulibre
$basePath = split-path $script:myinvocation.mycommand.path
$file = new-object System.IO.FileInfo([System.IO.Path]::Combine($basePath, $in))
$input = ('"{0}"' -f $file.FullName)
write-host $input
$pagecount = & djvused -e 'n' $input
for ($i = 1; $i -le $pagecount; $i++) {
$output = ('"{0}\{1}_t{2}_{3}.xml"' -f $file.DirectoryName, $file.BaseName, $pagecount, $i)
$args = "--with-text --page $i $input $output"
write-host $args
start-process djvutoxml $args -NoNewWindow -wait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment