Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

PDF/PostScript/Crystal Reports -add- PCL codes -to- Print from Visual Basic (Stapling PCL codes)?

684 views
Skip to first unread message

Eric

unread,
Apr 20, 2001, 2:14:28 AM4/20/01
to
Please "reply to email" as well as the group so I get
a copy in my email box. :) I may miss it.
-----------------------------------------------------------------

Problem:
I need to 'staple' pages when a print job completes. This can be done via a
Canon print/copier machine printing dozens of batches at a time. My problem
is I need to send PCL commands to the printer to tell it to 'staple' this
print job once it completes.

The printer staples 'per print job'. Initiating printer options to staple,
then an adobe/crystal reports/vb .printer commnad to print would create a
new print job outside of my initial print job to staple. Therefore the
PDF/Crystal Reports/PostScript file never would get stapled.

I also need a little more info on how to do the 'simplest' of things it
seems:
1) Print from Visual Basic using PCL codes (I just know a little about the
Printer object, is that it? How would I send PCL commands using this
object?) I think I would just use direct <printer-object>.Print <ascii
codes> to do this. Just need a comfirm.

2) Could you convert a PDF file (using Distiller or another converter like
GhostScript) to PostScript and wrap/insert some sort of PCL codes around
this somehow? Again, the PCL codes for stapling.

Note: I do have the PCL codes and commands for the actual printer to BIND
using stapling. That's at least done. :)

Descriptions:
The reports to print are generated in via Crystal Reports 8.5. But the key
note to remember is they are generated with Crystal Reports, I can't change
this. I have done a lot of research over the last few days, searching
groups.google.com to make sure I cover all news groups and have ended up
with a few ideas. I just can't seem to nail one.

Senerios to think about?:
1) Adobe Acrobat reader PDFs & PCL Codes -> Print from Visual Basic API
controls
A new feature the client wanted was to output the Crystal Reports in an
archived PDF format. Done. So I was thinking of taking this Adobe PDF file
on the server, opening it using the Acrobat object in VB, and printing it
from here. But before printing it, could I submit PCL or Printer Codes to
the printer to initate the Staple command, via VB to the acrobat reader's
printer options?

2) Crystal Reports using PCL or PrinterOptions -> Print from Visual Basic
The initial reports are created in Crystal Reports. I can print using the
.PrintOut False (preferred so no user interaction is needed, nor is it
wanted) to print the report within VB and they are perfect! Just no staple.
Is there a way to send PrinterOptions such as STAPLE BINDING to the printer
from VB to Crystal Reports before printing?

3) PDF -> PostScript -> "add PCL codes?" -> Print from Visual Basic
My final thought was to take the PDF file and convert it to a PostScript
file (using one of the methods above). Then somehow plugging in the PCL
codes to BIND via stapling? But I am not sure about how to print PostScript
within VB, or even send PCL commands via VB either and not even sure this
wouldn't error out due to mixing PCL and PostScript. This is of last resort
mainly because it would create a 'temp' file and a lot of disk access I
don't want. Not to mention the headache of installing GhostScript on EVERY
user's machine (if that is needed)! Installing Adobe Reader (option 1
above) would be cool.


As you can see, I am not too fimilar with PostScript and how it relates to
PCL codes. Much less how to implenment them into my application as I need
to.

Thanks in advance!
Eric


Aandi Inston

unread,
Apr 20, 2001, 2:48:59 PM4/20/01
to
"Eric" <er...@cdc.net> wrote:

>1) Print from Visual Basic using PCL codes (I just know a little about the
>Printer object, is that it? How would I send PCL commands using this
>object?) I think I would just use direct <printer-object>.Print <ascii
>codes> to do this. Just need a comfirm.

No, nothing like that. Windows works hard to conceal the kind of
printer from the application. If you say Print "text" then it converts
"text" into whatever printer codes are needed to position and send
those codes. There is no possibility to escape into printer language.

For that you need to use special escape methods, perhaps the
PassThrough escape. The printer object provides a device-independent
graphic model and does not appear to support escapes at all.


>
>2) Could you convert a PDF file (using Distiller or another converter like
>GhostScript) to PostScript and wrap/insert some sort of PCL codes around
>this somehow? Again, the PCL codes for stapling.

No to PostScript. PCL and PostScript cannot be mixed in the same job.
No to PDF. PCL codes cannot be embedded in a PDF in any way at all.


>
>Note: I do have the PCL codes and commands for the actual printer to BIND
>using stapling. That's at least done. :)

If you are working with PostScript, I'd recommend finding and using
the PostScript sequence instead.
----------------------------------------
Aandi Inston qu...@dial.pipex.com
Visit http://www.quite.com/ for info on PostScript,
PSAlter, psalters, tea, and small furry animals. And stuff.

John Nurick

unread,
Apr 20, 2001, 4:57:53 PM4/20/01
to
Eric,

Some perhaps not very helpful comments:

