shithub: pdffs

ref: 886a60cfed3741be9dc78b6eb4afdaedb88d6ed3
dir: /pdf2txt/

View raw version
#!/bin/rc
file=$1
if(~ $#file 0){
	echo Usage: pdf2txt file
	exit
}

if(! test -f $file){
	echo $file does not exist
	exit
}

current=0
fn dumppages{ 
	count=`{pdffs $file $* Count}
	i=0
	while(! ~ $i $count){
		current=`{echo $current '+ 1' | bc}
		type=`{pdffs $file $* Kids $i Type}
		if(~ $type /Page)
			pdffs $file $* Kids $i "
		if not if(~ $type /Pages)
			dumppages $* Kids $i
		if not{
			echo Invalid type $type
			exit
		}
		i=`{echo $i '+ 1' | bc}
	}
}
dumppages Root Pages