Thomas,
I was hoping you would be able to provide a little more help on this thread. My problem is that I have a JPG file of someone's signature in a database, and that I am trying to print it in the middle of a document.
I have looked at your response to "how to print variable bmp/jpg using image" (
and you instructed kgeffert to study the following code you posted:
%!PS
/JPEGdict 20 dict def
JPEGdict begin
/NoParamMarkers
[ % JPEG markers without additional parameters
16#D0 16#D1 16#D2 16#D3 16#D4 16#D5 16#D6 16#D7 16#D8 16#01
] def
/NotSupportedMarkers
[ % JPEG markers not supported by PostScript level 2
16#C3 16#C5 16#C6 16#C7 16#C8 16#C9 16#CA 16#CB 16#CD 16#CE 16#CF
] def
/ColorSpaceNames << /1 /DeviceGray /3 /DeviceRGB /4 /DeviceCMYK >> def
/NextByte
{ F read not { (Read error in ViewJPEG!\n) print flush stop } if
} bind def
/SkipSegment
{ % read two bytes and skip that much data
NextByte 8 bitshift NextByte add 2 sub { NextByte pop } repeat
} bind def
/readJPEGmarkers
{ 5 dict begin
{ % loop: read JPEG marker segments until we find SOFn marker or EOF
NextByte 16#FF eq
{ % found marker
/markertype NextByte def
markertype dup 16#C0 ge exch 16#C2 le and
{ NextByte pop NextByte pop % segment length
NextByte 8 ne {(Error: not 8 bits per component!\n) print flush stop} if
/height NextByte 8 bitshift NextByte add def
/width NextByte 8 bitshift NextByte add def
/colors NextByte def
exit
} if
NotSupportedMarkers
{ markertype eq {(Marker ) print markertype == (not supported!\n) print flush stop } if
} forall
true
NoParamMarkers
{ markertype eq {pop false exit} if
} forall
{ SkipSegment } if
} if
} loop
currentdict dup /markertype undef
end
} bind def
end % JPEGdict
/viewJPEG
{ save
JPEGdict begin
/saved exch def
/scratch 1 string def
dup type /stringtype eq { (r) file } if
/F exch def
readJPEGmarkers begin
F 0 setfileposition
width height scale
ColorSpaceNames colors scratch cvs get setcolorspace
<< /ImageType 1
/Width width
/Height height
/ImageMatrix [ width 0 0 height neg 0 height ]
/BitsPerComponent 8
colors 4 eq
{ /Decode [ colors { 1 0 } repeat ] }
{ /Decode [ colors { 0 1 } repeat ] }
ifelse
/DataSource F /DCTDecode filter
>> image
end
saved end restore
} bind def
10 10 translate
(c:/documents and settings/administrator/my documents/image.jpg) viewJPEG
I have studied that code, and I can get it to work if I spool the JPG file to the print server. The problem I am having is that this solution leaves the JPG file on the print server, which is considered unsecure because this is a public directory. Is there a way to change that example to read hex data stored inside the PS program, and how would you do it?
Thank you again for your help,
Chad