home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 19 Printer / 19-Printer.zip / mpage.zip / mp_page.c < prev    next >
Text File  |  1997-09-25  |  6KB  |  223 lines

  1. # include <stdio.h>
  2. # include <sys/types.h>
  3.  
  4. # ifndef lint
  5. static char *rcs_id =
  6.     "@(#) $Header: mp_page.c,v 2.4 89/05/25 08:58:28 mark Exp $";
  7. # endif
  8.  
  9. # include "mp_head.h"
  10.  
  11. /*
  12.  * mpage:    a program to reduce pages of print so that several pages
  13.  *           of output appear on one printed page.
  14.  *
  15.  * Written by:
  16.  *   ...!uunet!\                       Mark Hahn, Sr Systems Engineer
  17.  *              >pyrdc!mark            Pyramid Technology Corporation
  18.  * ...!pyramid!/                       Vienna, Va    (703)848-2050
  19.  *
  20.  *
  21.  * Copyright (c) 1988 Mark P. Hahn, Herndon, Virginia
  22.  *  
  23.  *     Permission is granted to anyone to make or distribute verbatim
  24.  *     copies of this document as received, in any medium, provided
  25.  *     that this copyright notice notice is preserved, and that the
  26.  *     distributor grants the recipient permission for further
  27.  *     redistribution as permitted by this notice.
  28.  *
  29.  */
  30.  
  31. /* $Log:    mp_page.c,v $
  32.  * Revision 2.4  89/05/25  08:58:28  mark
  33.  * rearranged the rcs header keywords for better readability.
  34.  * 
  35.  * Revision 2.3  89/05/22  14:41:01  mark
  36.  * Fixed the type-o in the rcs identification string
  37.  * 
  38.  * Revision 2.2  89/05/22  14:38:04  mark
  39.  * Added rcs identification usable with the "what" program
  40.  * 
  41.  * Revision 2.1  89/05/22  14:31:27  mark
  42.  * New Major Revision
  43.  * 
  44.  * Revision 1.1  89/05/22  14:25:52  mark
  45.  * Initial revision
  46.  *  */
  47.  
  48. set_page()
  49. {
  50.     if (opt_a4) {
  51.         ps_width = 596;
  52.         ps_height = 842;
  53.     } else {
  54.         ps_width = 612;
  55.         ps_height = 792;
  56.     }
  57. }
  58.  
  59. xbase1()
  60. {
  61.     Debug(DB_POINTS, "%%xbase1: %d\n", pg_sheetmargin + pg_pagemargin);
  62.     return pg_sheetmargin + pg_pagemargin;
  63. }
  64.  
  65. xbase2()
  66. {
  67.     Debug(DB_POINTS, "%%xbase2: %d\n",  (ps_width / 2) + pg_pagemargin);
  68.     return (ps_width / 2) + pg_pagemargin;
  69. }
  70.  
  71. ybase1()
  72. {
  73.     Debug(DB_POINTS, "%%ybase1: %d\n", pg_sheetmargin + pg_pagemargin);
  74.     return pg_sheetmargin + pg_pagemargin;
  75. }
  76.  
  77. ybase2()
  78. {
  79.     Debug(DB_POINTS, "%%ybase2: %d\n",
  80.           (((ps_height / 2) - pg_sheetmargin) / 2)
  81.           + pg_sheetmargin + pg_pagemargin);
  82.     return (((ps_height / 2) - pg_sheetmargin) / 2)
  83.       + pg_sheetmargin + pg_pagemargin;
  84. }
  85.  
  86. ybase3()
  87. {
  88.     Debug(DB_POINTS, "%%ybase3: %d\n", (ps_height / 2) + pg_pagemargin);
  89.     return (ps_height / 2) + pg_pagemargin;
  90. }
  91.  
  92. ybase4()
  93. {
  94.     Debug(DB_POINTS, "%%ybase4: %d\n",
  95.           (((ps_height / 2) - pg_sheetmargin) / 2)
  96.           + (ps_height / 2) + pg_pagemargin);
  97.     return (((ps_height / 2) - pg_sheetmargin) / 2)
  98.       + (ps_height / 2) + pg_pagemargin;
  99. }
  100.  
  101. ytop1()
  102. {
  103.     Debug(DB_POINTS, "%%ytop1: %d\n", ybase1() + yht4());
  104.     return ybase1() + yht4();
  105. }
  106.  
  107. ytop2()
  108. {
  109.     Debug(DB_POINTS, "%%ytop2: %d\n", ybase2() + yht4());
  110.     return ybase2() + yht4();
  111. }
  112.  
  113. ytop3()
  114. {
  115.     Debug(DB_POINTS, "%%ytop3: %d\n", ybase3() + yht4());
  116.     return ybase3() + yht4();
  117. }
  118.  
  119. ytop4()
  120. {
  121.     Debug(DB_POINTS, "%%ytop4: %d\n", ybase4() + yht4());
  122.     return ybase4() + yht4();
  123. }
  124.  
  125. xwid1()
  126. {
  127.     Debug(DB_POINTS, "%%xwid1: %d\n",
  128.           ps_width - ((2 * pg_sheetmargin) + (2 * pg_pagemargin)));
  129.     return ps_width - ((2 * pg_sheetmargin) + (2 * pg_pagemargin));
  130. }
  131.  
  132. xwid2()
  133. {
  134.     Debug(DB_POINTS, "%%xwid2: %d\n",
  135.           (ps_width / 2) - (pg_sheetmargin + (2 * pg_pagemargin)));
  136.     return (ps_width / 2) - (pg_sheetmargin + (2 * pg_pagemargin));
  137. }
  138.  
  139. yht1()
  140. {
  141.     Debug(DB_POINTS, "%%yht1: %d\n",
  142.           ps_height - ((2 * pg_sheetmargin) + (2 * pg_pagemargin)));
  143.     return ps_height - ((2 * pg_sheetmargin) + (2 * pg_pagemargin));
  144. }
  145.  
  146. yht2()
  147. {
  148.     Debug(DB_POINTS, "%%yht2: %d\n",
  149.           (ps_height / 2) - (pg_sheetmargin + (2 * pg_pagemargin)));
  150.     return (ps_height / 2) - (pg_sheetmargin + (2 * pg_pagemargin));
  151. }
  152.  
  153. yht4()
  154. {
  155.     Debug(DB_POINTS, "%%yht4: %d\n",
  156.           (((ps_height / 2) - pg_sheetmargin) / 2) - (2 * pg_pagemargin));
  157.     return (((ps_height / 2) - pg_sheetmargin) / 2) - (2 * pg_pagemargin);
  158. }
  159.  
  160. outline_1(outfd)
  161.  FILE *outfd;
  162. {
  163.     /* one page outline */
  164.     fprintf(outfd, "0 setlinewidth\n");
  165.         fprintf(outfd, "%3d %3d moveto\n", pg_sheetmargin, pg_sheetmargin);
  166.     fprintf(outfd, "%3d %3d lineto\n", pg_sheetmargin,
  167.         ps_height - pg_sheetmargin);
  168.     fprintf(outfd, "%3d %3d lineto\n", ps_width - pg_sheetmargin,
  169.         ps_height - pg_sheetmargin);
  170.     fprintf(outfd, "%3d %3d lineto\n", ps_width - pg_sheetmargin,
  171.         pg_sheetmargin);
  172.     fprintf(outfd, "closepath stroke\n");
  173. }
  174.  
  175. outline_2(outfd)
  176.  FILE *outfd;
  177. {
  178.     /* two page outline */
  179.     outline_1(outfd);
  180.     fprintf(outfd, "%3d %3d moveto\n", pg_sheetmargin, ps_height / 2);
  181.     fprintf(outfd, "%3d %3d lineto\n",  ps_width - pg_sheetmargin,
  182.         ps_height / 2);
  183.     fprintf(outfd, "stroke\n");
  184. }
  185.  
  186. outline_4(outfd)
  187.  FILE *outfd;
  188. {
  189.     /* four page outline */
  190.     outline_2(outfd);
  191.     fprintf(outfd, "%3d %3d moveto\n", ps_width / 2 , pg_sheetmargin);
  192.     fprintf(outfd, "%3d %3d lineto\n", ps_width / 2 ,
  193.         ps_height - pg_sheetmargin);
  194.     fprintf(outfd, "stroke\n");
  195. }
  196.  
  197. outline_8(outfd)
  198.  FILE *outfd;
  199. {
  200.     /* eight page outline */
  201.     outline_4(outfd);
  202.     fprintf(outfd, "%3d %3d moveto\n", pg_sheetmargin,
  203.         ((ps_height / 2) - pg_sheetmargin) / 2 + pg_sheetmargin);
  204.     fprintf(outfd, "%3d %3d lineto\n", ps_width - pg_sheetmargin,
  205.         ((ps_height / 2) - pg_sheetmargin) / 2 + pg_sheetmargin);
  206.     fprintf(outfd, "stroke\n");
  207.     fprintf(outfd, "%3d %3d moveto\n", pg_sheetmargin,
  208.         ((ps_height / 2) - pg_sheetmargin) / 2 + (ps_height / 2));
  209.     fprintf(outfd, "%3d %3d lineto\n", ps_width - pg_sheetmargin,
  210.         ((ps_height / 2) - pg_sheetmargin) / 2 + (ps_height / 2));
  211.     fprintf(outfd, "stroke\n");
  212. }
  213.  
  214. mp_outline(outfd, asheet)
  215.  FILE *outfd;
  216.  struct sheet *asheet;
  217. {
  218.     if (opt_outline) {
  219.         (*asheet->sh_outline)(outfd);
  220.     }
  221. }
  222.  
  223.