zine_maker/doc_pdf.py
2021-12-10 01:24:22 +02:00

60 lines
1.4 KiB
Python

import sys
import random
from zine_maker import Zine
def make():
# Variables
header_font = 'helvetica'
header_font_size = 14
text_font_size = 11
top_margin = 20
left_margin = 20
right_margin = 20
left_max_margin = 160
max_height = 190
left_x = 20
top_y = 30
cell_width = 110
cell_header_height = 16
cell_height = 6
# set font for all text
zine = Zine(orientation="P", unit="mm", format="A5")
# cover font
zine.add_font(
'CasaleNBP', '', r"fonts/CasaletwoAlternatesNbp-RgRM.ttf", uni=True
)
cover_font = 'CasaleNBP'
# text font
zine.add_font(
'Kpalter', '',
r"fonts/KpProgrammerAlternatesNbp-Zg1q.ttf", uni=True
)
text_font = 'Kpalter'
zine.set_font(text_font, '', size=text_font_size)
zine.create_pages(inputfile, max_height, left_margin,
left_max_margin, top_margin, right_margin,
cell_width, cell_height, cell_header_height,
header_font, text_font, text_font_size)
zine.output(output)
if __name__ == '__main__':
# input text and output pdf
if len(sys.argv) > 1:
if len(sys.argv) == 3:
output = sys.argv[2]
inputfile = sys.argv[1]
else:
inputfile = "./text/oulipo1.txt"
output = "./body/body{}.pdf".format(random.randint(1, 40))
make()