comparison etc/ps-prin1.ps @ 28980:66e571cf74c6

PostScript code compatibility with other utilities like mpage, psnup, etc. (isLineStep): Code fix. (BeginDoc, BeginSheet): Utility compatibility.
author Gerd Moellmann <gerd@gnu.org>
date Thu, 18 May 2000 21:52:48 +0000
parents 8e8534ef4b0a
children a6ce0d37c2cf
comparison
equal deleted inserted replaced
28979:b6e33b095c08 28980:66e571cf74c6
299 /L0 6 /Times-Italic DefFont 299 /L0 6 /Times-Italic DefFont
300 300
301 % stack: -- |- boolean 301 % stack: -- |- boolean
302 /isLineStep{ 302 /isLineStep{
303 SyncLineZebra 303 SyncLineZebra
304 {PrintLineStep 1 gt 304 {PLScounter 0 gt % or zebra
305 {/PrintLineStep PrintLineStep 1 sub def false} % or inside zebra 305 {/PLScounter PLScounter 1 sub def PLScounter 0 eq}
306 {/PrintLineStep ZebraHeight def true}ifelse} % or 1st zebra line 306 {false}ifelse
307 {LineNumber 1 sub PrintLineStep mod 0 eq}ifelse % or line step 307 PrintLineStep 1 gt
308 {/PrintLineStep PrintLineStep 1 sub def}
309 {/PrintLineStep ZebraHeight def
310 /PLScounter PrintLineStart def}ifelse}
311 {LineNumber PrintLineStart sub PrintLineStep mod 0 eq}ifelse % or line step
308 }def 312 }def
309 313
310 % stack: -- 314 % stack: --
311 /doLineNumber{ 315 /doLineNumber{
312 /LineNumber where 316 /LineNumber where
415 /SpaceWidth /f0 findfont setfont ( ) stringwidth pop def 419 /SpaceWidth /f0 findfont setfont ( ) stringwidth pop def
416 % ---- save the state of the document (useful for ghostscript!) 420 % ---- save the state of the document (useful for ghostscript!)
417 /docState save def 421 /docState save def
418 % ---- [andrewi] set PageSize based on chosen dimensions 422 % ---- [andrewi] set PageSize based on chosen dimensions
419 UseSetpagedevice{ 423 UseSetpagedevice{
420 BMark /PageSize [PageWidth LandscapePageHeight] EMark setpagedevice 424 BMark/PageSize[PageWidth LandscapePageHeight LandscapeMode{exch}if]EMark setpagedevice
421 }{ 425 }if
422 LandscapeMode{ 426 /ColumnWidth PrintWidth InterColumn add def
423 % ---- translate to bottom-right corner of Portrait page 427 % ---- define where printing will start
424 LandscapePageHeight 0 translate 428 /f0 F % this installs Ascent
425 90 rotate 429 /PrintStartY PrintHeight Ascent sub def
430 /ColumnIndex 1 def
431 /N-Up-Counter N-Up-End 1 sub def
432 /PLScounter PrintLineStart def
433 }def
434
435 /EndDoc{
436 % ---- restore the state of the document (useful for ghostscript!)
437 docState restore
438 }def
439
440 /BeginDSCPage{
441 % ---- when 1st column, save the state of the page
442 ColumnIndex 1 eq{
443 /pageState save def
444 }if
445 % ---- save the state of the column
446 /columnState save def
447 }def
448
449 /PrintHeaderWidth PrintOnlyOneHeader{PrintPageWidth}{PrintWidth}ifelse def
450
451 /BeginPage{
452 % ---- when 1st column, print all background effects
453 ColumnIndex 1 eq{
454 0 PrintStartY moveto % move to where printing will start
455 printBackground
456 Zebra {printZebra}if
457 printGlobalBackground
458 printLocalBackground
459 }if
460 PrintHeader{
461 PrintOnlyOneHeader{ColumnIndex 1 eq}{true}ifelse{
462 PrintHeaderFrame{HeaderFrame}if
463 HeaderText
426 }if 464 }if
465 }if
466 0 PrintStartY moveto % move to where printing will start
467 PLN
468 }def
469
470 /EndPage{bg{eolbg}if}def
471
472 /EndDSCPage{
473 ColumnIndex NumberOfColumns eq{
474 % ---- restore the state of the page
475 pageState restore
476 /ColumnIndex 1 def
477 % ---- N-up printing
478 N-Up 1 gt{
479 N-Up-Counter 0 gt{
480 % ---- Next page on same row
481 /N-Up-Counter N-Up-Counter 1 sub def
482 N-Up-XColumn N-Up-YColumn
483 }{
484 % ---- Next page on next line
485 /N-Up-Counter N-Up-End 1 sub def
486 N-Up-XLine N-Up-YLine
487 }ifelse
488 translate
489 }if
490 }{ % else
491 % ---- restore the state of the current column
492 columnState restore
493 % ---- and translate to the next column
494 ColumnWidth 0 translate
495 /ColumnIndex ColumnIndex 1 add def
427 }ifelse 496 }ifelse
497 }def
498
499 % stack: number-of-pages-per-sheet |- --
500 /BeginSheet{
501 /sheetState save def
502 /pages-per-sheet exch def
503
504 % ---- translate to bottom-right corner of Portrait page
505 LandscapeMode{
506 LandscapePageHeight 0 translate
507 90 rotate
508 }if
428 % ---- [jack] Kludge: my ghostscript window is 21x27.7 instead of 21x29.7 509 % ---- [jack] Kludge: my ghostscript window is 21x27.7 instead of 21x29.7
429 /JackGhostscript where{pop 1 27.7 29.7 div scale}if 510 /JackGhostscript where{pop 1 27.7 29.7 div scale}if
430 UpsideDown{PageWidth LandscapePageHeight translate 180 rotate}if 511 UpsideDown{PageWidth LandscapePageHeight translate 180 rotate}if
431 % ---- N-Up printing 512 % ---- N-Up printing
432 N-Up 1 gt{ 513 N-Up 1 gt{
449 {N-Up-Lines div HH}{N-Up-Columns N-Up-Missing add div WW}ifelse 530 {N-Up-Lines div HH}{N-Up-Columns N-Up-Missing add div WW}ifelse
450 div dup scale 531 div dup scale
451 0 N-Up-Repeat 1 sub LandscapePageHeight mul translate 532 0 N-Up-Repeat 1 sub LandscapePageHeight mul translate
452 % ---- go to start position in page matrix 533 % ---- go to start position in page matrix
453 N-Up-XStart N-Up-Missing 0.5 mul 534 N-Up-XStart N-Up-Missing 0.5 mul
454 LandscapeMode{ 535 LandscapeMode
455 LandscapePageHeight mul N-Up-YStart add 536 {LandscapePageHeight mul N-Up-YStart add}
456 }{ 537 {PageWidth mul add N-Up-YStart}ifelse
457 PageWidth mul add N-Up-YStart
458 }ifelse
459 translate 538 translate
460 }if 539 }if
461 /ColumnWidth PrintWidth InterColumn add def
462 % ---- translate to lower left corner of TEXT 540 % ---- translate to lower left corner of TEXT
463 LeftMargin BottomMargin translate 541 LeftMargin BottomMargin translate
464 % ---- define where printing will start 542
465 /f0 F % this installs Ascent
466 /PrintStartY PrintHeight Ascent sub def
467 /ColumnIndex 1 def
468 /N-Up-Counter N-Up-End 1 sub def
469 }def
470
471 /EndDoc{
472 % ---- restore the state of the document (useful for ghostscript!)
473 docState restore
474 }def
475
476 /BeginDSCPage{
477 % ---- when 1st column, save the state of the page
478 ColumnIndex 1 eq{
479 /pageState save def
480 }if
481 % ---- save the state of the column
482 /columnState save def
483 }def
484
485 /PrintHeaderWidth PrintOnlyOneHeader{PrintPageWidth}{PrintWidth}ifelse def
486
487 /BeginPage{
488 % ---- when 1st column, print all background effects
489 ColumnIndex 1 eq{
490 0 PrintStartY moveto % move to where printing will start
491 printBackground
492 Zebra {printZebra}if
493 printGlobalBackground
494 printLocalBackground
495 }if
496 PrintHeader{
497 PrintOnlyOneHeader{ColumnIndex 1 eq}{true}ifelse{
498 PrintHeaderFrame{HeaderFrame}if
499 HeaderText
500 }if
501 }if
502 0 PrintStartY moveto % move to where printing will start
503 PLN
504 }def
505
506 /EndPage{bg{eolbg}if}def
507
508 /EndDSCPage{
509 ColumnIndex NumberOfColumns eq{
510 % ---- restore the state of the page
511 pageState restore
512 /ColumnIndex 1 def
513 % ---- N-up printing
514 N-Up 1 gt{
515 N-Up-Counter 0 gt{
516 % ---- Next page on same row
517 /N-Up-Counter N-Up-Counter 1 sub def
518 N-Up-XColumn N-Up-YColumn
519 }{
520 % ---- Next page on next line
521 /N-Up-Counter N-Up-End 1 sub def
522 N-Up-XLine N-Up-YLine
523 }ifelse
524 translate
525 }if
526 }{ % else
527 % ---- restore the state of the current column
528 columnState restore
529 % ---- and translate to the next column
530 ColumnWidth 0 translate
531 /ColumnIndex ColumnIndex 1 add def
532 }ifelse
533 }def
534
535 % stack: number-of-pages-per-sheet |- --
536 /BeginSheet{
537 /sheetState save def
538 /pages-per-sheet exch def
539 % ---- N-up printing 543 % ---- N-up printing
540 N-Up 1 gt N-Up-Border and pages-per-sheet 0 gt and{ 544 N-Up 1 gt N-Up-Border and pages-per-sheet 0 gt and{
541 % ---- page border 545 % ---- page border
542 gsave 546 gsave
543 0 setgray 547 0 setgray