static int lp2000_print_page_copies(gx_device_printer * pdev, FILE * fp, int num_coipes) { gx_device_lprn *const lprn = (gx_device_lprn *) pdev; int code = 0; int bpl = gdev_mem_bytes_per_scan_line(pdev); int maxY = lprn->BlockLine / lprn->nBh * lprn->nBh; /* printer initialize */ if (pdev->PageCount == 0) escpage_printer_initialize(pdev, fp, num_coipes); if (!(lprn->CompBuf = gs_malloc(pdev->memory->non_gc_memory, bpl * 3 / 2 + 1, maxY, "lp2000_print_page_copies(CompBuf)"))) return_error(gs_error_VMerror); if (lprn->NegativePrint) { fprintf(fp, "%c1dmG", GS); fprintf(fp, "%c0;0;%d;%d;0rG", GS, pdev->width, pdev->height); fprintf(fp, "%c2owE", GS); } code = lprn_print_image(pdev, fp); if (code < 0) return code; gs_free(pdev->memory->non_gc_memory, lprn->CompBuf, bpl * 3 / 2 + 1, maxY, "lp2000_print_page_copies(CompBuf)"); if (pdev->Duplex) fprintf(fp, "%c0dpsE", GS); else fprintf(fp, "\014"); /* eject page */ return code; }
/* Send the page to the printer. For speed, compress each scan line, since computer-to-printer communication time is often a bottleneck. */ static int npdl_print_page_copies(gx_device_printer * pdev, FILE * prn_stream, int num_copies) { gx_device_lprn *const lprn = (gx_device_lprn *) pdev; int line_size = gdev_prn_raster(pdev); int x_dpi = (int)(pdev->x_pixels_per_inch); char paper_command[5]; int code; int maxY = lprn->BlockLine / lprn->nBh * lprn->nBh; if (!(lprn->CompBuf = gs_malloc(pdev->memory->non_gc_memory, line_size * maxY, sizeof(byte), "npdl_print_page_copies(CompBuf)"))) return_error(gs_error_VMerror); /* Initialize printer */ if (pdev->PageCount == 0) { /* Initialize printer */ fputs("\033c1", prn_stream); /* Software Reset */ fputs("\034d240.", prn_stream); /* Page Printer Mode */ /* Check paper size */ switch (npdl_get_paper_size((gx_device *) pdev)) { case PAPER_SIZE_POSTCARD: gs_sprintf(paper_command, "PC"); break; case PAPER_SIZE_A5: gs_sprintf(paper_command, "A5"); break; case PAPER_SIZE_A4: gs_sprintf(paper_command, "A4"); break; case PAPER_SIZE_A3: gs_sprintf(paper_command, "A3"); break; case PAPER_SIZE_B5: gs_sprintf(paper_command, "B5"); break; case PAPER_SIZE_B4: gs_sprintf(paper_command, "B4"); break; case PAPER_SIZE_LETTER: gs_sprintf(paper_command, "LT"); break; case PAPER_SIZE_ENV4: gs_sprintf(paper_command, "ENV4"); break; case PAPER_SIZE_BPOSTCARD: gs_sprintf(paper_command, "UPPC"); break; } if (lprn->ManualFeed) { fprintf(prn_stream, "\034f%cM0.", (pdev->MediaSize[0] > pdev->MediaSize[1]) ? 'L' : 'P'); /* Page Orientation P: Portrait, L: Landscape */ } else { fprintf(prn_stream, "\034f%c%s.", (pdev->MediaSize[0] > pdev->MediaSize[1]) ? 'L' : 'P', /* Page Orientation P: Portrait, L: Landscape */ paper_command); /* Paper Size */ } fprintf(prn_stream, "\034<1/%d,i.", x_dpi); /* Image Resolution */ /* Duplex Setting */ if (pdev->Duplex_set > 0) { if (pdev->Duplex) { if (lprn->Tumble == 0) fprintf(prn_stream, "\034'B,,1,0."); else fprintf(prn_stream, "\034'B,,2,0."); } else fprintf(prn_stream, "\034'S,,,0."); } } if (num_copies > 99) num_copies = 99; fprintf(prn_stream, "\034x%d.", num_copies); lprn->initialized = false; if (lprn->NegativePrint) { fprintf(prn_stream, "\034e0,0."); /* move to (0, 0) */ fprintf(prn_stream, "\034Y"); /* goto figure mode */ fprintf(prn_stream, "SU1,%d,0;", (int)pdev->x_pixels_per_inch); /* Setting Printer Unit */ fprintf(prn_stream, "SG0,0;"); /* select black color */ fprintf(prn_stream, "NP;"); /* begin path */ fprintf(prn_stream, "PA%d,0,%d,%d,0,%d;", pdev->width, pdev->width, pdev->height, pdev->height); /* draw rectangle */ fprintf(prn_stream, "CP"); /* close path */ fprintf(prn_stream, "EP;"); /* end path */ fprintf(prn_stream, "FL0;"); /* fill path */ fprintf(prn_stream, "\034Z"); /* end of figure mode */ fprintf(prn_stream, "\034\"R."); /* `R'eplace Mode */ } code = lprn_print_image(pdev, prn_stream); if (code < 0) return code; /* Form Feed */ fputs("\014", prn_stream); gs_free(pdev->memory->non_gc_memory, lprn->CompBuf, line_size * maxY, sizeof(byte), "npdl_print_page_copies(CompBuf)"); return 0; }