Browse Source

improve layout

automate
mxmehl 7 months ago
parent
commit
0b6063cfc2
Signed by: mxmehl GPG Key ID: 2704E4AB371E2E92
  1. 18
      scripts/create-index.py

18
scripts/create-index.py

@ -12,10 +12,6 @@ parser.add_argument("-t", "--type", dest="type",
help="Define whether to build A-Z or A-Y")
args = parser.parse_args()
def wline(text):
"""Write a line of text with line break afterwards"""
pdf.cell(txt=text, ln=1)
pdf = FPDF(format = "A5")
pdf.add_page()
pdf.set_margin(10)
@ -23,11 +19,9 @@ pdf.set_margin(10)
# Print Title
pdf.set_font('courier', size=16, style="BU")
pdf.cell(0, 6, 'Songbook-Index', ln=1, align='C')
pdf.ln(4)
# Print index of Songs
pdf.set_font('courier', size=8)
if args.type == "az":
SELECTION = "[A-Z]"
else:
@ -45,12 +39,12 @@ for file_name in sorted(glob.iglob(f'build/Songs/{SELECTION}*.pdf')):
# Treat new category starts differently
if song_no == 0:
pdf.ln(1)
wline(f"{song_cat}. {song_name}")
pdf.set_font('courier', size=8, style="B")
pdf.cell(txt=f"{song_cat}. {song_name}", ln=1)
else:
wline(f" {song_no}. {song_name}")
pdf.set_font('courier', size=8)
pdf.cell(txt=f" {song_no}. {song_name}", ln=1)
pdf.ln(1)
wline("Akkorde")
pdf.cell(txt="**Akkorde**", ln=1, markdown=True)
pdf.output("build/Extra/Index.pdf")

Loading…
Cancel
Save