10 hereby transferred. |
10 hereby transferred. |
11 " |
11 " |
12 |
12 |
13 PrinterStream subclass:#PostscriptPrinterStream |
13 PrinterStream subclass:#PostscriptPrinterStream |
14 instanceVariableNames:'xPos yPos lineBuffer colNr lineNr fFamily fStyle pageStartAction |
14 instanceVariableNames:'xPos yPos lineBuffer colNr lineNr fFamily fStyle pageStartAction |
15 pageEndAction' |
15 pageEndAction pageCount' |
16 classVariableNames:'Prolog Trailer PageProlog PageTrailer FontNames FontHeight |
16 classVariableNames:'Prolog Trailer PageProlog PageTrailer FontNames FontHeight |
17 FontWidth LeftX TopY PageHeight LinesPerPage PhysicalPageHeight |
17 FontWidth LeftX TopY PageHeight LinesPerPage PhysicalPageHeight |
18 Italic Bold Normal BoldItalic Courier Times Helvetica TopInset |
18 Italic Bold Normal BoldItalic Courier Times Helvetica TopInset |
19 LeftInset BottomInset SupportsColor' |
19 LeftInset BottomInset SupportsColor' |
20 poolDictionaries:'' |
20 poolDictionaries:'' |
270 Helvetica := 0. "/ # of helvetica base font |
270 Helvetica := 0. "/ # of helvetica base font |
271 Times := 4. "/ # of times base font |
271 Times := 4. "/ # of times base font |
272 Courier := 8. "/ # of courier base font |
272 Courier := 8. "/ # of courier base font |
273 |
273 |
274 FontNames := #( |
274 FontNames := #( |
275 '/Helvetica-Oblique' |
275 'Helvetica-Oblique' |
276 '/Helvetica-Bold' |
276 'Helvetica-Bold' |
277 '/Helvetica-BoldOblique' |
277 'Helvetica-BoldOblique' |
278 '/Helvetica' |
278 'Helvetica' |
279 '/Times-Italic' |
279 'Times-Italic' |
280 '/Times-Bold' |
280 'Times-Bold' |
281 '/Times-BoldItalic' |
281 'Times-BoldItalic' |
282 '/Times' |
282 'Times' |
283 '/Courier-Oblique' |
283 'Courier-Oblique' |
284 '/Courier-Bold' |
284 'Courier-Bold' |
285 '/Courier-BoldOblique' |
285 'Courier-BoldOblique' |
286 '/Courier' |
286 'Courier' |
287 ) |
287 ) |
288 |
288 |
289 "Modified: 18.5.1996 / 09:37:48 / cg" |
289 " |
|
290 PostscriptPrinterStream initFonts |
|
291 " |
|
292 |
290 ! |
293 ! |
291 |
294 |
292 initPage |
295 initPage |
293 "setup the page parameters. |
296 "setup the page parameters. |
294 All coordinates are scaled by 20 w.r.t the PS coordinates (i.e. in twips)." |
297 All coordinates are scaled by 20 w.r.t the PS coordinates (i.e. in twips)." |
366 "define the documents prolog" |
369 "define the documents prolog" |
367 |
370 |
368 |tmpString t fontNr| |
371 |tmpString t fontNr| |
369 |
372 |
370 tmpString := |
373 tmpString := |
371 '%!!PS-Adobe-1.0 |
374 '%!!PS-Adobe-2.0 |
372 %%Creator: Smalltalk/X |
375 %%Creator: Smalltalk/X |
373 %%DocumentFonts: Courier-Oblique Courier-Bold Courier Times-Italic Times-Bold Times |
376 %%DocumentFonts: '. |
374 save/SmalltalkJob exch def |
377 |
|
378 FontNames do:[:aName | |
|
379 tmpString := tmpString , aName , ' ' |
|
380 ]. |
|
381 |
|
382 tmpString := tmpString , ' |
|
383 %%Pages: (atend) |
|
384 %%EndComments |
|
385 |
|
386 save /SmalltalkJob exch def |
|
387 |
375 /OriginalState gstate def |
388 /OriginalState gstate def |
376 /StartSmalltalkDoc{$smalltalk begin}def |
389 /StartSmalltalkDoc{$smalltalk begin}def |
377 /$smalltalk 50 dict def $smalltalk begin |
390 /$smalltalk 50 dict def $smalltalk begin |
378 /EndSmalltalkDoc{end}def |
391 /EndSmalltalkDoc{end}def |
|
392 |
379 /S/show load def |
393 /S/show load def |
380 /X{exch 0 rmoveto S}def |
394 /X{exch 0 rmoveto S}def |
381 /Y{exch 0 exch rmoveto S}def |
395 /Y{exch 0 exch rmoveto S}def |
382 /B{3 1 roll moveto S}def |
396 /B{3 1 roll moveto S}def |
383 /SUL {gsave currentpoint currentfont /FontInfo get /UnderlinePosition get |
397 /SUL {gsave currentpoint currentfont /FontInfo get /UnderlinePosition get |
427 % end of fixed prolog |
441 % end of fixed prolog |
428 '. |
442 '. |
429 |
443 |
430 t := ''. |
444 t := ''. |
431 FontNames do:[:aName | |
445 FontNames do:[:aName | |
432 t := t , '/ISO-' , aName , ' ' , aName , ' ISOrecode |
446 t := t , '/ISO-' , aName , ' /' , aName , ' ISOrecode |
433 '. |
447 '. |
434 ]. |
448 ]. |
435 t := t , ' |
449 t := t , ' |
436 '. |
450 '. |
437 tmpString := tmpString , t. |
451 tmpString := tmpString , t. |
439 t := ''. |
453 t := ''. |
440 fontNr := 0. |
454 fontNr := 0. |
441 FontNames do:[:aName | |
455 FontNames do:[:aName | |
442 t := t , (fontNr printString) , ' ' |
456 t := t , (fontNr printString) , ' ' |
443 , (FontHeight printString) , ' ' |
457 , (FontHeight printString) , ' ' |
444 , aName , (Character nl) asString. |
458 , '/ISO-' , aName , (Character nl) asString. |
445 fontNr := fontNr + 1 |
459 fontNr := fontNr + 1 |
446 ]. |
460 ]. |
447 tmpString := tmpString , t. |
461 tmpString := tmpString , t. |
448 tmpString := tmpString , fontNr printString , ' SetUpFonts |
462 tmpString := tmpString , fontNr printString , ' SetUpFonts |
449 |
463 |
450 % end of prolog |
464 % end of prolog |
|
465 %%EndProlog |
451 '. |
466 '. |
452 Prolog := tmpString. |
467 Prolog := tmpString. |
453 |
468 |
454 " |
469 " |
455 PostscriptPrinterStream initProlog |
470 PostscriptPrinterStream initProlog |
660 "Modified: 23.4.1996 / 20:05:59 / cg" |
674 "Modified: 23.4.1996 / 20:05:59 / cg" |
661 ! ! |
675 ! ! |
662 |
676 |
663 !PostscriptPrinterStream methodsFor:'accessing'! |
677 !PostscriptPrinterStream methodsFor:'accessing'! |
664 |
678 |
|
679 pageCount |
|
680 "returns the number of the currently printed page" |
|
681 |
|
682 ^ pageCount |
|
683 |
|
684 "Created: 5.9.1996 / 18:29:23 / cg" |
|
685 ! |
|
686 |
665 pageEndAction:something |
687 pageEndAction:something |
666 "set pageEndAction - if non-nil, that will be called before |
688 "set pageEndAction - if non-nil, that will be called before |
667 and EndPage is emmitted. |
689 and EndPage is emmitted. |
668 An example use is a private block, |
690 An example use is a private block, |
669 which draws a company frame around the page ..." |
691 which draws a company frame around the page ..." |
816 endPrint |
838 endPrint |
817 "finish a document - finish page; then send documentTrailer. |
839 "finish a document - finish page; then send documentTrailer. |
818 Send nothing if nativePrinting." |
840 Send nothing if nativePrinting." |
819 |
841 |
820 native == true ifFalse:[ |
842 native == true ifFalse:[ |
821 self endPage. |
843 self endPage. |
822 super nextPutAllUntranslated:Trailer. |
844 super nextPutAllUntranslated:'%%Pages: ' , pageCount printString. |
|
845 super nextPutUntranslated:(Character cr). |
|
846 super nextPutAllUntranslated:Trailer. |
823 ]. |
847 ]. |
824 super endPrint |
848 super endPrint |
825 |
849 |
826 "Modified: 23.4.1996 / 20:03:26 / cg" |
850 "Modified: 5.9.1996 / 18:35:29 / cg" |
827 ! |
851 ! |
828 |
852 |
829 startPrint |
853 startPrint |
830 "start a document - send documentProlog & start a page. |
854 "start a document - send documentProlog & start a page. |
831 Send nothing if nativePrinting." |
855 Send nothing if nativePrinting." |
|
856 |
|
857 pageCount := 1. |
832 |
858 |
833 fFamily := Courier. |
859 fFamily := Courier. |
834 fStyle := Normal. |
860 fStyle := Normal. |
835 underline := false. |
861 underline := false. |
836 strikeout := false. |
862 strikeout := false. |
837 |
863 |
838 native == true ifFalse:[ |
864 native == true ifFalse:[ |
839 Prolog isNil ifTrue:[ |
865 Prolog isNil ifTrue:[ |
840 self class initialize |
866 self class initialize |
841 ]. |
867 ]. |
842 super writingTo:(self class printCommand). |
868 super writingTo:(self class printCommand). |
843 super nextPutAllUntranslated:Prolog. |
869 super nextPutAllUntranslated:Prolog. |
844 self startPage |
870 self startPage |
845 ] |
871 ] |
846 |
872 |
847 "Modified: 8.6.1996 / 08:16:50 / cg" |
873 "Modified: 5.9.1996 / 18:29:34 / cg" |
848 ! ! |
874 ! ! |
849 |
875 |
850 !PostscriptPrinterStream methodsFor:'private'! |
876 !PostscriptPrinterStream methodsFor:'private'! |
851 |
877 |
852 endPage |
878 endPage |
902 nextPage |
928 nextPage |
903 "new page - finish previous page & start enew. |
929 "new page - finish previous page & start enew. |
904 Should not be sent when nativePrinting." |
930 Should not be sent when nativePrinting." |
905 |
931 |
906 self endPage. |
932 self endPage. |
|
933 |
|
934 pageCount := pageCount + 1. |
907 self startPage |
935 self startPage |
908 |
936 |
909 "Modified: 23.4.1996 / 20:04:07 / cg" |
937 "Modified: 5.9.1996 / 18:30:00 / cg" |
910 ! |
938 ! |
911 |
939 |
912 placeString:aString at:pos |
940 placeString:aString at:pos |
913 "special entry: place a string at some particular position in my ps-coordinate |
941 "special entry: place a string at some particular position in my ps-coordinate |
914 system. Can be used with endPageActions to place a page-number." |
942 system. Can be used with endPageActions to place a page-number." |
940 ! |
968 ! |
941 |
969 |
942 startPage |
970 startPage |
943 "start a page - send pageProlog, reset x/y position and line/col." |
971 "start a page - send pageProlog, reset x/y position and line/col." |
944 |
972 |
|
973 super nextPutAllUntranslated:'%%Page: ' , pageCount printString , ' ' , pageCount printString. |
|
974 super nextPutUntranslated:(Character cr). |
|
975 |
945 pageStartAction notNil ifTrue:[ |
976 pageStartAction notNil ifTrue:[ |
946 pageStartAction value |
977 pageStartAction value |
947 ]. |
978 ]. |
948 super nextPutAllUntranslated:PageProlog. |
979 super nextPutAllUntranslated:PageProlog. |
949 self class landscape ifTrue:[ |
980 self class landscape ifTrue:[ |
950 super nextPutAllUntranslated:'Landscape |
981 super nextPutAllUntranslated:'Landscape |
951 '. |
982 '. |
952 ]. |
983 ]. |
953 |
984 |
954 self setFont. |
985 self setFont. |
955 |
986 |