Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions htmldocx/h2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ def add_styles_to_paragraph(self, style):
self.paragraph.paragraph_format.left_indent = Inches(min(margin // 10 * INDENT, MAX_INDENT))
# TODO handle non px units


def add_styles_to_run(self, style):
if 'color' in style:
if 'rgb' in style['color']:
Expand Down Expand Up @@ -399,6 +400,9 @@ def handle_link(self, href, text):
# Add hyperlink to run
self.paragraph._p.append(hyperlink)

def handle_pagebreak(self):
self.doc.add_page_break()

def handle_starttag(self, tag, attrs):
if self.skip:
return
Expand Down Expand Up @@ -468,6 +472,13 @@ def handle_starttag(self, tag, attrs):
elif tag == 'table':
self.handle_table()
return
# handle pagebreak using following html code
# <div style="page-break-after: always;"></div>
elif tag == 'div':
style = self.parse_dict_string(current_attrs['style'])
if(style.get('page-break-after', '') == 'always'):
self.handle_pagebreak()


# set new run reference point in case of leading line breaks
if tag in ['p', 'li', 'pre']:
Expand Down