diff --git a/Example PDF.pdf b/Example PDF.pdf index def86ec..5e34700 100644 Binary files a/Example PDF.pdf and b/Example PDF.pdf differ diff --git a/README.md b/README.md index 7b825ef..4a061a8 100644 --- a/README.md +++ b/README.md @@ -3,13 +3,12 @@ Merges a directory structure of images into a PDF with nested bookmarks. ``` $ bookdir2pdf.py --help - usage: bookdir2pdf.py [-h] -i INPUT_DIR [-o OUTPUT_FILE] - [-s ORDER_NUMBER_SEPERATOR] [-c] + [-s ORDER_NUMBER_SEPARATOR] [-c] [-p [PURIFY [PURIFY ...]]] [-d DPI] [-t TITLE] [-a AUTHOR] -Merge nested image direcotry into PDF with nested bookmarks. +Merge nested image directory into PDF with nested bookmarks. optional arguments: -h, --help show this help message and exit @@ -17,14 +16,14 @@ optional arguments: path to nested image directory to merge -o OUTPUT_FILE, --output_file OUTPUT_FILE output file path ( defaults to [input_dir].pdf ) - -s ORDER_NUMBER_SEPERATOR, --order_number_seperator ORDER_NUMBER_SEPERATOR - the character used to seperate the direcotry ordering + -s ORDER_NUMBER_SEPARATOR, --order_number_separator ORDER_NUMBER_SEPARATOR + the character used to separate the directory ordering numbers from the bookmark names ( like '.' or ')' ) -c, --table_of_contents just scan directory and print table of contents -p [PURIFY [PURIFY ...]], --purify [PURIFY [PURIFY ...]] purify scanned B&W page ( greyscale, sharpen, - threshold ), named sub-argumets: (sharpen|s) + threshold ), named sub-arguments: (sharpen|s) (threshold|t) -d DPI, --dpi DPI dots-per-inch of the input images -t TITLE, --title TITLE @@ -36,7 +35,7 @@ optional arguments: The PDF here was made using: -`bookdir2pdf.py --input_dir test_dir/ --order_number_seperator . --purify sharpen=1 --title "Example PDF" --dpi 72` +`bookdir2pdf.py --input_dir test_dir/ --order_number_separator . --purify sharpen=1 --title "Example PDF" --dpi 72` The `.` is what seperates the ordering numbers from the bookmark name in the directory name. For example, the directory name `01. The First Part` has a `.` between the ordering number `01` and the bookmark name `The First Part`. @@ -49,22 +48,24 @@ $ bookdir2pdf.py --input_dir test_dir/ --table_of_contents ... [output removed] ... -Example PDF - Table of Contents -------------------------------- -Page #1 Cover Page -Page #2 --- Empty Directory Example -Page #2 --- --- Nested Empty Directory Level 1 -Page #2 --- --- --- Nested Empty Directory Level 2 -Page #2 --- --- --- --- Nested Empty Directory Level 3 -Page #2 Empty Directory .name File Example (allows for forbidden characters like <>?\/*: and also means you can make a really long name like this without hitting the path le -ngth limit of your OS) -Page #2 The First Part -Page #2 --- Chapter 1 -Page #4 --- Chapter 2 -Page #6 The Middle Part -Page #6 --- Chapter 3 -Page #8 --- Chapter 4 -Page #10 The Final Part -Page #10 --- Chapter 5 -Page #12 --- Chapter 6 +test_dir - Table of Contents +---------------------------- +Page #1 00. Cover Page +Page #2 --- 01. Empty Directory Example +Page #2 --- --- 01. Nested Empty Directory Level 1 +Page #2 --- --- --- 01. Nested Empty Directory Level 2 +Page #2 --- --- --- --- 01. Nested Empty Directory Level 3 +Page #2 Empty Directory .name File Example (allows for forbidden characters like <>?\/*: and also means you can make a really long name like this without hitting the path length limit of your OS) +Page #2 02. The First Part +Page #2 --- 01. Chapter 1 +Page #4 --- 02. Chapter 2 +Page #6 03. The Middle Part +Page #6 --- 01. Chapter 3 +Page #8 --- 02. Chapter 4 +Page #10 04. The Final Part +Page #10 --- 01. Chapter 5 +Page #12 --- 02. Chapter 6 + Page count: 13 + +... [output removed] ... ``` \ No newline at end of file diff --git a/bookdir2pdf.py b/bookdir2pdf.py index 050b8cb..66646c5 100644 --- a/bookdir2pdf.py +++ b/bookdir2pdf.py @@ -196,7 +196,8 @@ def get_valid_filename(s): else: print("PDF author: {}".format(pdf_author)) -print("PDF resolution: {} DPI".format(pdf_dpi)) +if not args["table_of_contents"]: + print("PDF resolution: {} DPI".format(pdf_dpi)) print("Input directory: {}".format(input_dir)) @@ -401,6 +402,8 @@ def get_valid_filename(s): # Update page_list with new images/paths page_list = new_page_list + + print("\tDone purifying images!") # Make page_list but with only files page_list_files = [p for p in page_list if os.path.isfile(p)] @@ -419,7 +422,6 @@ def get_valid_filename(s): current_level[part] = OrderedDict() current_level = current_level[part] -print("\tDone purifying images!") # Create PDF from page_list(no bookmarks) @@ -447,9 +449,10 @@ def get_valid_filename(s): print() -print("-------- BOOKMARK CREATION --------") -print("Table of Contents will be printed as bookmarks are created.") -print() +if not args["table_of_contents"]: + print("-------- BOOKMARK CREATION --------") + print("Table of Contents will be printed as bookmarks are created.") + print() # Get ToC title toc_title = pdf_title