cover fix
This commit is contained in:
parent
e0ed5e50c5
commit
cf62814378
4 changed files with 158 additions and 502 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -3,4 +3,4 @@ media/
|
|||
pdf/
|
||||
|
||||
*.json
|
||||
*.pdf
|
||||
|
||||
|
|
BIN
copertina.pdf
Normal file
BIN
copertina.pdf
Normal file
Binary file not shown.
344
copertina.svg
344
copertina.svg
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 42 KiB |
|
@ -21,28 +21,26 @@ def copertina(text):
|
|||
from PyPDF2 import PdfFileWriter, PdfFileReader
|
||||
import io
|
||||
from reportlab.pdfgen import canvas
|
||||
from reportlab.lib.pagesizes import A4
|
||||
from reportlab.lib.pagesizes import A5
|
||||
from reportlab.pdfbase import pdfmetrics
|
||||
from reportlab.pdfbase.ttfonts import TTFont
|
||||
from reportlab.pdfbase.pdfmetrics import stringWidth
|
||||
from reportlab.rl_config import defaultPageSize
|
||||
|
||||
FONT = 'Roboto'
|
||||
SIZE = 48
|
||||
SIZE = 36
|
||||
|
||||
packet = io.BytesIO()
|
||||
# create a new PDF with Reportlab
|
||||
|
||||
pdfmetrics.registerFont(TTFont("Roboto", "template/roboto-regular-webfont.ttf"))
|
||||
|
||||
can = canvas.Canvas(packet, pagesize=A4)
|
||||
can = canvas.Canvas(packet, pagesize=A5)
|
||||
can.setFont(FONT, SIZE)
|
||||
|
||||
PAGE_WIDTH = defaultPageSize[0]
|
||||
#PAGE_HEIGHT = defaultPageSize[1]
|
||||
PAGE_WIDTH = A5[0]
|
||||
|
||||
text_width = stringWidth(text,FONT, SIZE)
|
||||
can.drawString((PAGE_WIDTH - text_width) / 2, 150, text)
|
||||
can.drawString((PAGE_WIDTH - text_width) / 2, 100, text)
|
||||
can.save()
|
||||
|
||||
#move to the beginning of the StringIO buffer
|
||||
|
@ -60,16 +58,16 @@ def copertina(text):
|
|||
return(page)
|
||||
|
||||
|
||||
def main():
|
||||
# Scarica tutti i post da Mastodon
|
||||
|
||||
# Scarica tutti i post da Mastodon
|
||||
print("Scarico i post")
|
||||
|
||||
print("Scarico i post")
|
||||
|
||||
def default(o):
|
||||
def default(o):
|
||||
if isinstance(o, (datetime.date, datetime.datetime)):
|
||||
return o.isoformat()
|
||||
|
||||
if not os.path.isfile('oloturiadump.json'):
|
||||
if not os.path.isfile('oloturiadump.json'):
|
||||
mastodon = Mastodon(api_base_url = "https://mastodon.bida.im")
|
||||
all_vgos = []
|
||||
last_id = None
|
||||
|
@ -100,10 +98,10 @@ if not os.path.isfile('oloturiadump.json'):
|
|||
json.dump(all_vgos, json_file, indent=4, default=default)
|
||||
|
||||
|
||||
# Scarica tutte le immagini
|
||||
# Scarica tutte le immagini
|
||||
|
||||
print("Scarico le immagini")
|
||||
with open('oloturiadump.json') as json_file:
|
||||
print("Scarico le immagini")
|
||||
with open('oloturiadump.json') as json_file:
|
||||
all_vgos = json.load(json_file)
|
||||
os.makedirs('media', exist_ok=True)
|
||||
|
||||
|
@ -200,11 +198,11 @@ with open('oloturiadump.json') as json_file:
|
|||
os.remove(html_name)
|
||||
|
||||
|
||||
# Genera i libretti
|
||||
# Genera i libretti
|
||||
|
||||
print("Genero i libretti")
|
||||
os.makedirs('books', exist_ok=True)
|
||||
for book_num in range(1, int(len(vgo_dict) / 50) + 1):
|
||||
print("Genero i libretti")
|
||||
os.makedirs('books', exist_ok=True)
|
||||
for book_num in range(1, int(len(vgo_dict) / 50) + 1):
|
||||
pdfWriter = PyPDF2.PdfFileWriter()
|
||||
print(book_num)
|
||||
|
||||
|
@ -234,4 +232,6 @@ for book_num in range(1, int(len(vgo_dict) / 50) + 1):
|
|||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
|
Loading…
Reference in a new issue