pdf-auto-outline 0.1.4__tar.gz → 0.1.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pdf-auto-outline
3
- Version: 0.1.4
3
+ Version: 0.1.5
4
4
  Summary: Automatically generate and edit PDF table of contents / outline
5
5
  Author: Rossikos
6
6
  Author-email: Rossikos <216631970+rossikos@users.noreply.github.com>
@@ -62,6 +62,29 @@ Edit exiting pdf toc:
62
62
  A save toc to new pdf from file:
63
63
  `pdfao paper.pdf -o new.pdf -i outline.txt`
64
64
 
65
+ ### Editing
66
+
67
+ The edit command opens the TOC in the OS default editor (result of 'start' command on Windows and 'EDITOR' environment variable on MacOS and Linux). The file schema is something like this:
68
+
69
+ ```
70
+ Title 1 | 1
71
+ Title 2 | 2 | *
72
+ ^^^^^^
73
+ optional
74
+ ```
75
+ The essential parts of each line are:
76
+ - Indentation - 4 space characters per nesting level (or use tabs with the -t flag).
77
+ - Title text
78
+ - Delimiter - ' | ' (vertical bar with 2 spaces padding on each side)
79
+ - Page number
80
+
81
+ The optional part can be one of:
82
+ ```
83
+ | None same as not including it
84
+ | 241.2 y-ordinate
85
+ | Point(72.0, 363.9) x and y coords
86
+ | {<dictionary>} dictionary with more attributes for the ToC entry
87
+ ```
65
88
 
66
89
  ## For Sioyek Users
67
90
 
@@ -69,7 +92,7 @@ Example commands; add to `prefs_user.config`.
69
92
 
70
93
  ```
71
94
  new_command _gen_toc pdfao "%{file_path}" --sioyek path/to/sioyek -mp 4
72
- new_command _edit_toc pdfao %{file_path}" --sioyek path/to/sioyek -e
95
+ new_command _edit_toc pdfao "%{file_path}" --sioyek path/to/sioyek -e
73
96
  ```
74
97
 
75
98
  If you don't wish to install from PyPI, download source and use `python3 -m path/to/src/pdf_auto_outline` in place of `pdfao`.
@@ -45,6 +45,29 @@ Edit exiting pdf toc:
45
45
  A save toc to new pdf from file:
46
46
  `pdfao paper.pdf -o new.pdf -i outline.txt`
47
47
 
48
+ ### Editing
49
+
50
+ The edit command opens the TOC in the OS default editor (result of 'start' command on Windows and 'EDITOR' environment variable on MacOS and Linux). The file schema is something like this:
51
+
52
+ ```
53
+ Title 1 | 1
54
+ Title 2 | 2 | *
55
+ ^^^^^^
56
+ optional
57
+ ```
58
+ The essential parts of each line are:
59
+ - Indentation - 4 space characters per nesting level (or use tabs with the -t flag).
60
+ - Title text
61
+ - Delimiter - ' | ' (vertical bar with 2 spaces padding on each side)
62
+ - Page number
63
+
64
+ The optional part can be one of:
65
+ ```
66
+ | None same as not including it
67
+ | 241.2 y-ordinate
68
+ | Point(72.0, 363.9) x and y coords
69
+ | {<dictionary>} dictionary with more attributes for the ToC entry
70
+ ```
48
71
 
49
72
  ## For Sioyek Users
50
73
 
@@ -52,7 +75,7 @@ Example commands; add to `prefs_user.config`.
52
75
 
53
76
  ```
54
77
  new_command _gen_toc pdfao "%{file_path}" --sioyek path/to/sioyek -mp 4
55
- new_command _edit_toc pdfao %{file_path}" --sioyek path/to/sioyek -e
78
+ new_command _edit_toc pdfao "%{file_path}" --sioyek path/to/sioyek -e
56
79
  ```
57
80
 
58
81
  If you don't wish to install from PyPI, download source and use `python3 -m path/to/src/pdf_auto_outline` in place of `pdfao`.
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "pdf-auto-outline"
3
- version = "0.1.4"
3
+ version = "0.1.5"
4
4
  description = "Automatically generate and edit PDF table of contents / outline"
5
5
  readme = "README.md"
6
6
  authors = [
@@ -0,0 +1 @@
1
+ __version__ = '0.1.5'
@@ -159,7 +159,9 @@ def generate_txtfile(toc_entries, txtfile='outline.txt') -> str:
159
159
  ============================================================
160
160
 
161
161
  """)
162
- if len(toc_entries[0]) > 3:
162
+ if not toc_entries:
163
+ pass
164
+ elif len(toc_entries[0]) > 3:
163
165
  txt += '\n'.join(f"{' '*4 * (i[0] - 1)}{i[1]} | {i[2]} | {i[3]}"
164
166
  for i in toc_entries)
165
167
  else:
@@ -208,7 +210,7 @@ def embed_toc(pdfpath, toc_entries, newfile=''):
208
210
  log(f"toc saved to '{pdfpath}'")
209
211
 
210
212
  def get_toc_custom(doc) -> list:
211
- toc_entries = [[*i[:3], i[3].get('to')] for i in doc.get_toc(False)]
213
+ toc_entries = [[*i[:3], i[3].get('to')[1]] for i in doc.get_toc(False)]
212
214
  return toc_entries
213
215
 
214
216
  def edit_txtfile(txtfile='outline.txt'):
@@ -232,7 +234,7 @@ def main():
232
234
  parser.add_argument('-i', '--infile', type=str, metavar='<file>', help='write toc from file to pdf')
233
235
  parser.add_argument('-t', '--tablevel', type=int, metavar='<n>', help='tab = n toc nesting levels (default 2)', default=2)
234
236
  parser.add_argument('--sioyek', type=str, metavar='<path>', help='for users of the Sioyek pdf viewer')
235
- parser.add_argument('--version', action='version', version='%(prog)s 0.1.4')
237
+ parser.add_argument('--version', action='version', version='%(prog)s 0.1.5')
236
238
 
237
239
  args = parser.parse_args()
238
240
 
@@ -1 +0,0 @@
1
- __version__ = '0.1.4'