PDF Output: Fix conversion failing when adding header/footer and the input document defines margins/padding on the <html> tag. Fixes #1905736 [PDF conversion fails - number of header/footer pages](https://bugs.launchpad.net/calibre/+bug/1905736)

This commit is contained in:
Kovid Goyal 2020-12-10 12:11:36 +05:30
parent 706e229558
commit b14ab0351b
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -1031,6 +1031,7 @@ def add_header_footer(manager, opts, pdf_doc, container, page_number_display_map
report_progress(0.8, _('Adding headers and footers'))
name = create_skeleton(container)
root = container.parsed(name)
root.set('style', 'margin: 0; padding: 0; border-width: 0; background-color: unset;')
body = last_tag(root)
body.attrib.pop('id', None)
body.set('style', 'margin: 0; padding: 0; border-width: 0; background-color: unset;')
@ -1181,6 +1182,7 @@ def add_header_footer(manager, opts, pdf_doc, container, page_number_display_map
data = results[name]
if not isinstance(data, bytes):
raise SystemExit(data)
# open('/t/impose.pdf', 'wb').write(data)
doc = data_as_pdf_doc(data)
first_page_num = pdf_doc.page_count()
num_pages = doc.page_count()