1) I'd expect the printer driver for the Canon device to have options
to control collating, stapling, etc. Certainly that's how it works
with the Xerox printer/copier where I work. Assuming it does, how
about installing a "second copy" of the printer in Windows and setting
its defaults so it behaves the way you want?

2) In principle you can print the PCL to file and then pipe the file
through a script that inserts the necessary PCL instructions at the
right point.

3) If the printer/copier speaks PostScript, (a) the driver might have
more options and (b) even if it doesn't, it should be easier to parse
the output file and insert stapling instructions as in (2); in fact
all you may need to do is edit the header file that the driver sends
to the printer before the first job.

--
With best wishes
John

Please reply to the newsgroup and not by e-mail.

M.R. Hoare

unread,
Apr 21, 2001, 9:54:35 AM4/21/01
to
I hope that by now the '2nd driver copy' option of John Nurick's is
working well.

However, if you do end up looking at 'print-to-file' options are you
sure that the commands are PCL (which handles actual printing) and not
PJL (the printer Job Language used to control the print job on an HP
printer) or something like it? For example: if you want to print PCL
jobs and PostScript jobs mixed on an HP PostScript printer with PCL5
there is a PJL sequence to change the language (by changing the printer
'personality') and set up a print environment (page size, tray to use,
default symbol set, number of copies, orientation and so on). Most
things can also be set up in PCL but
'@PJL DEFAULT PAPER = LETTER' is a bit easier to read (and edit) than
'<esc>&l2A'. I would expect any printer with multiple languages and
stapling/collating etc to have a similar control language tp PJL.

If you are dealing with PJL you can fairly easily add your commands into
the header sequence or at the end of the job after printing to disk in
either PCL or PostScript as John Nurick suggested. Modifying a straight
PCL file can be quite tricky.

Dan Sideen

unread,
Apr 23, 2001, 6:39:45 PM4/23/01
to
Embedding PCL codes in your job will not be a pleasant task. Here is a
different approach that might work, and you don't have to know a single PCL
escape sequence!

1. Output the Crystal Reports as Postscript files by choosing a Postscript
printer driver. The exact driver doesn't matter, but it should support the
page size that you are using, and have an option to make DSC compliant
postscript (referred to as "optimize for portability" in some MS drivers). A
good choice is to get the Adobe PS driver, and select an Laserwriter II NTX
device.

2. If you can control Crystal from VB, you can output a separate report for
each "set " you want stapled. If not, put an identifier in the report (use a
1 pt Courier font) as the first item on the first page of a new report. You
then need a program to "strip" the ps file into individual ones. Email me,
and I can give you some pointers on how to do this in VB, or where to get a
commercial program to do this. Alternatively, you can look for this
identifier, and put a postscript setpagedevice command in to turn stapling
(more properly called stitching) on and off.

3. If you can upgrade your Canon to support Postscript, do it. Even better
if you can upgrade to PS 3.

4. If you can do #3, just turn on stitching, and send each set to the
printer using LPR or copy {filename} {devicename}

5. If you can't, then Distill the PS files, and use the Acrobat IAC options
to automate the printing of the sets. Acrobat (even Reader) will do a nice
job of converting the files back to PCL.


Here is another approach. If you have Crystal 8.5, you can create pdf's
directly rather than ps-and-convert. You should be able to create a separate
pdf for each section, and you can then print them directly (if you have PS 3
support on the Canon) or with a little VB program to automate printing.

Here is a VB sub routine that will silently print pdf files. (You must start
Acrobat or Reader first)

Sub Printit(FileToPrint As String)
'Print a file using Acrobat
Dim sCmd As String 'command string to pass via DDE
Dim FullName As String ' fully qualified file name
FullName = FormsHome + "\" + FileToPrint
sCmd = "[FilePrintSilent(" & FullName & ")]"
frmFindForm.lblDDE.Caption = "Printing..." & FileToPrint
frmFindForm.lblDDE.LinkTopic = "Acroview|Control"
frmFindForm.lblDDE.LinkItem = ""
If frmFindForm.lblDDE.LinkMode <> 2 Then
frmFindForm.lblDDE.LinkMode = 2
End If
frmFindForm.lblDDE.LinkTimeout = 1
frmFindForm.lblDDE.LinkExecute sCmd
frmFindForm.lblDDE.LinkMode = 0
frmFindForm.lblDDE.Caption = ""
frmFindForm.lblDDE.LinkMode = 2
End Sub

"Eric" <er...@cdc.net> wrote in message news:3ae07ac6$1...@news.isdn.net...

Ed Deinstadt

unread,
Apr 23, 2001, 9:01:58 PM4/23/01
to
Eric:
Can you post the "PCL Codes" for stapling? Most of the PCL printers that I have
seen that staple actually use something called PJL. I have not seen the Cannon.
Typically printers that use PJL CAN do so both in PCL mode and in PostScript
mode. The PJL is a wrapper that can be put around the entire print job.

Ed Deinstadt

0 new messages