Imported Upstream version 0.1
Didier Raboud
12 years ago
0 | ||
1 | rastertosag-gdi | |
2 | --------------- | |
3 | ||
4 | A printer driver for the Ricoh Aficio SP 1000S and SP 1100S | |
5 | ||
6 | Created by palz <paalzza@gmail.com> in Feb 2011, Moscow, Russia | |
7 | ||
8 | License: GPL | |
9 | ||
10 | CUPS raster filter for Ricoh Aficio SP 1000S and SP 1100S. These | |
11 | printers use the SAG-GDI raster format by Sagem Communication and do | |
12 | not understand PCL or PostScript like most other Ricoh laser | |
13 | printers. If you find any other Ricoh printer working with this driver | |
14 | please tell. | |
15 | ||
16 | The SAG-GDI protocol is described here: | |
17 | http://www.undocprint.org/formats/page_description_languages/sagem-gdi | |
18 | ||
19 | Initial presentation of this driver: | |
20 | http://forums.linux-foundation.org/read.php?30,13489,13557 | |
21 | ||
22 | ||
23 | Installation: | |
24 | ||
25 | CUPS and Python are needed on your system. Linux distributions have | |
26 | this usually included. | |
27 | ||
28 | If you have CUPS 1.4.x or newer run the following commands as root: | |
29 | ||
30 | cp rastertosag-gdi /usr/lib/cups/filter/ | |
31 | chmod 755 /usr/lib/cups/filter/rastertosag-gdi | |
32 | cp rastertosag-gdi.drv /usr/share/cups/drv/ | |
33 | chmod 644 /usr/share/cups/drv/rastertosag-gdi.drv | |
34 | ||
35 | If you have CUPS 1.3.x or older run the following commands as root: | |
36 | ||
37 | cp rastertosag-gdi /usr/lib/cups/filter/ | |
38 | chmod 755 /usr/lib/cups/filter/rastertosag-gdi | |
39 | cp ppd/*.ppd /usr/share/cups/model/ | |
40 | chmod 644 /usr/share/cups/model/rsp1?00s.ppd | |
41 | killall -HUP cupsd | |
42 | ||
43 | After that, set up your printer with the usual tools. Often it is | |
44 | enough to simply plug in the printer on USB and turn it on. Then a | |
45 | print queue with the newly installed driver will get set up | |
46 | automatically. If not, or if the printer is connected via the network, | |
47 | use the distribution's printer setup tool or the web interface of CUPS | |
48 | (http://localhost:631/). |
0 | *PPD-Adobe: "4.3" | |
1 | *%%%% PPD file for Ricoh Aficio SP 1000S with CUPS. | |
2 | *%%%% Created by the CUPS PPD Compiler CUPS v1.4.6. | |
3 | *FormatVersion: "4.3" | |
4 | *FileVersion: "1.0" | |
5 | *LanguageVersion: English | |
6 | *LanguageEncoding: ISOLatin1 | |
7 | *PCFileName: "rsp1000s.ppd" | |
8 | *Product: "(Ricoh Aficio SP 1000S)" | |
9 | *Manufacturer: "Ricoh" | |
10 | *ModelName: "Ricoh Aficio SP 1000S" | |
11 | *ShortNickName: "Ricoh Aficio SP 1000S" | |
12 | *NickName: "Ricoh Aficio SP 1000S, rastertosag-gdi 1.0" | |
13 | *PSVersion: "(3010.000) 0" | |
14 | *LanguageLevel: "3" | |
15 | *ColorDevice: False | |
16 | *DefaultColorSpace: Gray | |
17 | *FileSystem: False | |
18 | *Throughput: "1" | |
19 | *LandscapeOrientation: Plus90 | |
20 | *TTRasterizer: Type42 | |
21 | *% Driver-defined attributes... | |
22 | *1284DeviceID: "MFG:MFPrinter ;MDL:Laser Pro LL;CMD:AUTOMATIC,PJL,GDI_RL;DES:MFPrinter Laser Pro LL;CLS:PRINTER;VER:v1.03e ;NS:L507124L8090042;" | |
23 | *cupsVersion: 1.4 | |
24 | *cupsModelNumber: 0 | |
25 | *cupsManualCopies: False | |
26 | *cupsFilter: "application/vnd.cups-raster 100 rastertosag-gdi" | |
27 | *cupsLanguages: "en" | |
28 | *OpenUI *PageSize/Media Size: PickOne | |
29 | *OrderDependency: 10 AnySetup *PageSize | |
30 | *DefaultPageSize: A4 | |
31 | *PageSize A4/A4: "<</PageSize[595 842]/ImagingBBox null>>setpagedevice" | |
32 | *PageSize A5/A5: "<</PageSize[420 595]/ImagingBBox null>>setpagedevice" | |
33 | *PageSize A6/A6: "<</PageSize[297 420]/ImagingBBox null>>setpagedevice" | |
34 | *PageSize Letter/US Letter: "<</PageSize[612 792]/ImagingBBox null>>setpagedevice" | |
35 | *PageSize Legal/US Legal: "<</PageSize[612 1008]/ImagingBBox null>>setpagedevice" | |
36 | *PageSize B5/B5: "<</PageSize[516 729]/ImagingBBox null>>setpagedevice" | |
37 | *PageSize B6/B6: "<</PageSize[363 516]/ImagingBBox null>>setpagedevice" | |
38 | *PageSize Monarch/Monarch: "<</PageSize[279 540]/ImagingBBox null>>setpagedevice" | |
39 | *CloseUI: *PageSize | |
40 | *OpenUI *PageRegion/Media Size: PickOne | |
41 | *OrderDependency: 10 AnySetup *PageRegion | |
42 | *DefaultPageRegion: A4 | |
43 | *PageRegion A4/A4: "<</PageSize[595 842]/ImagingBBox null>>setpagedevice" | |
44 | *PageRegion A5/A5: "<</PageSize[420 595]/ImagingBBox null>>setpagedevice" | |
45 | *PageRegion A6/A6: "<</PageSize[297 420]/ImagingBBox null>>setpagedevice" | |
46 | *PageRegion Letter/US Letter: "<</PageSize[612 792]/ImagingBBox null>>setpagedevice" | |
47 | *PageRegion Legal/US Legal: "<</PageSize[612 1008]/ImagingBBox null>>setpagedevice" | |
48 | *PageRegion B5/B5: "<</PageSize[516 729]/ImagingBBox null>>setpagedevice" | |
49 | *PageRegion B6/B6: "<</PageSize[363 516]/ImagingBBox null>>setpagedevice" | |
50 | *PageRegion Monarch/Monarch: "<</PageSize[279 540]/ImagingBBox null>>setpagedevice" | |
51 | *CloseUI: *PageRegion | |
52 | *DefaultImageableArea: A4 | |
53 | *ImageableArea A4/A4: "12 12 583 830" | |
54 | *ImageableArea A5/A5: "12 12 408 583" | |
55 | *ImageableArea A6/A6: "12 12 285 408" | |
56 | *ImageableArea Letter/US Letter: "12 12 600 780" | |
57 | *ImageableArea Legal/US Legal: "12 12 600 996" | |
58 | *ImageableArea B5/B5: "12 12 504 717" | |
59 | *ImageableArea B6/B6: "12 12 351 504" | |
60 | *ImageableArea Monarch/Monarch: "12 12 267 528" | |
61 | *DefaultPaperDimension: A4 | |
62 | *PaperDimension A4/A4: "595 842" | |
63 | *PaperDimension A5/A5: "420 595" | |
64 | *PaperDimension A6/A6: "297 420" | |
65 | *PaperDimension Letter/US Letter: "612 792" | |
66 | *PaperDimension Legal/US Legal: "612 1008" | |
67 | *PaperDimension B5/B5: "516 729" | |
68 | *PaperDimension B6/B6: "363 516" | |
69 | *PaperDimension Monarch/Monarch: "279 540" | |
70 | *OpenUI *MediaType/Media Type: PickOne | |
71 | *OrderDependency: 10 AnySetup *MediaType | |
72 | *DefaultMediaType: Auto | |
73 | *MediaType Auto/Auto: "<</MediaType(Auto)/cupsMediaType 0>>setpagedevice" | |
74 | *MediaType Heavyweight/Heavyweight: "<</MediaType(Heavyweight)/cupsMediaType 3>>setpagedevice" | |
75 | *CloseUI: *MediaType | |
76 | *OpenUI *InputSlot/Media Source: PickOne | |
77 | *OrderDependency: 10 AnySetup *InputSlot | |
78 | *DefaultInputSlot: Auto | |
79 | *InputSlot Auto/Auto: "<</MediaPosition 0>>setpagedevice" | |
80 | *InputSlot Automatic/Automatic Tray: "<</MediaPosition 1>>setpagedevice" | |
81 | *InputSlot Manual/Manual Tray: "<</MediaPosition 3>>setpagedevice" | |
82 | *CloseUI: *InputSlot | |
83 | *OpenUI *Resolution/Resolution: PickOne | |
84 | *OrderDependency: 10 AnySetup *Resolution | |
85 | *DefaultResolution: 600dpi | |
86 | *Resolution 600dpi/600 DPI: "<</HWResolution[600 600]/cupsBitsPerColor 1/cupsRowCount 0/cupsRowFeed 0/cupsRowStep 0/cupsColorSpace 3>>setpagedevice" | |
87 | *CloseUI: *Resolution | |
88 | *DefaultFont: Courier | |
89 | *Font AvantGarde-Book: Standard "(1.05)" Standard ROM | |
90 | *Font AvantGarde-BookOblique: Standard "(1.05)" Standard ROM | |
91 | *Font AvantGarde-Demi: Standard "(1.05)" Standard ROM | |
92 | *Font AvantGarde-DemiOblique: Standard "(1.05)" Standard ROM | |
93 | *Font Bookman-Demi: Standard "(1.05)" Standard ROM | |
94 | *Font Bookman-DemiItalic: Standard "(1.05)" Standard ROM | |
95 | *Font Bookman-Light: Standard "(1.05)" Standard ROM | |
96 | *Font Bookman-LightItalic: Standard "(1.05)" Standard ROM | |
97 | *Font Courier: Standard "(1.05)" Standard ROM | |
98 | *Font Courier-Bold: Standard "(1.05)" Standard ROM | |
99 | *Font Courier-BoldOblique: Standard "(1.05)" Standard ROM | |
100 | *Font Courier-Oblique: Standard "(1.05)" Standard ROM | |
101 | *Font Helvetica: Standard "(1.05)" Standard ROM | |
102 | *Font Helvetica-Bold: Standard "(1.05)" Standard ROM | |
103 | *Font Helvetica-BoldOblique: Standard "(1.05)" Standard ROM | |
104 | *Font Helvetica-Narrow: Standard "(1.05)" Standard ROM | |
105 | *Font Helvetica-Narrow-Bold: Standard "(1.05)" Standard ROM | |
106 | *Font Helvetica-Narrow-BoldOblique: Standard "(1.05)" Standard ROM | |
107 | *Font Helvetica-Narrow-Oblique: Standard "(1.05)" Standard ROM | |
108 | *Font Helvetica-Oblique: Standard "(1.05)" Standard ROM | |
109 | *Font NewCenturySchlbk-Bold: Standard "(1.05)" Standard ROM | |
110 | *Font NewCenturySchlbk-BoldItalic: Standard "(1.05)" Standard ROM | |
111 | *Font NewCenturySchlbk-Italic: Standard "(1.05)" Standard ROM | |
112 | *Font NewCenturySchlbk-Roman: Standard "(1.05)" Standard ROM | |
113 | *Font Palatino-Bold: Standard "(1.05)" Standard ROM | |
114 | *Font Palatino-BoldItalic: Standard "(1.05)" Standard ROM | |
115 | *Font Palatino-Italic: Standard "(1.05)" Standard ROM | |
116 | *Font Palatino-Roman: Standard "(1.05)" Standard ROM | |
117 | *Font Symbol: Special "(001.005)" Special ROM | |
118 | *Font Times-Bold: Standard "(1.05)" Standard ROM | |
119 | *Font Times-BoldItalic: Standard "(1.05)" Standard ROM | |
120 | *Font Times-Italic: Standard "(1.05)" Standard ROM | |
121 | *Font Times-Roman: Standard "(1.05)" Standard ROM | |
122 | *Font ZapfChancery-MediumItalic: Standard "(1.05)" Standard ROM | |
123 | *Font ZapfDingbats: Special "(001.005)" Special ROM | |
124 | *% End of rsp1000s.ppd, 06010 bytes. |
0 | *PPD-Adobe: "4.3" | |
1 | *%%%% PPD file for Ricoh Aficio SP 1100S with CUPS. | |
2 | *%%%% Created by the CUPS PPD Compiler CUPS v1.4.6. | |
3 | *FormatVersion: "4.3" | |
4 | *FileVersion: "1.0" | |
5 | *LanguageVersion: English | |
6 | *LanguageEncoding: ISOLatin1 | |
7 | *PCFileName: "rsp1100s.ppd" | |
8 | *Product: "(Ricoh Aficio SP 1100S)" | |
9 | *Manufacturer: "Ricoh" | |
10 | *ModelName: "Ricoh Aficio SP 1100S" | |
11 | *ShortNickName: "Ricoh Aficio SP 1100S" | |
12 | *NickName: "Ricoh Aficio SP 1100S, rastertosag-gdi 1.0" | |
13 | *PSVersion: "(3010.000) 0" | |
14 | *LanguageLevel: "3" | |
15 | *ColorDevice: False | |
16 | *DefaultColorSpace: Gray | |
17 | *FileSystem: False | |
18 | *Throughput: "1" | |
19 | *LandscapeOrientation: Plus90 | |
20 | *TTRasterizer: Type42 | |
21 | *% Driver-defined attributes... | |
22 | *1284DeviceID: "MFG:MFPrinter;MDL: Laser Pro LL2 1;CMD:AUTOMATIC,PJL,GDI_RL;DES:MFPrinter Laser Pro LL2 1;CLS:PRINTER;VER:v2.07g ;NS:L510245LA020328;" | |
23 | *cupsVersion: 1.4 | |
24 | *cupsModelNumber: 0 | |
25 | *cupsManualCopies: False | |
26 | *cupsFilter: "application/vnd.cups-raster 100 rastertosag-gdi" | |
27 | *cupsLanguages: "en" | |
28 | *OpenUI *PageSize/Media Size: PickOne | |
29 | *OrderDependency: 10 AnySetup *PageSize | |
30 | *DefaultPageSize: A4 | |
31 | *PageSize A4/A4: "<</PageSize[595 842]/ImagingBBox null>>setpagedevice" | |
32 | *PageSize A5/A5: "<</PageSize[420 595]/ImagingBBox null>>setpagedevice" | |
33 | *PageSize A6/A6: "<</PageSize[297 420]/ImagingBBox null>>setpagedevice" | |
34 | *PageSize Letter/US Letter: "<</PageSize[612 792]/ImagingBBox null>>setpagedevice" | |
35 | *PageSize Legal/US Legal: "<</PageSize[612 1008]/ImagingBBox null>>setpagedevice" | |
36 | *PageSize B5/B5: "<</PageSize[516 729]/ImagingBBox null>>setpagedevice" | |
37 | *PageSize B6/B6: "<</PageSize[363 516]/ImagingBBox null>>setpagedevice" | |
38 | *PageSize Monarch/Monarch: "<</PageSize[279 540]/ImagingBBox null>>setpagedevice" | |
39 | *CloseUI: *PageSize | |
40 | *OpenUI *PageRegion/Media Size: PickOne | |
41 | *OrderDependency: 10 AnySetup *PageRegion | |
42 | *DefaultPageRegion: A4 | |
43 | *PageRegion A4/A4: "<</PageSize[595 842]/ImagingBBox null>>setpagedevice" | |
44 | *PageRegion A5/A5: "<</PageSize[420 595]/ImagingBBox null>>setpagedevice" | |
45 | *PageRegion A6/A6: "<</PageSize[297 420]/ImagingBBox null>>setpagedevice" | |
46 | *PageRegion Letter/US Letter: "<</PageSize[612 792]/ImagingBBox null>>setpagedevice" | |
47 | *PageRegion Legal/US Legal: "<</PageSize[612 1008]/ImagingBBox null>>setpagedevice" | |
48 | *PageRegion B5/B5: "<</PageSize[516 729]/ImagingBBox null>>setpagedevice" | |
49 | *PageRegion B6/B6: "<</PageSize[363 516]/ImagingBBox null>>setpagedevice" | |
50 | *PageRegion Monarch/Monarch: "<</PageSize[279 540]/ImagingBBox null>>setpagedevice" | |
51 | *CloseUI: *PageRegion | |
52 | *DefaultImageableArea: A4 | |
53 | *ImageableArea A4/A4: "12 12 583 830" | |
54 | *ImageableArea A5/A5: "12 12 408 583" | |
55 | *ImageableArea A6/A6: "12 12 285 408" | |
56 | *ImageableArea Letter/US Letter: "12 12 600 780" | |
57 | *ImageableArea Legal/US Legal: "12 12 600 996" | |
58 | *ImageableArea B5/B5: "12 12 504 717" | |
59 | *ImageableArea B6/B6: "12 12 351 504" | |
60 | *ImageableArea Monarch/Monarch: "12 12 267 528" | |
61 | *DefaultPaperDimension: A4 | |
62 | *PaperDimension A4/A4: "595 842" | |
63 | *PaperDimension A5/A5: "420 595" | |
64 | *PaperDimension A6/A6: "297 420" | |
65 | *PaperDimension Letter/US Letter: "612 792" | |
66 | *PaperDimension Legal/US Legal: "612 1008" | |
67 | *PaperDimension B5/B5: "516 729" | |
68 | *PaperDimension B6/B6: "363 516" | |
69 | *PaperDimension Monarch/Monarch: "279 540" | |
70 | *OpenUI *MediaType/Media Type: PickOne | |
71 | *OrderDependency: 10 AnySetup *MediaType | |
72 | *DefaultMediaType: Auto | |
73 | *MediaType Auto/Auto: "<</MediaType(Auto)/cupsMediaType 0>>setpagedevice" | |
74 | *MediaType Heavyweight/Heavyweight: "<</MediaType(Heavyweight)/cupsMediaType 3>>setpagedevice" | |
75 | *CloseUI: *MediaType | |
76 | *OpenUI *InputSlot/Media Source: PickOne | |
77 | *OrderDependency: 10 AnySetup *InputSlot | |
78 | *DefaultInputSlot: Auto | |
79 | *InputSlot Auto/Auto: "<</MediaPosition 0>>setpagedevice" | |
80 | *InputSlot Automatic/Automatic Tray: "<</MediaPosition 1>>setpagedevice" | |
81 | *InputSlot Manual/Manual Tray: "<</MediaPosition 3>>setpagedevice" | |
82 | *CloseUI: *InputSlot | |
83 | *OpenUI *Resolution/Resolution: PickOne | |
84 | *OrderDependency: 10 AnySetup *Resolution | |
85 | *DefaultResolution: 600dpi | |
86 | *Resolution 600dpi/600 DPI: "<</HWResolution[600 600]/cupsBitsPerColor 1/cupsRowCount 0/cupsRowFeed 0/cupsRowStep 0/cupsColorSpace 3>>setpagedevice" | |
87 | *CloseUI: *Resolution | |
88 | *DefaultFont: Courier | |
89 | *Font AvantGarde-Book: Standard "(1.05)" Standard ROM | |
90 | *Font AvantGarde-BookOblique: Standard "(1.05)" Standard ROM | |
91 | *Font AvantGarde-Demi: Standard "(1.05)" Standard ROM | |
92 | *Font AvantGarde-DemiOblique: Standard "(1.05)" Standard ROM | |
93 | *Font Bookman-Demi: Standard "(1.05)" Standard ROM | |
94 | *Font Bookman-DemiItalic: Standard "(1.05)" Standard ROM | |
95 | *Font Bookman-Light: Standard "(1.05)" Standard ROM | |
96 | *Font Bookman-LightItalic: Standard "(1.05)" Standard ROM | |
97 | *Font Courier: Standard "(1.05)" Standard ROM | |
98 | *Font Courier-Bold: Standard "(1.05)" Standard ROM | |
99 | *Font Courier-BoldOblique: Standard "(1.05)" Standard ROM | |
100 | *Font Courier-Oblique: Standard "(1.05)" Standard ROM | |
101 | *Font Helvetica: Standard "(1.05)" Standard ROM | |
102 | *Font Helvetica-Bold: Standard "(1.05)" Standard ROM | |
103 | *Font Helvetica-BoldOblique: Standard "(1.05)" Standard ROM | |
104 | *Font Helvetica-Narrow: Standard "(1.05)" Standard ROM | |
105 | *Font Helvetica-Narrow-Bold: Standard "(1.05)" Standard ROM | |
106 | *Font Helvetica-Narrow-BoldOblique: Standard "(1.05)" Standard ROM | |
107 | *Font Helvetica-Narrow-Oblique: Standard "(1.05)" Standard ROM | |
108 | *Font Helvetica-Oblique: Standard "(1.05)" Standard ROM | |
109 | *Font NewCenturySchlbk-Bold: Standard "(1.05)" Standard ROM | |
110 | *Font NewCenturySchlbk-BoldItalic: Standard "(1.05)" Standard ROM | |
111 | *Font NewCenturySchlbk-Italic: Standard "(1.05)" Standard ROM | |
112 | *Font NewCenturySchlbk-Roman: Standard "(1.05)" Standard ROM | |
113 | *Font Palatino-Bold: Standard "(1.05)" Standard ROM | |
114 | *Font Palatino-BoldItalic: Standard "(1.05)" Standard ROM | |
115 | *Font Palatino-Italic: Standard "(1.05)" Standard ROM | |
116 | *Font Palatino-Roman: Standard "(1.05)" Standard ROM | |
117 | *Font Symbol: Special "(001.005)" Special ROM | |
118 | *Font Times-Bold: Standard "(1.05)" Standard ROM | |
119 | *Font Times-BoldItalic: Standard "(1.05)" Standard ROM | |
120 | *Font Times-Italic: Standard "(1.05)" Standard ROM | |
121 | *Font Times-Roman: Standard "(1.05)" Standard ROM | |
122 | *Font ZapfChancery-MediumItalic: Standard "(1.05)" Standard ROM | |
123 | *Font ZapfDingbats: Special "(001.005)" Special ROM | |
124 | *% End of rsp1100s.ppd, 06016 bytes. |
0 | #!/usr/bin/python -u | |
1 | #coding=utf8 | |
2 | ||
3 | # CUPS raster filter for Ricoh Aficio SP1000s | |
4 | # this printer uses SAG-GDI raster format by Sagem Communication | |
5 | # licence: GPL | |
6 | # created by palz <paalzza@gmail.com> | |
7 | # Feb 2011, Moscow, Russia | |
8 | ||
9 | from struct import * | |
10 | import sys | |
11 | from time import time | |
12 | ||
13 | # parse command-line parameters | |
14 | if len(sys.argv)<6: | |
15 | exit(1) | |
16 | jobid = sys.argv[1] | |
17 | username = sys.argv[2] | |
18 | jobtitle = sys.argv[3] | |
19 | try: | |
20 | numcopies = int(sys.argv[4]) | |
21 | except: | |
22 | numcopies = 1 | |
23 | options = sys.argv[5] | |
24 | filename='-' | |
25 | if len(sys.argv)>6: | |
26 | filename=sys.argv[6] | |
27 | if filename=='.' or filename=='-': | |
28 | input=sys.stdin | |
29 | else: | |
30 | input = open(sys.argv[6],'r') | |
31 | output = sys.stdout | |
32 | ||
33 | def print_stderr(s,newline=True): | |
34 | sys.stderr.write(str(s)+('\n' if newline else '')) | |
35 | sys.stderr.flush() | |
36 | ||
37 | #interpret data from CUPS format version 3 supplied via stdin | |
38 | cups = input.read() # Read all bytes from stdin | |
39 | ||
40 | sync_word=cups[0:4] # length of sync-word is 4 bytes: "3SaR" | |
41 | version=int(cups[0]) | |
42 | cups=cups[4:] | |
43 | ||
44 | dtype={ | |
45 | 'C String': {'b': 's','size': 1}, | |
46 | 'Unsigned Integer': {'b': 'I','size': 4}, | |
47 | 'IEEE Single Precision': {'b': 'f','size': 4}, | |
48 | } | |
49 | ||
50 | header_length={ # length of page header | |
51 | 1: 420, | |
52 | 2: 1796, | |
53 | 3: 1796, | |
54 | } | |
55 | ||
56 | def make_unpack_format(format,begin,end,split_count=1): | |
57 | return '<'+(str((end-begin+1)/dtype[format]['size']/split_count)+dtype[format]['b'])*split_count | |
58 | ||
59 | hdr={ | |
60 | 1: {}, # version 1 header | |
61 | 2: {}, # version 2-3 header | |
62 | } | |
63 | def unpack_header(cups,version): | |
64 | # unpack v1 page header | |
65 | hdr[1]['MediaClass'], = unpack(make_unpack_format('C String',0,63),cups[0:63+1]) # Media class string | |
66 | hdr[1]['MediaColor'], = unpack(make_unpack_format('C String',64,127),cups[64:127+1]) # Media color string | |
67 | hdr[1]['MediaType'], = unpack(make_unpack_format('C String',128,191),cups[128:191+1]) # Media type string | |
68 | hdr[1]['OutputType'], = unpack(make_unpack_format('C String',192,255),cups[192:255+1]) # Output type string | |
69 | hdr[1]['AdvanceDistance'], = unpack(make_unpack_format('Unsigned Integer',256,259),cups[256:259+1]) # 0 to 2<sup>32</sup> - 1 points | |
70 | hdr[1]['AdvanceMedia'], = unpack(make_unpack_format('Unsigned Integer',260,263),cups[260:263+1]) # 0 = Never advance roll; 1 = Advance roll after file; 2 = Advance roll after job; 3 = Advance roll after set; 4 = Advance roll after page | |
71 | hdr[1]['Collate'], = unpack(make_unpack_format('Unsigned Integer',264,267),cups[264:267+1]) # 0 = do not collate copies; 1 = collate copies | |
72 | hdr[1]['CutMedia'], = unpack(make_unpack_format('Unsigned Integer',268,271),cups[268:271+1]) # 0 = Never cut media; 1 = Cut roll after file; 2 = Cut roll after job; 3 = Cut roll after set; 4 = Cut roll after page | |
73 | hdr[1]['Duplex'], = unpack(make_unpack_format('Unsigned Integer',272,275),cups[272:275+1]) # 0 = Print single-sided; 1 = Print double-sided | |
74 | hdr[1]['HWResolution'] = unpack(make_unpack_format('Unsigned Integer',276,283),cups[276:283+1]) # Horizontal and vertical resolution in dots-per-inch. | |
75 | hdr[1]['ImagingBoundingBox'] = unpack(make_unpack_format('Unsigned Integer',284,299),cups[284:299+1]) # Four integers giving the left, bottom, right, and top positions of the page bounding box in points | |
76 | hdr[1]['InsertSheet'], = unpack(make_unpack_format('Unsigned Integer',300,303),cups[300:303+1]) # 0 = Do not insert separator sheets; 1 = Insert separator sheets | |
77 | hdr[1]['Jog'], = unpack(make_unpack_format('Unsigned Integer',304,307),cups[304:307+1]) # 0 = Do no jog pages; 1 = Jog pages after file; 2 = Jog pages after job; 3 = Jog pages after set | |
78 | hdr[1]['LeadingEdge'], = unpack(make_unpack_format('Unsigned Integer',308,311),cups[308:311+1]) # 0 = Top edge is first; 1 = Right edge is first; 2 = Bottom edge is first; 3 = Left edge is first | |
79 | hdr[1]['Margins'] = unpack(make_unpack_format('Unsigned Integer',312,319),cups[312:319+1]) # Left and bottom origin of image in points | |
80 | hdr[1]['ManualFeed'], = unpack(make_unpack_format('Unsigned Integer',320,323),cups[320:323+1]) # 0 = Do not manually feed media; 1 = Manually feed media | |
81 | hdr[1]['MediaPosition'], = unpack(make_unpack_format('Unsigned Integer',324,327),cups[324:327+1]) # Input slot position from 0 to N | |
82 | hdr[1]['MediaWeight'], = unpack(make_unpack_format('Unsigned Integer',328,331),cups[328:331+1]) # Media weight in grams per meter squared, 0 = printer default | |
83 | hdr[1]['MirrorPrint'], = unpack(make_unpack_format('Unsigned Integer',332,335),cups[332:335+1]) # 0 = Do not mirror prints; 1 = Mirror prints | |
84 | hdr[1]['NegativePrint'], = unpack(make_unpack_format('Unsigned Integer',336,339),cups[336:339+1]) # 0 = Do not invert prints; 1 = Invert prints | |
85 | hdr[1]['NumCopies'], = unpack(make_unpack_format('Unsigned Integer',340,343),cups[340:343+1]) # 0 to 2<sup>32</sup> - 1, 0 = printer default | |
86 | hdr[1]['Orientation'], = unpack(make_unpack_format('Unsigned Integer',344,347),cups[344:347+1]) # 0 = Do not rotate page; 1 = Rotate page counter-clockwise; 2 = Turn page upside down; 3 = Rotate page clockwise | |
87 | hdr[1]['OutputFaceUp'], = unpack(make_unpack_format('Unsigned Integer',348,351),cups[348:351+1]) # 0 = Output face down; 1 = Output face up | |
88 | hdr[1]['PageSize'] = unpack(make_unpack_format('Unsigned Integer',352,359),cups[352:359+1]) # Width and length in points | |
89 | hdr[1]['Separations'], = unpack(make_unpack_format('Unsigned Integer',360,363),cups[360:363+1]) # 0 = Print composite image; 1 = Print color separations | |
90 | hdr[1]['TraySwitch'], = unpack(make_unpack_format('Unsigned Integer',364,367),cups[364:367+1]) # 0 = Do not change trays if selected tray is empty; 1 = Change trays if selected tray is empty | |
91 | hdr[1]['Tumble'], = unpack(make_unpack_format('Unsigned Integer',368,371),cups[368:371+1]) # 0 = Do not rotate even pages when duplexing; 1 = Rotate even pages when duplexing | |
92 | hdr[1]['cupsWidth'], = unpack(make_unpack_format('Unsigned Integer',372,375),cups[372:375+1]) # Width of page image in pixels | |
93 | hdr[1]['cupsHeight'], = unpack(make_unpack_format('Unsigned Integer',376,379),cups[376:379+1]) # Height of page image in pixels | |
94 | hdr[1]['cupsMediaType'], = unpack(make_unpack_format('Unsigned Integer',380,383),cups[380:383+1]) # Driver-specific 0 to 2<sup>32</sup> - 1 | |
95 | hdr[1]['cupsBitsPerColor'], = unpack(make_unpack_format('Unsigned Integer',384,387),cups[384:387+1]) # 1, 2, 4, 8 bits for version 1 raster files; 1, 2, 4, 8, and 16 bits for version 2 raster files | |
96 | hdr[1]['cupsBitsPerPixel'], = unpack(make_unpack_format('Unsigned Integer',388,391),cups[388:391+1]) # 1 to 32 bits for version 1 raster files; 1 to 64 bits for version 2 raster files | |
97 | hdr[1]['cupsBytesPerLine'], = unpack(make_unpack_format('Unsigned Integer',392,395),cups[392:395+1]) # 1 to 2<sup>32</sup> - 1 bytes | |
98 | hdr[1]['cupsColorOrder'], = unpack(make_unpack_format('Unsigned Integer',396,399),cups[396:399+1]) # 0 = chunky pixels (CMYK CMYK CMYK); 1 = banded pixels (CCC MMM YYY KKK); 2 = planar pixels (CCC... MMM... YYY... KKK...) | |
99 | hdr[1]['cupsColorSpace'], = unpack(make_unpack_format('Unsigned Integer',400,403),cups[400:403+1]) # 0 = gray (device, typically sRGB-based); 1 = RGB (device, typically sRGB); 2 = RGBA (device, typically sRGB); 3 = black; 4 = CMY; 5 = YMC; 6 = CMYK; 7 = YMCK; 8 = KCMY; 9 = KCMYcm; 10 = GMCK; 11 = GMCS; 12 = WHITE; 13 = GOLD; 14 = SILVER; 15 = CIE XYZ; 16 = CIE Lab; 17 = RGBW (sRGB); 18 = sGray (gray using sRGB gamma/white point); 19 = sRGB; 20 = AdobeRGB; 32 = ICC1 (CIE Lab with hint for 1 color); 33 = ICC2 (CIE Lab with hint for 2 colors); 34 = ICC3 (CIE Lab with hint for 3 colors); 35 = ICC4 (CIE Lab with hint for 4 colors); 36 = ICC5 (CIE Lab with hint for 5 colors); 37 = ICC6 (CIE Lab with hint for 6 colors); 38 = ICC7 (CIE Lab with hint for 7 colors); 39 = ICC8 (CIE Lab with hint for 8 colors); 40 = ICC9 (CIE Lab with hint for 9 colors); 41 = ICCA (CIE Lab with hint for 10 colors); 42 = ICCB (CIE Lab with hint for 11 colors); 43 = ICCC (CIE Lab with hint for 12 colors); 44 = ICCD (CIE Lab with hint for 13 colors); 45 = ICCE (CIE Lab with hint for 14 colors); 46 = ICCF (CIE Lab with hint for 15 colors); 48 = Device1 (DeviceN for 1 color); 48 = Device2 (DeviceN for 2 colors); 48 = Device3 (DeviceN for 3 colors); 48 = Device4 (DeviceN for 4 colors); 48 = Device5 (DeviceN for 5 colors); 48 = Device6 (DeviceN for 6 colors); 48 = Device7 (DeviceN for 7 colors); 48 = Device8 (DeviceN for 8 colors); 48 = Device9 (DeviceN for 9 colors); 48 = DeviceA (DeviceN for 10 colors); 48 = DeviceB (DeviceN for 11 colors); 48 = DeviceC (DeviceN for 12 colors); 48 = DeviceD (DeviceN for 13 colors); 48 = DeviceE (DeviceN for 14 colors); 48 = DeviceF (DeviceN for 15 colors) | |
100 | hdr[1]['cupsCompression'], = unpack(make_unpack_format('Unsigned Integer',404,407),cups[404:407+1]) # Driver-specific 0 to 2<sup>32</sup> - 1 | |
101 | hdr[1]['cupsRowCount'], = unpack(make_unpack_format('Unsigned Integer',408,411),cups[408:411+1]) # Driver-specific 0 to 2<sup>32</sup> - 1 | |
102 | hdr[1]['cupsRowFeed'], = unpack(make_unpack_format('Unsigned Integer',412,415),cups[412:415+1]) # Driver-specific 0 to 2<sup>32</sup> - 1 | |
103 | hdr[1]['cupsRowStep'], = unpack(make_unpack_format('Unsigned Integer',416,419),cups[416:419+1]) # Driver-specific 0 to 2<sup>32</sup> - 1 | |
104 | ||
105 | # unpack v2 page header | |
106 | if(version>1): | |
107 | hdr[2]['cupsNumColors'], = unpack(make_unpack_format('Unsigned Integer',420,423),cups[420:423+1]) # 1 to 6 colors | |
108 | hdr[2]['cupsBorderlessScalingFactor'], = unpack(make_unpack_format('IEEE Single Precision',424,427),cups[424:427+1]) # 0.0 or 1.0 or greater | |
109 | hdr[2]['cupsPageSize'] = unpack(make_unpack_format('IEEE Single Precision',428,435),cups[428:435+1]) # Width and length in points | |
110 | hdr[2]['cupsImagingBBox'] = unpack(make_unpack_format('IEEE Single Precision',436,451),cups[436:451+1]) # Four floating point numbers giving the left, bottom, right, and top positions of the page bounding box in points | |
111 | hdr[2]['cupsInteger'] = unpack(make_unpack_format('Unsigned Integer',452,515),cups[452:515+1]) # 16 driver-defined integer values | |
112 | hdr[2]['cupsReal'] = unpack(make_unpack_format('IEEE Single Precision',516,579),cups[516:579+1]) # 16 driver-defined floating point values | |
113 | hdr[2]['cupsString'] = unpack(make_unpack_format('C String',580,1603,16),cups[580:1603+1]) # 16 driver-defined strings | |
114 | hdr[2]['cupsMarkerType'], = unpack(make_unpack_format('C String',1604,1667),cups[1604:1667+1]) # Ink/toner type string | |
115 | hdr[2]['cupsRenderingIntent'], = unpack(make_unpack_format('C String',1668,1731),cups[1668:1731+1]) # Color rendering intent string | |
116 | hdr[2]['cupsPageSizeName'], = unpack(make_unpack_format('C String',1732,1795),cups[1732:1795+1]) # Page size name/keyword string from PPD | |
117 | ||
118 | return hdr | |
119 | ||
120 | page_data='' | |
121 | ||
122 | def get_cups_page(): | |
123 | global cups,page_data | |
124 | if len(cups): | |
125 | hdr=unpack_header(cups[:header_length[version]],version) | |
126 | ||
127 | print_stderr('cupsWidth x cupsHeight: '+str(hdr[1]['cupsWidth'])+' x '+str(hdr[1]['cupsHeight'])) | |
128 | print_stderr('cupsBytesPerLine: '+str(hdr[1]['cupsBytesPerLine'])) | |
129 | print_stderr('cupsBitsPerPixel: '+str(hdr[1]['cupsBitsPerPixel'])) | |
130 | print_stderr('cupsColorOrder: '+str(hdr[1]['cupsColorOrder'])) | |
131 | print_stderr('page size in bytes = '+str(hdr[1]['cupsBytesPerLine']*hdr[1]['cupsHeight'])) | |
132 | ||
133 | page_data=cups[header_length[version]:header_length[version]+hdr[1]['cupsBytesPerLine']*hdr[1]['cupsHeight']] | |
134 | cups=cups[header_length[version]+len(page_data):] | |
135 | return True | |
136 | else: | |
137 | return False | |
138 | ||
139 | def make_bytes(): | |
140 | ret=[] | |
141 | for byte in range(256): | |
142 | ret.append([ | |
143 | 1 if byte&0b10000000 else 0, | |
144 | 1 if byte&0b01000000 else 0, | |
145 | 1 if byte&0b00100000 else 0, | |
146 | 1 if byte&0b00010000 else 0, | |
147 | 1 if byte&0b00001000 else 0, | |
148 | 1 if byte&0b00000100 else 0, | |
149 | 1 if byte&0b00000010 else 0, | |
150 | 1 if byte&0b00000001 else 0, | |
151 | ]) | |
152 | return ret | |
153 | ||
154 | bytes = make_bytes() | |
155 | def get_cups_line(y): | |
156 | numbytes=hdr[1]['cupsBytesPerLine'] | |
157 | w=hdr[1]['cupsWidth'] | |
158 | line=unpack('<'+str(numbytes)+'B',page_data[y*numbytes:(y+1)*numbytes]) | |
159 | ret=[] | |
160 | extend=ret.extend | |
161 | for x in range(0,w/8): | |
162 | extend(bytes[line[x]]) | |
163 | if w%8: | |
164 | extend(bytes[line[w/8]][:w%8]) | |
165 | return ret | |
166 | ||
167 | FORMAT_WIDTH=0 | |
168 | FORMAT_HEIGHT=1 | |
169 | FORMAT_LINEFILL=2 | |
170 | FORMAT_INDEX=3 | |
171 | formats = { | |
172 | 'A4': (0x129A,0x1A7A,0x9A4A,0x0000), | |
173 | 'A5': (0x0CE2,0x1276,0xA233,0x0004), | |
174 | 'A6': (0x08E9,0x0CBE,0xA923,0x000E), | |
175 | 'Letter': (0x1324,0x18DC,0xA44C,0x0001), | |
176 | 'Legal': (0x1324,0x1FE4,0xA44C,0x0002), | |
177 | 'B5': (0x1006,0x16CC,0x8640,0x0005), | |
178 | 'B6': (0x0B14,0x0FE2,0x942C,0x000D), | |
179 | 'Monarch': (0x0850,0x10A8,0x9021,0x0008), | |
180 | # (width,height,linefill,index,) | |
181 | # LINEFILL is created by common rule 0x129A = 0x9A + 64 * 0x4A | |
182 | } | |
183 | ||
184 | def begin_document(): | |
185 | output.write(pack( | |
186 | '>76sbbHHI', | |
187 | ') SAG-GDI RL;0;0;Comment Copyright Sagem Communication 2005. Version 1.0.0.0', | |
188 | 0x0D,0x0A, | |
189 | 0x1000,0x0200, | |
190 | 0 | |
191 | )) | |
192 | ||
193 | def end_document(): | |
194 | output.write(pack('>3H',0x1400,0,0)) | |
195 | ||
196 | format = 'A4' | |
197 | def begin_page(page_format='A4',numcopies=1,toner_economy=False): | |
198 | if not (page_format in formats): | |
199 | page_format='A4' | |
200 | global linefill,format | |
201 | format=page_format | |
202 | linefill=formats[format][FORMAT_LINEFILL] | |
203 | output.write(pack( | |
204 | '<II4H2B3B', | |
205 | 0x000F0011, | |
206 | int(hdr[1]['MediaPosition']), | |
207 | 0x0404,0,formats[format][FORMAT_WIDTH],formats[format][FORMAT_HEIGHT], | |
208 | formats[format][FORMAT_INDEX],int(hdr[1]['cupsMediaType']), | |
209 | numcopies,0,1 if toner_economy else 0 | |
210 | )) | |
211 | ||
212 | def end_page(): | |
213 | output.write(pack('>3H',0x1300,0,0)) | |
214 | ||
215 | current_block_data='' | |
216 | current_line_length=0 | |
217 | def begin_block(): | |
218 | global current_block_data | |
219 | current_block_data='' | |
220 | ||
221 | def get_block_size(): | |
222 | return len(current_block_data) | |
223 | ||
224 | def end_block(): | |
225 | output.write(pack('<3H',0x0012,get_block_size(),0)+current_block_data) | |
226 | ||
227 | def write_px_data(col,length): | |
228 | if length<=0: | |
229 | return | |
230 | ||
231 | color = 1 if col else 0 | |
232 | color_bit = color << 6 | |
233 | first_byte = length%64 | |
234 | second_byte = length/64 | |
235 | two_bytes_bit = 0b10000000 if second_byte else 0b00000000 | |
236 | ||
237 | px_data=pack('>B', two_bytes_bit | color_bit | first_byte) | |
238 | if second_byte: | |
239 | px_data=px_data+pack('>B',second_byte) | |
240 | ||
241 | # start new block of commands if previous is full | |
242 | if len(px_data)+get_block_size()>0xFF: | |
243 | end_block() | |
244 | begin_block() | |
245 | ||
246 | global current_line_length,current_block_data | |
247 | current_block_data+=px_data | |
248 | current_line_length+=length | |
249 | ||
250 | def fill_line(): | |
251 | global current_line_length | |
252 | write_px_data(0,formats[format][FORMAT_WIDTH]-current_line_length) | |
253 | current_line_length=0 | |
254 | ||
255 | def write_cups(): | |
256 | w,h=min(hdr[1]['cupsWidth'],formats[format][FORMAT_WIDTH]),min(hdr[1]['cupsHeight'],formats[format][FORMAT_HEIGHT]) | |
257 | t=time() | |
258 | for y in range(h): | |
259 | if y%(h/15)==0: | |
260 | print_stderr('%d%% '%(int(float(y)/h*100),),False) | |
261 | ||
262 | yline=get_cups_line(y) | |
263 | lastcol=yline[0] | |
264 | lastcolidx=0 | |
265 | for x in range(1,w): | |
266 | currcol=yline[x] # 1 means black pixel | |
267 | if (currcol!=lastcol): | |
268 | write_px_data(lastcol,x-lastcolidx) | |
269 | lastcol=currcol | |
270 | lastcolidx=x | |
271 | write_px_data(lastcol,w-lastcolidx) | |
272 | fill_line() # fills rest of the line and resets current_line_length | |
273 | if h<formats[format][FORMAT_HEIGHT]: | |
274 | for y in range(h,formats[format][FORMAT_HEIGHT]): | |
275 | fill_line() | |
276 | print_stderr('100%%.\nDone in %.3f seconds.'%(time()-t,)) | |
277 | ||
278 | begin_document() | |
279 | ||
280 | curr_page_number=0 | |
281 | while get_cups_page(): | |
282 | begin_page(hdr[2]['cupsPageSizeName'][:2],numcopies=numcopies) | |
283 | begin_block() | |
284 | ||
285 | curr_page_number+=1 | |
286 | print_stderr('Rendering page %i'%(curr_page_number,)) | |
287 | write_cups() | |
288 | ||
289 | end_block() | |
290 | end_page() | |
291 | ||
292 | end_document()⏎ |
0 | // Include standard font and media definitions | |
1 | #include <font.defs> | |
2 | #include <media.defs> | |
3 | ||
4 | // List the fonts that are supported, in this case all standard fonts... | |
5 | Font * | |
6 | ||
7 | // Manufacturer | |
8 | Manufacturer "Ricoh" | |
9 | ||
10 | // Version | |
11 | #define Version "1.0" | |
12 | Version $Version | |
13 | ||
14 | // Each filter provided by the driver... | |
15 | Filter application/vnd.cups-raster 100 rastertosag-gdi | |
16 | ||
17 | // Supported page sizes | |
18 | HWMargins 12 12 12 12 | |
19 | //MediaSize Letter | |
20 | *MediaSize A4 | |
21 | MediaSize A5 | |
22 | MediaSize A6 | |
23 | MediaSize Letter | |
24 | MediaSize Legal | |
25 | MediaSize B5 | |
26 | MediaSize B6 | |
27 | MediaSize Monarch | |
28 | ||
29 | MinSize 9cm 9cm | |
30 | ||
31 | MediaType 0 Auto | |
32 | MediaType 3 "Heavyweight" | |
33 | ||
34 | // input trays | |
35 | InputSlot 0 "Auto/Auto" | |
36 | InputSlot 1 "Automatic/Automatic Tray" | |
37 | InputSlot 3 "Manual/Manual Tray" | |
38 | ||
39 | ||
40 | // Supported resolutions | |
41 | *Resolution k 1 0 0 0 "600dpi/600 DPI" | |
42 | ||
43 | { | |
44 | // Model | |
45 | ModelName "Ricoh Aficio SP 1000S" | |
46 | Attribute "NickName" "" "Ricoh Aficio SP 1000S, rastertosag-gdi $Version" | |
47 | ||
48 | // Specify the name of the PPD file we want to generate... | |
49 | PCFileName "rsp1000s.ppd" | |
50 | ||
51 | // Device ID | |
52 | Attribute "1284DeviceID" "" "MFG:MFPrinter ;MDL:Laser Pro LL;CMD:AUTOMATIC,PJL,GDI_RL;DES:MFPrinter Laser Pro LL;CLS:PRINTER;VER:v1.03e ;NS:L507124L8090042;" | |
53 | } | |
54 | ||
55 | { | |
56 | // Model | |
57 | ModelName "Ricoh Aficio SP 1100S" | |
58 | Attribute "NickName" "" "Ricoh Aficio SP 1100S, rastertosag-gdi $Version" | |
59 | ||
60 | // Specify the name of the PPD file we want to generate... | |
61 | PCFileName "rsp1100s.ppd" | |
62 | ||
63 | // Device ID | |
64 | Attribute "1284DeviceID" "" "MFG:MFPrinter;MDL: Laser Pro LL2 1;CMD:AUTOMATIC,PJL,GDI_RL;DES:MFPrinter Laser Pro LL2 1;CLS:PRINTER;VER:v2.07g ;NS:L510245LA020328;" | |
65 | } |