static int /* ESC & l <sd_enum> S */ pcl_simplex_duplex_print(pcl_args_t *pargs, pcl_state_t *pcs) { int code; bool reopen = false; /* oddly the command goes to the next page irrespective of arguments */ code = pcl_end_page_if_marked(pcs); if ( code < 0 ) return code; pcl_home_cursor(pcs); switch ( int_arg(pargs) ) { case 0: pcs->duplex = false; break; case 1: pcs->duplex = true; pcs->bind_short_edge = false; break; case 2: pcs->duplex = true; pcs->bind_short_edge = true; break; default: return 0; } code = put_param1_bool(pcs, "Duplex", pcs->duplex); switch ( code ) { case 1: /* reopen device */ reopen = true; case 0: break; case gs_error_undefined: return 0; default: /* error */ if ( code < 0 ) return code; } code = put_param1_bool(pcs, "BindShortEdge", pcs->bind_short_edge); switch ( code ) { case 1: /* reopen device */ reopen = true; case 0: case gs_error_undefined: break; default: /* error */ if ( code < 0 ) return code; } return (reopen ? gs_setdevice_no_erase(pcs->pgs, gs_currentdevice(pcs->pgs)) : 0); }
/* * ESC & l <feed_enum> H * * Set paper source */ static int set_paper_source(pcl_args_t * pargs, pcl_state_t * pcs) { uint i = uint_arg(pargs); /* oddly the command goes to the next page irrespective of arguments */ int code = pcl_end_page_if_marked(pcs); if (code < 0) return code; pcl_home_cursor(pcs); /* Do not change the page side if the wanted paper source is the same as the actual one */ if (pcs->paper_source != i) { pcs->back_side = false; put_param1_bool(pcs, "FirstSide", !pcs->back_side); } pcs->paper_source = i; /* Note: not all printers support all possible values. */ if (i <= 6) { code = 0; if (i > 0) code = put_param1_int(pcs, "%MediaSource", i); return (code < 0 ? code : 0); } else return e_Range; }
static int /* ESC & a <side_enum> G */ pcl_duplex_page_side_select(pcl_args_t *pargs, pcl_state_t *pcs) { uint i = uint_arg(pargs); int code; /* oddly the command goes to the next page irrespective of arguments */ code = pcl_end_page_if_marked(pcs); if ( code < 0 ) return code; pcl_home_cursor(pcs); if ( i > 2 ) return 0; if ( i > 0 && pcs->duplex ) put_param1_bool(pcs, "FirstSide", i == 1); return 0; }
int pcl_do_printer_reset(pcl_state_t *pcs) { if ( pcs->macro_level ) return e_Range; /* not allowed inside macro */ /* reset the other parser in case we have gotten the pcl_printer_reset while in gl/2 mode. */ pcl_implicit_gl2_finish(pcs); /* Print any partial page if not pclxl snippet mode. */ if (pcs->end_page == pcl_end_page_top) { int code = pcl_end_page_if_marked(pcs); if ( code < 0 ) return code; /* if duplex start on the front side of the paper */ if ( pcs->duplex ) put_param1_bool(pcs, "FirstSide", true); } /* unload fonts */ /* Reset to user default state. */ return pcl_do_resets(pcs, pcl_reset_printer); }
/* * End a page, either unconditionally or only if there are marks on it. * Return 1 if the page was actually printed and erased. */ int pcl_end_page(pcl_state_t * pcs, pcl_print_condition_t condition) { int code = 0; pcl_break_underline(pcs); /* (could mark page) */ /* If we are conditionally printing (normal case) check if the page is marked */ if (condition != pcl_print_always) { if (!pcl_page_marked(pcs)) return 0; } /* finish up graphics mode in case we finished the page in the middle of a raster stream */ if (pcs->raster_state.graphics_mode) pcl_end_graphics_mode(pcs); /* If there's an overlay macro, execute it now. */ if (pcs->overlay_enabled) { void *value; if (pl_dict_find(&pcs->macros, id_key(pcs->overlay_macro_id), 2, &value)) { pcs->overlay_enabled = false; /**** IN reset_overlay ****/ code = pcl_execute_macro((const pcl_macro_t *)value, pcs, pcl_copy_before_overlay, pcl_reset_overlay, pcl_copy_after_overlay); if (code < 0) return code; pcs->overlay_enabled = true; /**** IN copy_after ****/ } } /* output the page */ code = (*pcs->end_page) (pcs, pcs->num_copies, true); if (code < 0) return code; if (pcs->end_page == pcl_end_page_top) code = gs_erasepage(pcs->pgs); pcs->page_marked = false; /* * Advance of a page may move from a page front to a page back. This may * change the applicable transformations. */ /* * Keep track of the side you are on */ if (pcs->duplex) { pcs->back_side = ! pcs->back_side; } else { pcs->back_side = false; } put_param1_bool(pcs,"FirstSide", !pcs->back_side); update_xfm_state(pcs, 0); pcl_continue_underline(pcs); return (code < 0 ? code : 1); }