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/
|
pdf/
|
||||||
|
|
||||||
*.json
|
*.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
|
from PyPDF2 import PdfFileWriter, PdfFileReader
|
||||||
import io
|
import io
|
||||||
from reportlab.pdfgen import canvas
|
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 import pdfmetrics
|
||||||
from reportlab.pdfbase.ttfonts import TTFont
|
from reportlab.pdfbase.ttfonts import TTFont
|
||||||
from reportlab.pdfbase.pdfmetrics import stringWidth
|
from reportlab.pdfbase.pdfmetrics import stringWidth
|
||||||
from reportlab.rl_config import defaultPageSize
|
|
||||||
|
|
||||||
FONT = 'Roboto'
|
FONT = 'Roboto'
|
||||||
SIZE = 48
|
SIZE = 36
|
||||||
|
|
||||||
packet = io.BytesIO()
|
packet = io.BytesIO()
|
||||||
# create a new PDF with Reportlab
|
# create a new PDF with Reportlab
|
||||||
|
|
||||||
pdfmetrics.registerFont(TTFont("Roboto", "template/roboto-regular-webfont.ttf"))
|
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)
|
can.setFont(FONT, SIZE)
|
||||||
|
|
||||||
PAGE_WIDTH = defaultPageSize[0]
|
PAGE_WIDTH = A5[0]
|
||||||
#PAGE_HEIGHT = defaultPageSize[1]
|
|
||||||
|
|
||||||
text_width = stringWidth(text,FONT, SIZE)
|
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()
|
can.save()
|
||||||
|
|
||||||
#move to the beginning of the StringIO buffer
|
#move to the beginning of the StringIO buffer
|
||||||
|
@ -60,7 +58,7 @@ def copertina(text):
|
||||||
return(page)
|
return(page)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
# Scarica tutti i post da Mastodon
|
# Scarica tutti i post da Mastodon
|
||||||
|
|
||||||
print("Scarico i post")
|
print("Scarico i post")
|
||||||
|
@ -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