+ /* when printing multiple collated copies & multiple pages per sheet we want to
+ prevent the next copy bleeding into the last sheet of the previous one
+ we therefore check whether we've reached the last page in a document
+ if that is the case and the given sheet is not filled with pages,
+ we introduce a few blank pages to finish off the sheet
+ to make sure nothing goes wrong, the final condition ensures that
+ we're not at the end of a sheet, otherwise we'd introduce a blank sheet! */
+
+ if (export->collate == 1 && export->total > 1 && export->pages_per_sheet > 1 &&
+ (export->page + 1) % export->n_pages == 0 && (export->total - 1 + export->blank) % export->pages_per_sheet != 0) {
+ ev_document_doc_mutex_lock ();
+ ev_file_exporter_end_page (EV_FILE_EXPORTER (op->document));
+ /* keep track of how many blank pages have been added */
+ export->blank += export->pages_per_sheet - (export->total - 1 + export->blank) % export->pages_per_sheet;
+ ev_document_doc_mutex_unlock ();
+ }
+
+