You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A much better option is to combine the python file into the shell script so we can put that one file in PATH,
#!/bin/bash# Change to the directory of pdf filecd$(dirname "$1")
pdf=$(basename "$1")
pdf_data="${pdf%.*}""_data.txt"
EXTRACT_FILE=booky_bookmarks_extract
bkFile="$2"if [[ "$OSTYPE"=="darwin"* ]];then
SED=gsed
else
SED=sed
fiecho"Converting $bkFile to pdftk compatible format"
python3 -c 'import syslevel = 0startChar = "{"endChar = "}"for line in sys.stdin: line = line.strip() if line == startChar: level = level + 1 elif line == endChar: level = level - 1 elif line: commaIndex = line.rfind(",") title = line[:commaIndex] pageNo = line[commaIndex + 1:].strip() print("BookmarkBegin") print("BookmarkTitle:", title.strip()) print("BookmarkLevel:", level) print("BookmarkPageNumber:", pageNo.strip())'<"$bkFile">"$EXTRACT_FILE"echo"Dumping pdf meta data..."
pdftk "$pdf" dump_data_utf8 output "$pdf_data"echo"Clear dumped data of any previous bookmarks"$SED -i '/Bookmark/d'"$pdf_data"echo"Inserting your bookmarks in the data"$SED -i "/NumberOfPages/r $EXTRACT_FILE""$pdf_data"echo"Creating new pdf with your bookmarks..."
pdftk "$pdf" update_info_utf8 "$pdf_data" output "${pdf%.*}""_new.pdf"echo"Deleting leftovers"
rm "$EXTRACT_FILE""$pdf_data"
The text was updated successfully, but these errors were encountered:
A much better option is to combine the python file into the shell script so we can put that one file in PATH,
The text was updated successfully, but these errors were encountered: