small PDF export tweaks

This commit is contained in:
vabene1111
2022-01-07 10:55:27 +01:00
parent 0a6abf9688
commit d506952602
6 changed files with 54 additions and 39 deletions

View File

@ -19,10 +19,6 @@ class PDFexport(Integration):
def get_recipe_from_file(self, file):
raise NotImplementedError('Method not implemented in storage integration')
async def get_files_from_recipes_async(self, recipes, cookie):
cmd = runserver.Command()
@ -33,15 +29,15 @@ class PDFexport(Integration):
ignoreHTTPSErrors=True
)
cookies = {'domain': cmd.default_addr, 'name': 'sessionid', 'value': cookie['sessionid'],}
options = { 'format': 'letter',
'margin': {
'top': '0.75in',
'bottom': '0.75in',
'left': '0.75in',
'right': '0.75in',
}
}
cookies = {'domain': cmd.default_addr, 'name': 'sessionid', 'value': cookie['sessionid'], }
options = {'format': 'letter',
'margin': {
'top': '0.75in',
'bottom': '0.75in',
'left': '0.75in',
'right': '0.75in',
}
}
page = await browser.newPage()
await page.emulateMedia('print')
@ -49,14 +45,11 @@ class PDFexport(Integration):
files = []
for recipe in recipes:
await page.goto('http://'+cmd.default_addr+':'+cmd.default_port+'/view/recipe/'+str(recipe.id), {'waitUntil': 'networkidle0',})
files.append([ recipe.name+'.pdf', await page.pdf(options) ])
await page.goto('http://' + cmd.default_addr + ':' + cmd.default_port + '/view/recipe/' + str(recipe.id), {'waitUntil': 'networkidle0', })
files.append([recipe.name + '.pdf', await page.pdf(options)])
await browser.close()
return files
def get_files_from_recipes(self, recipes, cookie):
return asyncio.run(self.get_files_from_recipes_async(recipes, cookie))