docx-mailmerge
docx-mailmerge copied to clipboard
Make page break optional for merge_pages
When using the merge_pages
function, a page break is systematically added between each template. I need to insert several tables in a word document, which should not be separated by page breaks. I think that it would be useful to make the page break optional for such cases.
Current Behavior
Page break inserted between each template with merge_pages
Possible Solution
Maker this page break optional is simple:
Line 139, replace
def merge_pages(self, replacements):
with
def merge_pages(self, replacements, insertpagebreaks=True):
Line 158, replace
if i > 0:
with
if i > 0 and insertpagebreaks :
The title of issue #27 looks like it is a duplicate, but I do not think it is when looking at the issue description as it refers to "blank pages"
So if I understand you correctly, you'd want to duplicate the same table a few times -- however without inserting page breaks? So instead of merge_pages
, shouldn't the API rather be renamed to merge_template
and accept an argument like separate_by_page_break
?
Yes, it is what I try to do.
Indeed, renaming the function is probably best suited, but it would break the API and codes using it. Or maybe have merge_pages
and merge_template
methods separate?