~ft/pdffs

6237cc2a6834ccba99270c96dc66e4bffd3173a7 — Noam Preil 2 months ago b574ea6
add pdf2txt rc script
1 files changed, 31 insertions(+), 0 deletions(-)

A pdf2txt
A pdf2txt => pdf2txt +31 -0
@@ 0,0 1,31 @@
#!/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