small PDF export tweaks
This commit is contained in:
@ -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))
|
||||
|
Reference in New Issue
Block a user