Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Example of printobject 1

Status
Not open for further replies.

RolandTheRoadie

Programmer
Jan 5, 2005
7
US
Hello,

Does anyone have an example of how printobject is used to print a binary object sequence?

My specific problem is that I have a binary object stored in a database, and I am using a C program to retrieve the data and convert it to a postscript program to send to a printer. If anyone could offer any tips or advice, I would greatly appreciate it.

Thanks,
Chad
 
What is your understanding of a "binary object sequence"? It doesn't refer to any binary data. What is stored in your database?

Also, "printobject" streams the binary object sequence back to the standard out file, not to the printer.

In short, from your description I don't think that "printobject" is the right operator.

If you can describe in general terms what you want to accomplish, such as: "I have a JPEG stored in a database, I want to create PostScript program to print it", I might be able to help further.



Thomas D. Greer

Providing PostScript & PDF
Training, Development & Consulting


Haiku workshop and community.
 
My understanding of "binary object sequence" and all other things Postscript is very limited.

I have an image file (BMP or JPG) of a signature stored in a database (Oracle, 9i) and I need that image to print on a letter.

A c program is used to select all of the other data from the database and produce a postscript file, and the postscript file is sent to a printer to produce the letter.

Thanks again for your help,
Chad
 
Ok. No, you don't need binary object sequences or printobject. They are used to work with a special "binary" way of writing PostScript programs.

PostScript can work with JPEGs directly, not with BMPs. For JPEG files, you need to use the DCTDecode filter in conjunction with the image operator

May I ask how you are creating the signature? If you are using some of the Pocket PC or Tablet PC signature capture programs, there might be another, easier, way.

Those programs capture the coordinates of the pen/stylus as it creates the signature. If you have that raw coordinate data, you can create a PostScript program to "re-draw" the sig from that data.



Thomas D. Greer

Providing PostScript & PDF
Training, Development & Consulting


Haiku workshop and community.
 
After they help you've given, you can ask about any question you like.

Right now, the images are scanned and captured to a file. It may be possible to use some kind of signature capture program, but I would like to stay away from that possibility if we could. My client is more familiar with, and has all of the equipment for scanning, and I just think life will be easier down the road if we stick with what they know.
 
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
 
I guess, the main problem is to get the image parameters from the JPEG file and rewind it. PostScript 3 supports reusable streams. Earlier version can read image data from the string. A procedure data source can read data from an array of strings.

You can also include the image twice or preprocess it on the host.

--
Your PostScript expert is just a click away.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top