docx-mailmerge icon indicating copy to clipboard operation
docx-mailmerge copied to clipboard

Make page break optional for merge_pages

Open sebbelese opened this issue 7 years ago • 3 comments

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 :

sebbelese avatar Nov 10 '17 11:11 sebbelese

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"

sebbelese avatar Nov 10 '17 11:11 sebbelese

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?

Bouke avatar Nov 12 '17 20:11 Bouke

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?

sebbelese avatar Nov 13 '17 15:11 sebbelese