~Vamsi
13th August 2002, 04:11
This solution first appeared on Baanfans on July 19, 1999 at 04:23:11 EST. It works only with Unix print queues and not with BWPrint (either Unix or Windows).

~Vamsi
Mohanavamsi Potluru

<hr>

<h1>"Page of" using Barcode-Functionality</h1>

A completly other way of printing the number of pages is to use Barcode-Functionality.
The Barcode-Feature (Warning : Works only for UNIX-Printers) is in fact a API-Interface for
printing. You can merge everything you want to an existing spool. And the merging ist done
after Baan has createed the whole printing, so Baan also knows the total amount of pages.
<p>
I tried my example with an Easy-SQL and it works really fine.
<p>
In short the example works like that:
<ul>
<li>Before printing I generate a unique Spool number and print it (!!) on the report in
a field, which is connected to a Barcode
<li>At the end of printing I write the unique number and the number of pages to an ASCII-File
<li>In the filter-Program of Baan (which puts the correct Escape-Sequences to a spool) I take the
Barcode-Script (which gets the unique number as parameter) and read the corresponding
number of pages. Instead of a barcode i merge the number of pages in the Spool - Output
<p><center><b>--> there we are !!!!</b></center>
</ul>
<p>
The greatest problem is not getting the Page - number, but managing the unique numbers.
<p>
<h2> How to use the example</h2>
<ul>
<li>Print in the header of your report something like "Page : VVVVVVV of FFFFFFFF",
where FFFFFFFF is the new field
(in my example <i>int.unique.s</i> of type tcmcs.str8 and with Barcode - Type 95)
Dont care of the warning : "Input field not declared" . <b>Do not declare the field as input field</b>
<li>Warning: I think there is an error in the Baan-Barcode-API, because, when the Barcode-Field
is the last field in a line the Printer-Daemon gets mad, so i added a "." (= point) after the
barcode-Field and everything works fine. (Note: a empty field of 1 Byte works also)
<li>paste the code on this site to the report-script
<li>create (once) a subdirectory under your $BSE_TMP-folder named "printing". Make sure, that
everyone has accessrights for this directory.
<li>for each Baan-Printer(device), you have to connect the printer to a Baan- Printer-information-File
(see "technical manual" in the online help). Normally every UNIX-printer is
already connected to a Printer-Driver
<li>for each (unix-)printer you want to work with this feature you have to change
the printer driver file ($BSE/lib/printinf/.....), so that it contains a link to a
barcode-directory (there must be a line "barcodedir=xxxxxxx,"; dont forget the comma)
<li>In the barcode-directory ($BSE/lib/barcode/xxxxxx; xxxxx = name of the barcode-Directory)
create the shellscript (Name type95)
</ul>
<p><p>
<h2>Report-Script :</h2>
|******************************************************************************
|* tdsqljo07 VRC B40C c4 entw
|* mehrere Seiten und Seite von
|* bj_104_a
|* 15.07.99 [14:05]
|******************************************************************************

declaration:
long int.unique | unique number (internal)
domain tcmcs.str8 int.unique.s

before.program:
long fp
long ok
string number(8)

| Get unique number
fp = seq.open(bse.tmp.dir$() & "/printing/unique.dat","r")
int.unique = 0
if fp > 0 then
if seq.gets(number,8,fp) = 0 then
int.unique = lval(number)
endif
seq.close(fp)
endif

| Write new Unique number
int.unique = int.unique + 1
fp = seq.open(bse.tmp.dir$() & "/printing/unique.dat","w")
if fp > 0 then
seq.puts(edit$(int.unique,"ZZZZZZZ9"),fp)
seq.close(fp)
endif

| Unique Number as string for printing
int.unique.s = edit$(int.unique,"ZZZZZZZ9")

after.program:
long fp

fp = seq.open(bse.tmp.dir$() & "/printing/numbers.dat","a")
if fp > 0 then
seq.puts( edit$(int.unique,"ZZZZZZZ9")&
":" &
edit$(lattr.pageno,"ZZZZZ9"),fp)
seq.close(fp)
endif


<p><p>
<h2>Shell-Script</h2>

#!/bin/sh
#******************************************************************************
#
# File : type95
#
# jb : Print "Page of"
#******************************************************************************

# get unique number out of the printing string (8 Bytes)
unique="$1:"

# search the file with unique number for the string "Nr:xxxxxxxx"
tmpdat="`grep $unique $BSE_TMP/printing/numbers.dat`"

# get the column with the number of pages
tmpdat=`echo $tmpdat|cut -f2 -d:|head -1`

# merge the numer of pages in the spool-output
echo "$tmpdat\c"

# exit
exit 0

<hr>
I have to admit : I'm not very strong in shell-Scripting. For my Sun it works fine, but
I suppose for other UNIXES you have to change something on the script. I'm sure someone
could do this script in a better way.
<hr>
Make sure, that the shell-Script is executable !!
<p>
Make sure, that the 2 ASCII-Files in the directory "printing"
(and the directory itself) are accessible (UNIX-rights)
<p>
In case of error : Check the logfile ($BSE/log/log.filter6.1)

