Updated April 16 2004
Macros with Canon networked printers
Many people use macros for their printing needs. There are
different applications that you can use it for, but it basically boils
down to the same thing. Sending data needed for every page only
once and the variable data, the data that only goes on one page, down
after.
Let say you have 50,000 customer names and addresses in a database.
You want to send everyone a form letter about some upcoming event.
You want 50,000 letters with one customers name and addresses on
each page. (sounds like a mail merge) Well instead of
sending the form letter down with each name and address you could send
it once as a macro and then call as an overlay as each name and address
is sent down. Saves time, space, bandwidth, ... This could
work for many things like tax forms, shipping forms, any single page
form with variable data.
There are a couple of ways to do this, remembering, of course, that
this is how Canon iR printers deal with macros.
One is to define and call the macro within the same print job as the
data and the other is to store the macro permanently on the printer and
call it when it is needed. We will look at both methods as they
are slightly different from HP's methods.
Note1: You can make a temporary macro with the same ID as a
permanent macro with out deleting the permanent macro.
Note2: You can not call a permanent macro in the same job that
you define a temporary macro even if the ID are different.
PCL commands for macros
There are two PCL escape sequences used when working with macros.
Each macro has to be defined some how so we can call it when needed
especially when working with more than one macro. This is done
with the macro ID command.
<ESC>&f#Y
Where # is the ID number
ranging from 0 to 32767.
Once we have decided what number to call our macro we need to be able
to control the macro. This is done with the macro control command.
<ESC>&f#X
Where # is defines what we
are doing with the macro. Ranges from 0 to 10. This is where
we do most of our stuff. Every time we use the macro
control command it manipulates the current macro. The current
macro is the last macro defined in the current job.
Controls:
0 - Begin/start macro definition - we need to tell the printer
where the macro begins
1 - End/stop macro definition - we need to tell the printer where
the macro ends
2 - Execute macro - overlay on the first page after the command.
not subsequent pages, retain macro's environment
3 - Call macro - overlay on the first page after the command. not
subsequent pages, do not retain macro's environment
4 - Enable macro for overlay - overlays on every page, do not
retain macro's environment
5 - Disable overlay - disable the overlay with the possibility of
enabling it again
6 - Delete all macros - Only deletes macros defined in current job
7 - Delete all temporary macros - Only deletes macros defined in
current job
8 - Delete current macro - Only deletes current macro defined in
current job
9 - Make macro temporary - not supported by Canon iR's, all
macro's defined in the job are temporary ONLY
10 - Make macro permanent - not supported by Canon iR's. To make
permanent use NetSpot Resource Downloader (see below)
Type 1 - Define and call the macro
within the same print job as the data
You can not make these macros permanent. They are deleted from
memory when the job is finished and the connection to the host is closed.
This is a very basic working example just to show the format of the
job. I have put the commands on their own lines so I could insert
notes, in the actual job this would all be on one line. The macro
has to come first so we can call it as an overlay for our data.
<ESC>E - All PCL starts with a PCL reset
<ESC>&f42Y - Define macro ID 42
<ESC>&f0X - start macro definition
The colour for this page is ...<CR><LF> - macro data
<ESC>&f1X - End macro definition
<ESC>&f4X - Enable Macro for overlay
<CR><LF>Yellow<CR><LF><FF><CR><LF>Blue<CR><LF><FF><CR><LF>Green<CR><LF><FF>
- Data (three pages)
<ESC>E - All PCL ends with a PCL reset
This will print three pages, all with "The colour for this page is ..."
on the first line and each page with a different colour on the second
line.
Type 2 - Store the macro permanently
on the printer and call it when it is needed
Using the same example as above, we will make our macro permanent so we
can call it with any print job.
First we need to put our macro in a file. Take above line with
the note "macro data" and put it in a file. That wasn't to hard.
Now we need to store it on the copier so we can access it. I
believe there are a couple of ways to do this, I will show you how using
Canon NetSpot Resource Downloader.
Download, install, and run the Canon NetSpot Resource Downloader.
Click on the settings button in the bottom left. Verify settings
and click ok. This sets up the directories CNRD uses. Now
it's time to create a group to work with. Under device group click new.
Choose PCL Font/Macro and name the group. Click ok.
Now we need to add the printer we want to use with our macro. With our
new group selected, under device click on add. Automatically discover or
manually input the IP address to your printer. Click add. Now we
have a group and a device we just need to point to our macro.
Under the resource section click on add. Point to our macro file and
click open. Click on the download button and wait. A check mark
appears beside the macro once it is downloaded and it is assigned an ID
number. We will use that ID number to call the macro.
The macro ID for the first macro is 0. So, following the example
above, the file we would now send to the printer would consist of the
following:
<ESC>E - All PCL starts with a PCL reset
<ESC>&f0Y - Define macro ID 0
<ESC>&f4X - Enable Macro for overlay
<CR><LF>Yellow<CR><LF><FF><CR><LF>Blue<CR><LF><FF><CR><LF>Green<CR><LF><FF>
- Data (three pages)
<ESC>E - All PCL ends with a PCL reset
And we get the same output as above.
Making a more complicated macro
You must have a strong understanding of PCL to do the following.
The above example is a very simple macro and most people want much more
complex forms or macros. There are many ways to do this. I
will explain how I have been doing it, with great success so far.
Choose the editor you need to create your form. I have seen
people use MS Word and Excel files. Anyway, create your form in an
editor, hey why not try Open Office.
Now print to file using the HP Laserjet 4000PCL driver. I
have chosen this model because all the Canon controllers are based on
this. Please use the printer driver that your printer's RIP
supports. FYI - The B&W imagePASS RIPS are based on
the HP Laserjet 5000PCL driver. I will not go into why I did
not use the Canon printer driver.
Now you have a spool file, it contains our macro but also many other
things we don't want like job control. Now comes the hard part, we
must clean this file so it will work as a macro. Open a copy of
the spool file in your hex editor, this way if you make a mistake you
still have the original file. Locate the first PCL reset
<ESC>E. Delete everything from the beginning, up to and
including the first PCL reset. Now scroll to the bottom of the
file and locate the last PCL reset. Delete everything from and
including the PCL reset to the end of the file. We are not done
yet.
While you are at the bottom of the spool file look for any <FF>.
Delete it if it exists. That should be it for the bottom,
now back to the top. There are certain PCL commands embedded in
the code of printing that we must remove for the macro. These
include, but not limited to:
Page Length -
|
<ESC>&l#P
|
Paper source -
|
<ESC>&l#H
|
Paper Size -
|
<ESC>&l#A
|
# of Copies -
|
<ESC>&l#X |
Orientation
-
|
<ESC>&l#O |
Cursor Position |
Stack |
I also remove any finishing options like simplex/duplex, bin selection,
you get the idea. Save your file and you have a macro.
follow the above directions to access it.
Updated July 14 2003
I received this helpful email from Paul Geary of Canon.co.za, Thanks a
lot Paul. This is fantastic!
---Begin---
Hello
Here's how you call a macro from Word....
Open a Word document
Go to:
Insert
field
Document automation
print
after the word PRINT leave a space and insert the following code:
0x1B"&f5y4X"
5 is the macro ID no.
This will call an HP PCL macro file that has been downloaded
using Netspot resource downloader
It can be placed at the top of any page in your document eg. 1,3,7
PS.
You must use 4X if you are using different macros on different
pages.
Other settings cause tables to not print in Word or 2nd macro
dissapears.
I tested this on an IR3300i with great success.
You can use the HP macro creator and then just rename the file to
.P5e
Have fun
Regards Paul Geary
---End---
Well That's it, I hope you feel more comfortable with macros, now on to
PJL.
Updated April 16 2004
The EFI controller for the iR330/400 H1/K1 handles macros a little
differently. Other controllers could as well but this is the one I
checked because someone was having a problem. If you find other
controller that work this way let me know and I'll add them to the list.
If I had the time I would test them all.
With this controller the macro ID is associated with an alphanumeric
ID/string. So calling the macro works a little different. We can find
the string used to call the macro in
\program files\canon\netspot resource downloader\driverinfo\<ip
address>\*.cal
<ip address> is the IP address of the iR.
*, so far, has been the basename of the p5e file downloaded.
I edit this string slightly. Here is an example:
(anything inside <> is a control character. The IP address and
macro ID used where picked to make the example easier to understand and
probably won't be the same as yours.)
Create your macro and save it in a file called rick.p5e. Download this
to the H1/K1 board at the IP address of 192.168.10.10 with a macro ID 0.
The contents of the file \program files\canon\netspot resource
downloader\driverinfo\192_168_10_10\rick.cal should be:
<esc>&f0Y<esc>&n6W<enq>rick<esc>&f2X
<esc>&f0Y - Call macro ID 0
<esc>&n6W<enq>rick - associate current macro ID with
alphanumeric string "rick"
<esc>&f2X - call macro, I change 2 to a 4.
In the second string <enq> is hex 05
Any questions? Should I explain further?