ref: 6237cc2a6834ccba99270c96dc66e4bffd3173a7
parent: b574ea6ce2f6fb2aa129da26687d4affeb1faabc
author: Noam Preil <noam@pixelhero.dev>
date: Mon Jul 19 20:33:34 EDT 2021
add pdf2txt rc script
--- /dev/null
+++ b/pdf2txt
@@ -1,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