/* * ESC & l <psize_enum> A * * Select paper size */ static int set_page_size(pcl_args_t * pargs, pcl_state_t * pcs) { /* Note: not all values are implemented on all printers. If -g has been given on the command line we use the "Custom" page tag, the height and width are set to the device media values which were filled in when the -g option was processed. */ uint tag = (pcs->page_set_on_command_line ? 101 : uint_arg(pargs)); int i; int code = 0; const pcl_paper_size_t *psize = 0; /* 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); for (i = 0; i < pcl_paper_type_count; i++) { if (tag == PAPER_SIZES[i].tag) { psize = &(PAPER_SIZES[i].psize); break; } } if ((psize != 0) && ((code = pcl_end_page_if_marked(pcs)) >= 0)) { pcs->xfm_state.print_dir = 0; new_page_size(pcs, psize, false, false); } return code; }
/* * Reset all parameters which must be reset whenever the logical page * orientation changes. * * The last operand indicates if this routine is being called as part of * an initial resete. */ void new_logical_page(pcl_state_t * pcs, int lp_orient, const pcl_paper_size_t * psize, bool reset_initial, bool for_passthrough) { pcl_xfm_state_t *pxfmst = &(pcs->xfm_state); pxfmst->lp_orient = lp_orient; pxfmst->print_dir = 0; new_page_size(pcs, psize, reset_initial, for_passthrough); }
static int set_logical_page(pcl_args_t * pargs, pcl_state_t * pcs) { uint count = uint_arg(pargs); const pcl_logical_page_t *plogpage = (pcl_logical_page_t *) arg_data(pargs); pcl_paper_size_t *pcur_paper; #ifdef DEBUG if (gs_debug_c('i')) { pcl_debug_dump_data(pcs->memory, arg_data(pargs), uint_arg(pargs)); } #endif /* the currently selected paper size */ pcur_paper = (pcl_paper_size_t *) pcs->xfm_state.paper_size; /* the command can set width, height and offsets (10) or just offsets (4) */ if (count != 10 && count != 4) return e_Range; if (count == 10) { pcur_paper->width = pl_get_uint16(plogpage->Width) * 10; pcur_paper->height = pl_get_uint16(plogpage->Height) * 10; if (pcur_paper->width == 0 || pcur_paper->height == 0) return e_Range; } pcur_paper->offset_portrait = pl_get_int16(plogpage->LeftOffset) * 10; pcur_paper->offset_landscape = pl_get_int16(plogpage->TopOffset) * 10; new_page_size(pcs, pcur_paper, false, false); gs_erasepage(pcs->pgs); pcs->page_marked = false; return 0; }
/* * ESC & l <psize_enum> A * * Select paper size */ static int set_page_size( pcl_args_t * pargs, pcl_state_t * pcs ) { /* Note: not all values are implemented on all printers. */ uint tag = uint_arg(pargs); int i; int code = 0; const pcl_paper_size_t * psize = 0; /* 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); for (i = 0; i < countof(paper_sizes); i++) { if (tag == paper_sizes[i].tag) { psize = &(paper_sizes[i].psize); break; } } if ((psize != 0) && ((code = pcl_end_page_if_marked(pcs)) >= 0)) { /* if the orientation flag is not set for this page we select a portrait page using the set paper size. Otherwise select the paper using the current orientation. */ if ( pcs->orientation_set == false ) new_logical_page(pcs, 0, psize, false, false); else new_page_size(pcs, psize, false, false); } return code; }