<p><hr><p>
The number for uniqueness ist 8 digits long, so I dont think, there will a be
a problem, but feel free to increment the size
<p>
Clear the file with the page numbers every month (or every weekend).
<hr>
<address>
Jo Büche<br>
Baan & Schuler GmbH<br>
jbueche@baan-schuler.com
</address>

Kingsto88
6th July 2005, 06:46
Hi,

Can you explain how to do this in simpler terms.
If I am using Windows, can i use this method?

Thanks and regards

norwim
6th July 2005, 09:16
This solution first appeared on Baanfans on July 19, 1999 at 04:23:11 EST. It works only with Unix print queues and not with BWPrint (either Unix or Windows).


The Barcode-Feature (Warning : Works only for UNIX-Printers) is in fact a API-Interface for
printing.

Dear Kingsto88: What remains unclear here?

Vamsi: Very clever solution indeed. I like it *g*

regards

Norbert

garias
27th February 2009, 00:51
Hello everybody:

I am researching this topic: "printing page x of y" in Baan ERP LN 6.1
I had reviewed this two important threads about this topic:
a) Vamsi - Kevin Brock's solution. Febrero de 2002
b) Vamsi - Jo Büche's solution. 12th August 2002,

Both oriented a Baan installed in a Unix S.O.
There are good job in these solutions.
Also I saw that these threads are of many years ago.

I want to know if there are an advance or upgrade in a generic o standard solution for this topic useful in windows or unix severs for Baan V or Baan LN.

Regards.

Gerardo

mark_h
27th February 2009, 00:53
Sorry to say - not that I am aware of. The best I have heard was there was a forms package that could be installed that would do this. I do not recall what the name was, but I do remember the cost was high.

Also please only post once. Here is the other thread (http://www.baanboard.com/baanboard/showthread.php?t=1079) gerardo refered to in the post.

Thanks

garias
27th February 2009, 10:15
Hello Mark thanks for your answer.

Hello Everybody:

I was working yesterday and today in a solution.
- I delevoped a simple DLL with only a external function.
Features:

- You don´t have to pass parameters to this function.
- Only have to put the function in the after.program section of your report script
- And of course to put *GA* in the layout where you want that the total page number appear. As you can see
max a 9999 total pages because *GA* are four characters.
- This solution is for WIndows and Unix Baan Server. No matter in which S.O Server is installed Baan.
- At the present time the solution is for Infor LN 6.1. But I supposed that it could be work in previous versions.
- It function don´t have to process the report two times. only one time.
- You don´t have to put any additional conversion program in the device.
- I have tested it with a Windows printer (BW) and with some customized reports. (I am going to test with more devices..)

If you are interesting I may send you, by now, the DLL object as a "black box" to test it. When I finished it I could put it here.

A more complex case:
When you print a report with a range of documents
And you get some independent documents (e.g. invoices, orders) in
the same report (spooler) , and you have independent page numeration for every
document. And you want to print an independent total page number for every one
document.

The actual version of my dll don´t cover this last case. But I am going to work in this case.


That´s all

Gerardo

thaykhov
21st July 2009, 07:14
HI Gerardo

Can you post your solution? I am looking for page x of y for my invoices/sales orders

Regards

Thay

Altrev
26th November 2009, 21:49
Hello Mark thanks for your answer.

Hello Everybody:

I was working yesterday and today in a solution.
- I delevoped a simple DLL with only a external function.
Features:

- You don´t have to pass parameters to this function.
- Only have to put the function in the after.program section of your report script
- And of course to put *GA* in the layout where you want that the total page number appear. As you can see
max a 9999 total pages because *GA* are four characters.
- This solution is for WIndows and Unix Baan Server. No matter in which S.O Server is installed Baan.
- At the present time the solution is for Infor LN 6.1. But I supposed that it could be work in previous versions.
- It function don´t have to process the report two times. only one time.
- You don´t have to put any additional conversion program in the device.
- I have tested it with a Windows printer (BW) and with some customized reports. (I am going to test with more devices..)

If you are interesting I may send you, by now, the DLL object as a "black box" to test it. When I finished it I could put it here.

A more complex case:
When you print a report with a range of documents
And you get some independent documents (e.g. invoices, orders) in
the same report (spooler) , and you have independent page numeration for every
document. And you want to print an independent total page number for every one
document.

The actual version of my dll don´t cover this last case. But I am going to work in this case.


That´s all

Gerardo

Hi Gerardo,

Did you had a chance to post your "Single pass: Page x of y" library?

I think that it will be a great tool.

Thanks.

pralash
20th February 2018, 08:08
Hi,

I have seen your post regarding to print the page number in the report as Page 1 of 5, Page 2 of 5... etc...

Can you please assist me how to perform this task by using sample scipt....

Thanks in advance,
Regards,
Pralash

günther
20th February 2018, 10:50
Hi Pralash,

you are on Windows, the presented solution only works on Unix.

pralash
20th February 2018, 13:44
Hi,

Oh i see... So is there some other solutions are available in windows for print the page number as Page 1 of 5, Page 2 of 5 etc?

Please assist me....
Thanks in advance,
Regards,
Pralash

andreas.toepper
21st February 2018, 08:26
If you are using LN 10.3 or a later release, you can also check solution 1841512. Buts its limited to creating pdf only and it will print "x / n" (n = number of pages)..