Tuesday, July 24, 2007

Short n Fat vs Tall n Slim: Apps Printer Drivers 66 lines per page A4 printing

In the old school days before the 3Ps - PASTA PDF Postscript and yonks before BIP there was character mode printing.

Actually, there still be character mode printing last time I checked. Gotta love those accountant's reports.

Being one of the ?unlucky? few operating outside the USA meant that the default printer driver initialization strings - or should that be initialisation - just didn't cut it with our tall n slim A4 paper vs short n fat US Letter paper. Hey, I'm not insinuating anything ;-)

And it was always a challenge to get character mode printing sorted for A4 paper without double spaced lines and printers that spat the dummy when you sent them US Letter. I could never understand why Oracle didn't deliver a few friendly print drivers for A4 paper.

Anyway one day many years ago I got out the handy character printing toolkit of:

  • a PCL 4 syntax manual,
  • the PCL escape character
  • some nifty shell scripts

And decided to save a few trees and get portrait 80 x 66, landscape 132x66 and landwide 180x66 printing nicely making best use of space, fonts and not flowing 5 or so lines over to the next page.

Before this info is relegated to the age of dinosaurs, this is what I came up with:

A4 Paper Printer Driver Initialization Strings for HPLJ4 (or higher) printers

A4 Portrait 80x66 /eE/e&l0o26a7C/e(s0t0p11H/e&a5L/e&k2G
A4 Landscape 132x66 /eE/e(0N/e&l1o26a5.25c-340z150u0S/e(s0p13H/e&k2G
A4 Landwide 180x66 /eE/e(0N/e&l1o26a5.25c-340z150u0S/e(s0p16.66H/e&k6.75h2G/e(2N

Oh, while I'm here I should say that the o26 means A4 paper and the &k2G means set LF to CRLF which solves lines being printed in cascading style and disappearing off the right hand side of the page like this:


Of course, you can also add a duplex mode via a bunch of additional drivers to save even more trees by adding one of:
&l1S - Duplex Long Edge
&l2S - Duplex Short Edge

Or even add some more drivers with relevant tray control with one of:
&l1H Feed from Tray 1 (upper)
&l2H Manual Feed
&l3H Manual Envelope Feed
&l4H Feed from Tray 2 (lower)
&l5H Feed from paper deck

A very quick and nasty way to get this sorted in an environment not using US Letter paper with printers setup as type HPLJ4SI is (not supported of course), oh and remember to restart the concurrent managers:

set define ~
update fnd_printer_drivers set
--user_printer_driver_name = 'LANDSCAPE A4 for Printer HPLJ4SI',
description = 'Init was ' || initialization,
initialization = '/eE/e(0N/e&l1o26a5.25c-340z150u0S/e(s0p13H/e&k2G',
last_update_date = sysdate
where printer_driver_name = 'LANDSCAPEHPLJ4SI';

update fnd_printer_drivers set
--user_printer_driver_name = 'LANDWIDE A4 for Printer HPLJ4SI',
description = 'Init was ' || initialization,
initialization = '/eE/e(0N/e&l1o26a5.25c-340z150u0S/e(s0p16.66H/e&k6.75h2G/e(2N',
last_update_date = sysdate
where printer_driver_name = 'LANDWIDEHPLJ4SI';

update fnd_printer_drivers set
--user_printer_driver_name = 'PORTRAIT A4 for Printer HPLJ4SI',
description = 'Init was ' || initialization,
initialization = '/eE/e&l0o26a7C/e(s0t0p11H/e&a5L/e&k2G',
last_update_date = sysdate
where printer_driver_name = 'PORTRAITHPLJ4SI';


Old school stuff, but can't remember how many times these statements have helped.

PS. Did I remember to say restart the concurrent managers after making printer driver changes?

PPS. Despite PASTA being a fantastic tool, I found myself modifying the following in order to get around a tad more setup to force US Letter to A4 paper

In file $FND_TOP/resource/pasta_pdf.cfg there is a line:
preprocess=pdftops {infile} {outfile}
Change this to the following (replace /usr/local/bin to wherever pdftops is installed):
preprocess=/usr/local/bin/pdftops -paper A4 {infile} {outfile}


Update: fixed some HTML formatting issues and missing || in the code, plus added a couple more comments.


Vivekadarpana said...

You run an excellent blog. COngrats.
I have a question. Is there a table which stores all the scheduled concurrent requests in ORacle apps. Please let me know if you are aware of any. I want have a list of all scheduled concurrent jobs.

Gareth Roberts said...

Hi Vivekadarpana,
Thanks! Get scheduled requests with the following query:

select request_id from fnd_concurrent_requests
where status_code in ('Q','I')
and requested_start_date > SYSDATE
and hold_flag = 'N';


Kooldude008 said...

Hi Gareth,
Quite a useful stuff!! I would like to have your inputs on the following:

I have requirement wherein i have to PRINT invoices, generated thru XMLP in PDF format. I am gonna use XMLP DeliveryManager APIs for printing and have CUPS server setup on MT for printing stuff.
I have couple of questions:
1) As far as i know, deliveryManager API doesn't provide Tray control. How can i achieve controlling trays.

2) If I set up CUPS on MT and my printer is on different machine (in network though), will this configuration work? (I guess IPP is intended for this only..)

Your valuable thoughts!!
Thanks in advance for any help you can provide on this.

With regards-

Kooldude008 said...

I found the solution to the first one:

// To Use A4 paper:
req.addProperty(IPP_MEDIA, IPP_MEDIA_A4);

// To Use a different tray:
req.addProperty(IPP_MEDIA, IPP_MEDIA_TRAY1);

metalink note: 357402.1

However, the second Q still remains unanswered.


Gareth said...

Hi Ashish,
As long as your target printer is on network, you should be able to setup its print queue and print to it via either Print Server (Windows Server Spooler or whatever) or IP direct assuming printer has JetDirect card or similar.

Anonymous said...

Hi Gareth, i think here your help would be much appreciated.
Well, we are having HP Laserjet 8150N for printing. We have a requirement to select different trays for different pages of the document generated by BI Publisher.
I am using a Java Conc Prog. to generate the document.

I checked various options with "lp" command but they are not able to select tray. Everytime, the default tray is selected. I guess this must be an issue with PPD file.
Any idea why this is happening?
Let me know if you need more information.


Gareth said...

Hi Ashish,

I can't test my answer right now since I don't have a multi tray printer... but I'll think out loud.

My understanding is that PASTA is used to print the output from your program via Postscript rather than PCL. This blog talks about tray selection when printing a text file using PCL printer commands rather than Postscript. So you'll need to get the tray select codes inside the postscript or instruct PASTA to select the tray at the time it sends the job to printer. If printing at the time file is sent to printer, then the tray will be for the whole file.

Let's give the chain of events for better understanding.
1. Your java concurrent program produces XML
2. XML is passed to BI Publisher and say, PDF document is produced
3. PDF document is passed to PASTA for printing
4. PASTA uses utility pdftops or pdf2ps to convert PDF to Postscript
5. PASTA sends postscript to printer.

So the first option I see is to modify e.g. $FND_TOP/resource/pasta_pdf.cfg to change the line:
printCommand=lp -c -d{printername}
to something like
printCommand=lpr -Ztray2 -P{printername}

Alternatively maybe pdftops could achieve something in the preprocess line:
preprocess=pdftops -?sometrayoption? {infile} {outfile}

Finally, to get different pages to different trays would require the postscript having tray control included ... I guess you have tried an RTF template with multiple sections going to different trays?

Or if that wasn't possible, then maybe use bursting? and print each bit using one of the prior techniques?

Interested to hear from anyone who has this working.


Anonymous said...

Gareth, thanks a lot for your inputs.
First of all, I did try section properties in RTF to control tray-selection, however, that did not work. Reason being, this properties are not retained in the generated output.

Second, I've not checked options with pdf2ps to generate PS to include tray-control. Will have a look.
However, from what you are suggesting here (preprocess=pdftops -?sometrayoption? {infile} {outfile}), it seems that the selected tray will apply to entire document rather that pages in it. So maybe I'll have to submit multiple requests to have different pages printed on different trays. I would consider that a less preferable option.

Also, I am thinking of using lp command directly from java, instead of using Printer setup defined in Ebiz. And I've tried the following various options with no luck..

lp -dpzmn00x170045 -o 1:InputSlot=Middle -o 2-2:InputSlot=LargeCapacity /home/kmahesh/Test.ps
Outcome: First page from Middle Tray 2 and the second page from Tray 4

lp -dpzmn00x170045 -o InputSlot=Lower /home/kmahesh/Test.ps
Outcome: Tray 2

lp -dpzmn00x170045 -o InputSlot=middle /home/kmahesh/Test.ps
Outcome: Tray 2

lp -dpzmn00x170045 -o InputSlot=Tray2 /home/kmahesh/Test.ps
Outcome: Tray 2

lp -dpzmn00x170045 -o media=Middle /home/kmahesh/Test.ps
Outcome: Tray 2

lp -dpzmn00x170045 -o media=middle /home/kmahesh/Test.ps
Outcome: Tray 2

lp -dpzmn00x170045 -o media=Tray2 /home/kmahesh/Test.ps
Outcome: Tray 2

lpr -ppzmn00x170045 -o media=Middle /home/kmahesh/Test.ps

None of the above is working. I am thinking of PPD file issue here. But not sure.
If lp command is able to select tray, my problem is resolved.
If you ever saw tray selection options with lp command working for HP Laserjet 8150N, please do let me know.

Thanks once again for your time.

Gareth said...

Hi Ashish,

Might have missed making my point ... the output from BI Publisher is not a straight text file, so it will be sent to the printer in raw mode - I think this means you'll only get tray control at the whole file level as e.g. PostScript has tray control inside the file.
Perhaps the BI Publisher Delivery Manager / bursting can help here?


Gareth said...

PS. Just noticed you are sending .ps files, did you try putting tray control inside the Postscript file?

Hmm, this is getting close:


tapan413 said...

Hi Gareth,

Stumbled upon your post while searching for PCl codes and syntax. Really a great post for customizing printer drivers.

I have a question regarding APLASP.prt. In my format payment (APXPBFEL) layout i have put date field at left-most corner of layout. But while printing it using a HPLJ4SI type printer with style "Portrait - Laser Check" that field is printing 3 to 4 chars left and not on exact left-most corner of paper. So is there anyway that we can print on left most corner without any margin using APLASP.prt ?
Please suggest.


Gareth said...

Hi Tapan,
Looks like APLASP.prt has lots of embedded PCL codes (you can reference the escape code on the fields within the report).
I'm not sure what all these codes do in APLASP.prt, but the initialization string on the printer driver that you use will still have effect, so you can control the default margins etc with that using the PCL language.
If you look at the syntax reference specifically here - margins you will see reference to top Ec&l#E and left margins Ec&a#L plus Long edge (left) offset registration # - Ec&l#U Short edge (top) offset registration # - Ec&l#Z.
Have a play with those in the initialization string and see how you get on.


satish said...

Hi Gareth,

We are printing bank details and check number at the footer. Requirement is to move the check number to very bottom of the page. When we try to move the check number, it is printing partially and when we try to move further it is not printing at all. Problem might be due to fixed margin size for the printer. I am not able to find where to control this size.

We are using Letter size and pdftops as third party tool. Can
you please provide your feedback.


Gareth said...

Just a note that there is a good post on BI Publisher and Tray Control here:


Ashish said...

Hi Gareth

We are trying to use the old laser priner (HP Laserjet 4 plus) which uses the PCL format to print , please suggest if we have a way to setup the pasta to use the pcl printer for printing the pdf documents.
~ Ashish | 630 487 9486

Gareth said...


PDF will usually end up being converted to Postscript and sent to printer. Theoretically you could convert the PDF to plain text, then send via PCL ... but I don't see the point!


Ashish said...

Thanks Gareth for quick response, yes I agree the pdf will be converted to postscript, but the printer is not supporting the postscript. The printer only understands the PCL. IS there a way to configure the pasta to change the pdf to pcl.

Gareth said...

Hi Ashish,

Should be possible, there is PDF to PCL converter available, and in PASTA you can configure the pasta_pdf.cfg to change the preprocess from pdf2ps to the pdf to pcl converter, then possibly modify the lp command if it doesn't work as standard. Of course I haven't tried this so not sure.

Let me know how you get on.


Ashish said...

Thanks Gareth, I will check for PDF to PCL converter, in between if you have the converter handy please mail me to ashish.dir@gmail.com. I need help to configure the Zebra printers as well, of you can provide the steps to do that as well will be great.

~ Ashish | 630 487 9486

trupti said...

Hi Gareth

I have a query related to ur blog on PASTA file setting
There is a need to print PDF Reports (Generated using XML Publisher) from a specific printer tray (Tray 3).
We believe same is possible by modifying pasta.conf file provided by oracle for printing PDF reports.

Please advice in case u know how to achieve the above functionality of printing PDF reports generated by XML Publisher to a specific printer tray
, would appreciate if you can share the details/code to do so.

PS: This being XML publisher report & not a normal RDF, printer initialization string to print to a specific tray does not work
Also there are total 4 reports printing together out of which one needs to be sent to a specific tray of printer.
Its very urgent (sollution is needed today itself)

Thanks in advance

Gareth said...

Hi Trupti,
Try solution per comment and let us know how it goes:
... first option I see is to modify e.g. $FND_TOP/resource/pasta_pdf.cfg to change the line:
printCommand=lp -c -d{printername}
to something like
printCommand=lpr -Ztray2 -P{printername}


Bill Gaston said...

Gareth, excellent article on printing. Quick question - in APLASP.prt, is there an escape code that turns on the dollar sign for checks? We are printing AP checks in Oracle. Thanks, Bill

Gareth said...

Hi Bill,

You can put the dollar sign directly into the text, then if you want special format (like bold) that plain text doesn't give you, you can possibly embed PCL commands in the text if you are using Oracle Reports to generate the text by using the "Printer Code Before"/After attributes on the properties of the field in the layout editor.


Jag said...

Hi Gareth,

Nice Article...

I have a requirement wherein the digital signatures have to be printed on the cheques generated through the RTF. The signatures will be configured in the printer and I have to use Printer Control Language (PCL) commands in my RTF to get it printed. Please let me know if have an idea on how to achieve this.


Gareth said...

Hi Jag,

If you're talking about XML (BI) Publisher RTF, it doesn't produce text (PCL), but produces PDF which by default is converted to postscript and sent to printer, so no PCL.

Check this forum post for alternatives:


raj said...

Hi Gareth,

We are implementing Std. R12.0.6 AP Check Printing.

I've designed standard BI Publisher RTF to print the Check and Check-Copy without any issue.

My RTF Template has Check design on first page and Check-Copy (Non-Negotiable) on second page of RTF. Std. Conc. Prog. Payment program FORMAT PAYMENT INSTRUCTIONS automaticlly will be printnig the Checks after paying the Vendor, there my RTF is being used for printing through PDF.

Issue is Both Check & Copy are by default getting printed from Tray#3. But the requirement is Check to be selected from Tray#2 and its Check-Copy should be selected from Tray#3.

Note: output PDF is NOT considering the Print setups made in RTF.

My question is:
(1) How can we Print Checks from (Check Stock) Tray#2 and Checks those Copies (which are Non-Negotiable) from

When printing is happening, it is through one single file (both check&copy) then how can I seperate them to specific two trays even if I modify pasta_pdf.cfg

If you can guide me that'll ge great.

I even emailed you the same requirement. It is very urgent.
my email: nagkode@yahoo.com

Thanks a million in advance for your attention and time.

Kind Regards,


Unknown said...

Just wondering if we have any solution for printing check & copy to different trays (tray#2 or tray#3). Would you mind sending it to my email DamuPant@gmail.com
Thanks in advance.

Praveen Y said...

Hi Gareth,

We are upgrading the EBS 11.5.9 to R12. the Check printing in 11i is Text format and, .prt files and printer side plugin is used to include the MICR code, Signature and Logo. The printer - HP4100_TROY.

1. In R12 the Check Printing process generates the PDF output. Using PASTA is it possible to convert otuput to PCL/Text and use the same printer and printer plugin.

2. Is there any other method to use the same printer and printer plugin to print MICR code,Logo and Signature on the check.

3. We have to generate checks of 3 bank accounts from different Tray. is it possible to send the print request to a particular Tray.

Is there any solution to implement above steps without using Third party tools, like Evergreen Docogurd.

Please let me know the steps to implement it.


Gareth said...

Hi Praveen,

I have had a customer with the same requirements, but they did not get a resolution from Oracle, so a custom or 3rd party solution is probably required here.


Hari said...

Raj , did you find a solution for your issue.

Gareth -- We have a similar requirement for check and copy to be printed on different tray's.
Is there any solution available ??


Gareth said...

Hi Hari,
I haven't tried it yet, but it may b be possible to use PASTA to Ghostscript to convert PDF to PCL, with embedded tray control escape sequences.
Something along the lines of this: