ajout d'un paramètre de ratio

This commit is contained in:
Francois Pelletier 2023-02-11 20:35:32 -05:00
parent 3d69f571d5
commit 6984195392
3 changed files with 18 additions and 10 deletions

12
main.py
View file

@ -24,6 +24,7 @@ class DocumentSpecs(BaseModel):
fontsize: int
paperwidth: int
paperheight: int
ratio: int
margin: int
vmargin: int
extension: str
@ -36,6 +37,7 @@ class FormatParameters(BaseModel):
fontsize: int
paperwidth: int
paperheight: int
ratio: int
margin: int
vmargin: int
extension: str
@ -130,10 +132,12 @@ async def generer(specs: DocumentSpecs):
f'--pdf-engine={specs.pdfengine}',
'-V', f'linkcolor={specs.linkcolor}',
'-V', f'fontsize={specs.fontsize}pt',
'-V', f'geometry:paperwidth={specs.paperwidth / 300}in',
'-V', f'geometry:paperheight={specs.paperheight / 300}in',
'-V', f'geometry:margin={specs.margin / 300}in',
'-V', f'geometry:vmargin={specs.vmargin / 300}in'
'-V', f'geometry:paperwidth={round(specs.paperwidth * specs.ratio / 100,-1) / 300}in',
'-V', f'geometry:paperheight={round(specs.paperwidth * specs.ratio / 100,-1) / 300}in',
'-V', f'geometry:left={specs.margin / 300}in',
'-V', f'geometry:right={specs.margin / 300}in',
'-V', f'geometry:top={specs.vmargin / 300}in',
'-V', f'geometry:bottom={specs.vmargin / 300}in'
]
try:
logging.info("Dossier courant = " + os.getcwd())

View file

@ -1,26 +1,23 @@
h11~=0.14.0
pip~=21.3.1
wheel~=0.37.1
PyYAML~=6.0
anyio~=3.6.2
sniffio~=1.3.0
click~=8.1.3
httpcore~=0.16.3
idna~=3.4
rfc3986~=1.5.0
certifi~=2022.12.7
pandoc~=2.3
ply~=3.11
plumbum~=1.8.0
uvloop~=0.17.0
fastapi~=0.88.0
starlette~=0.22.0
fastapi~=0.91.0
starlette~=0.24.0
pydantic~=1.10.2
websockets~=10.4
uvicorn~=0.20.0
httptools~=0.5.0
watchfiles~=0.18.1
httpx~=0.23.1
setuptools~=60.2.0
setuptools~=67.2.0
pypandoc~=1.10
Wand~=0.6.10

View file

@ -6,6 +6,7 @@
"fontsize": 12,
"paperwidth": 2480,
"paperheight": 3507,
"ratio": 100,
"margin": 248,
"vmargin": 350,
"extension": "pdf"
@ -17,6 +18,7 @@
"fontsize": 12,
"paperwidth": 2550,
"paperheight": 3300,
"ratio": 100,
"margin": 255,
"vmargin": 330,
"extension": "pdf"
@ -28,6 +30,7 @@
"fontsize": 16,
"paperwidth": 1200,
"paperheight": 1200,
"ratio": 100,
"margin": 120,
"vmargin": 120,
"extension": "jpg"
@ -39,6 +42,7 @@
"fontsize": 16,
"paperwidth": 1080,
"paperheight": 1920,
"ratio": 100,
"margin": 108,
"vmargin": 192,
"extension": "jpg"
@ -50,6 +54,7 @@
"fontsize": 16,
"paperwidth": 735,
"paperheight": 1102,
"ratio": 100,
"margin": 75,
"vmargin": 110,
"extension": "jpg"
@ -61,6 +66,7 @@
"fontsize": 16,
"paperwidth": 2560,
"paperheight": 1920,
"ratio": 100,
"margin": 256,
"vmargin": 192,
"extension": "pdf"
@ -72,6 +78,7 @@
"fontsize": 16,
"paperwidth": 2560,
"paperheight": 1440,
"ratio": 100,
"margin": 256,
"vmargin": 144,
"extension": "pdf"