Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Page breaks #123

Closed
poweriton opened this issue May 26, 2022 · 8 comments
Closed

Page breaks #123

poweriton opened this issue May 26, 2022 · 8 comments
Labels
help wanted Extra attention is needed

Comments

@poweriton
Copy link

We output our mail merge to one word document, idea being that each new letter is on a new page. To accomplish this i have a for loop wrapped round a page break. The output always has a additional page instead of ending straight after the last document.

@erdos
Copy link
Owner

erdos commented May 26, 2022

hi, can you share an example template document?

how are you doing the looping? perhaps you could try someting like this (I have not tested the idea):

{%for i in range(length(elems))%}
  {%if i != 0%} <PAGE BREAK HERE> {%end%}
  rest of document with parameters included like {%=elems[i]["price"]%} etc.
{%end%}

``

@poweriton
Copy link
Author

poweriton commented May 26, 2022 via email

@erdos
Copy link
Owner

erdos commented May 26, 2022

I created a working example based on the idea above, see in attachment. This does not render the empty page.

Example payload:

{"contacts":
  [{"ctype": "H"},
   {"ctype": "P"},
   {"ctype": "P"},
   {"ctype": "H"}]}

test-control-loop-empty2.docx

@erdos
Copy link
Owner

erdos commented May 26, 2022

This looks like an interesting use case, I created two issues to help solve the problem in a simpler way:

@erdos erdos added the help wanted Extra attention is needed label May 26, 2022
@poweriton
Copy link
Author

poweriton commented May 26, 2022 via email

@erdos
Copy link
Owner

erdos commented Jun 1, 2022

Hi, the two changes have been just released with version 0.4.3.

The solution for the inital task looks something like this now:

{%for idx, c in contacts %}{%if idx > 0%}{%=pageBreak()%}{%end%}
BODY HERE FOR {%=c.ctype%}.
{%end%}

@poweriton
Copy link
Author

poweriton commented Jun 2, 2022 via email

@erdos
Copy link
Owner

erdos commented Jul 2, 2022

did it work? :-)

@erdos erdos closed this as completed Jul 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants