Bug 18465 - Patron card creator: Print on duplex card printer
Summary: Patron card creator: Print on duplex card printer
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Label/patron card printing (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Marc Véron
QA Contact: Testopia
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 18541
  Show dependency treegraph
 
Reported: 2017-04-20 18:26 UTC by Marc Véron
Modified: 2017-07-12 10:03 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Bot Control: ---
When did the bot last check this:
Who signed the patch off:
Text to go in the release notes:


Attachments
Bug 18465 - Patron card creator: Print on duplex card printer (13.49 KB, patch)
2017-04-20 19:09 UTC, Marc Véron
Details | Diff | Splinter Review
Screenshots with test settings for duplex card printing... (176.81 KB, application/pdf)
2017-05-03 12:58 UTC, Marc Véron
Details
Results duplex card printing based on test settings (876.46 KB, application/pdf)
2017-05-03 12:59 UTC, Marc Véron
Details
[SIGNED OFF] Bug 18465 - Patron card creator: Print on duplex card printer (13.56 KB, patch)
2017-05-04 06:29 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 18465: (followup) Do not use clone (1.06 KB, text/plain)
2017-06-23 16:50 UTC, Marc Véron
Details
Bug 18465: (followup) Fix issue with patron lists an ddo notuse clone (2.55 KB, patch)
2017-06-23 17:48 UTC, Marc Véron
Details | Diff | Splinter Review
Bug 18465: (followup) Fix issue with patron lists an do not use clone (2.55 KB, patch)
2017-06-23 17:49 UTC, Marc Véron
Details | Diff | Splinter Review
Bug 18465 - Patron card creator: Print on duplex card printer (13.60 KB, patch)
2017-06-23 23:12 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 18465: (followup) Fix issue with patron lists an do not use clone (2.60 KB, patch)
2017-06-23 23:12 UTC, Nick Clemens
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Marc Véron 2017-04-20 18:26:12 UTC
Card printers with duplex functionality need as input a PDF file where odd pages contain the front side and even pages the back side of the cards.
Comment 1 Chris Nighswonger 2017-04-20 18:31:02 UTC
This would be a very nice. Combined with printable RFID cards, it would make a very useful improvement.
Comment 3 Chris Nighswonger 2017-04-20 18:37:06 UTC
If only the page order matters, this should be doable with little effort.
Comment 4 Marc Véron 2017-04-20 19:09:19 UTC
Created attachment 62498 [details] [review]
Bug 18465 - Patron card creator: Print on duplex card printer

Card printers with duplex functionality need as input a PDF file where odd pages contain
the front side and even pages the back side of the cards.

This patch adds such functionality.

To prepare test:
- In Patron card creator > Templates, prepare a 1 up template (1 column / 1 row) that
  fits to a single card. Give it a name like 'Duplex card template'
  (Attention, Card with and Card height seem to have wrong labels, that will go
  to a separate bug).
- In Patron card creator > Layouts create a layout for the front side and one for
  the back side. Give them names to easily remember (Card front layout, Card back layout)
- Go to Patron card creator > Batches and test both layouts together with the
  1 up template. Save and keepp both test files as reference.

To test:
- Apply patch. Restart memcached and plack.
- Go to Patron card creator > Batches
- Click "Export" for a batch
- In the following screen, note the new field "Select a layout for the back side"
  with a hint what it is used for
- Leave it on 'Back side layout not used', export and compare output with test ooutput
  from preparation. It should be the same
- Select the layout you prepared for the back side.
- Export - this file should contain 2 PDF pages per patron, one first with the
  front side, second with the back side.
Comment 5 Katrin Fischer 2017-05-03 09:42:15 UTC
Hi Marc, we have some probems gettig the setup right, could you share screenshots/information about your configuration (template/layout) maybe?
Comment 6 Marc Véron 2017-05-03 12:58:45 UTC
Created attachment 63011 [details]
Screenshots with test settings for duplex card printing...
Comment 7 Marc Véron 2017-05-03 12:59:22 UTC
Created attachment 63012 [details]
Results duplex card printing based on test settings
Comment 8 Katrin Fischer 2017-05-03 13:03:33 UTC
Hi Marc, thx, that's very helpful! Is it ok that both layouts say Page side = Front?
Comment 9 Marc Véron 2017-05-03 13:40:52 UTC
(In reply to Katrin Fischer from comment #8)
> Hi Marc, thx, that's very helpful! Is it ok that both layouts say Page side
> = Front?

Yes. This is only used for templates with multiple columns.

For duplex card print we use only 1 row and 1 column, so it is not needed here.

--------

Explanation for page side used with multiple columns: 
Workflow is to print first the front side, then turn the pages and then pront the back sides.

Lets say you have a template with 3 columns and a batch with 3 patrons.

The layout for the front prints the names:
Name 1 | Name 2 | Name 3

And another layout for the back side prints the first names.
Output should be:
First name 3 | First name 2 | First name 1
...to print 'First name 1' on the back of 'Name 1'

Page side: 'Back' shuffles data to do that.
Comment 10 Marc Véron 2017-05-03 14:30:43 UTC
(In reply to Marc Véron from comment #4)
> Created attachment 62498 [details] [review] [review]
> Bug 18465 - Patron card creator: Print on duplex card printer

>   (Attention, Card with and Card height seem to have wrong labels, that will
> go to a separate bug).

Not wrong labels but confusing sequence. See Bug 18528
Comment 11 Katrin Fischer 2017-05-04 06:28:33 UTC
Mine were not quite as pretty as yours - but it works really well!
Comment 12 Katrin Fischer 2017-05-04 06:29:15 UTC
Created attachment 63046 [details] [review]
[SIGNED OFF] Bug 18465 - Patron card creator: Print on duplex card printer

Card printers with duplex functionality need as input a PDF file where odd pages contain
the front side and even pages the back side of the cards.

This patch adds such functionality.

To prepare test:
- In Patron card creator > Templates, prepare a 1 up template (1 column / 1 row) that
  fits to a single card. Give it a name like 'Duplex card template'
  (Attention, Card with and Card height seem to have wrong labels, that will go
  to a separate bug).
- In Patron card creator > Layouts create a layout for the front side and one for
  the back side. Give them names to easily remember (Card front layout, Card back layout)
- Go to Patron card creator > Batches and test both layouts together with the
  1 up template. Save and keepp both test files as reference.

To test:
- Apply patch. Restart memcached and plack.
- Go to Patron card creator > Batches
- Click "Export" for a batch
- In the following screen, note the new field "Select a layout for the back side"
  with a hint what it is used for
- Leave it on 'Back side layout not used', export and compare output with test ooutput
  from preparation. It should be the same
- Select the layout you prepared for the back side.
- Export - this file should contain 2 PDF pages per patron, one first with the
  front side, second with the back side.

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 13 Marc Véron 2017-05-18 07:10:22 UTC Comment hidden (obsolete)
Comment 14 Marc Véron 2017-06-20 15:08:22 UTC
Still applies on current master.
Comment 15 Nick Clemens 2017-06-23 14:42:07 UTC
create-pdf.pl

135 	#my $print_layout_xml = $layout_back_xml;

136 	my $print_layout_xml = (( ($cardscount % 2  == 1) && ( $layout_back_id ) ) ?

137 	clone($layout_back_xml) : clone($layout_xml) );

Fist line looks like debug, is Clone being added as a dependency here? can we just make a copy?

Otherwise worked well in testing
Comment 16 Marc Véron 2017-06-23 16:17:03 UTC
(In reply to Nick Clemens from comment #15)
> create-pdf.pl
> 
> 135 	#my $print_layout_xml = $layout_back_xml;
> 
> 136 	my $print_layout_xml = (( ($cardscount % 2  == 1) && ( $layout_back_id
> ) ) ?
> 
> 137 	clone($layout_back_xml) : clone($layout_xml) );
> 
> Fist line looks like debug, is Clone being added as a dependency here? can
> we just make a copy?
> 
> Otherwise worked well in testing

- Yes, #135 is a reminder of my tests and superfluous. As far as I remember it was not possible to have a simple copy like in line 135, that's why I used clone for a deep copy.

- Clone is used at other places as well (git grep 'use Clone'). Should it be added to the dependencies? I would propose to do that in a separate bug.
Comment 17 Marc Véron 2017-06-23 16:47:00 UTC
Ok, I tested without clone, it seems to work. Followup follows.
Comment 18 Marc Véron 2017-06-23 16:50:56 UTC Comment hidden (obsolete)
Comment 19 Marc Véron 2017-06-23 17:48:44 UTC Comment hidden (obsolete)
Comment 20 Marc Véron 2017-06-23 17:49:49 UTC
Created attachment 64601 [details] [review]
Bug 18465: (followup) Fix issue with patron lists an do not use clone

This followup fixes duplex printing with patron lists.

Additionaly, it uses simple copy instead of clone and removes a
superfluous line, see comments #15 - #17
Comment 21 Nick Clemens 2017-06-23 23:12:25 UTC
Created attachment 64606 [details] [review]
Bug 18465 - Patron card creator: Print on duplex card printer

Card printers with duplex functionality need as input a PDF file where odd pages contain
the front side and even pages the back side of the cards.

This patch adds such functionality.

To prepare test:
- In Patron card creator > Templates, prepare a 1 up template (1 column / 1 row) that
  fits to a single card. Give it a name like 'Duplex card template'
  (Attention, Card with and Card height seem to have wrong labels, that will go
  to a separate bug).
- In Patron card creator > Layouts create a layout for the front side and one for
  the back side. Give them names to easily remember (Card front layout, Card back layout)
- Go to Patron card creator > Batches and test both layouts together with the
  1 up template. Save and keepp both test files as reference.

To test:
- Apply patch. Restart memcached and plack.
- Go to Patron card creator > Batches
- Click "Export" for a batch
- In the following screen, note the new field "Select a layout for the back side"
  with a hint what it is used for
- Leave it on 'Back side layout not used', export and compare output with test ooutput
  from preparation. It should be the same
- Select the layout you prepared for the back side.
- Export - this file should contain 2 PDF pages per patron, one first with the
  front side, second with the back side.

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 22 Nick Clemens 2017-06-23 23:12:28 UTC
Created attachment 64607 [details] [review]
Bug 18465: (followup) Fix issue with patron lists an do not use clone

This followup fixes duplex printing with patron lists.

Additionaly, it uses simple copy instead of clone and removes a
superfluous line, see comments #15 - #17

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 23 Jonathan Druart 2017-07-06 18:49:54 UTC
Pushed to master for 17.11, thanks to everybody involved!
Comment 24 Fridolin SOMERS 2017-07-12 10:03:15 UTC
Enhancement not pushed to 17.05.x