Multi Doc Printing

I thought I’d post some code for ppl who want to setup multiple doc printing with a click of a button. I’m testing this right now with the process payroll tool. I hope it’s useful to ppl who like to play around with code a bit.

The code uses some custom header and footer functionality I was working on. I’m sure it could be modified to work with the new header/footer features that are being added soon. I’ll have to look at it when I get the chance.

Disclaimer: Most of this code was hacked together in a rush and most definitely has bugs. Please don’t test on a production server.

Requirements:

  1. Add a button to a doctype
  2. Create custom js to be executed by the button. Example shown below.
  3. Add a Python method that creates a dict of all doc names to be printed.

The custom js basically joins all the names into one and calls a custom function that gets the html for each doc and joins it together with page breaks. Comments in the code show where the code should go for this example.
I should point out the at the moment it can only print multiple docs of the same doctype.

Edit: Made some changes and trying to make it compatible with the new pdf print features. Still WIP

5 Likes

@Kar_M send a PR :smile:

Done. https://github.com/frappe/frappe/pull/1598

1 Like