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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to print exact pages ? 1

Status
Not open for further replies.

KevinMcKloud

Programmer
Jun 8, 2002
22
MX
Hola, i have this text file:

=====
a
=====
b
=====
c
d
=====
e
=====
f
g
h
=====
i
=====

but the whole file doesn't fit in 1 single page
when printed.

it prints for example this:

===== <-- begin of printed page 1
a
=====
b
=====
c
d
=====
e
===== <-- this should have been in page 2
f <-- this should have been in page 2
g <-- this should have been in page 2
-------------- <-- end of printed page 1


h <-- begin of the printed page 2
=====
i
=====

...
So, i don't want the last 'f, g, h' to be printed
separately !, how do i start printing the next page (2)
beginnin with the &quot;=====&quot; line ???

Thanks =)

Kevin
 
Hi Kevin!

Simply edit in a control &quot;L&quot; (^L) immediately following the last line of each page.

This will cause the printer to form feed exactly where you want it to!

Hope this helps you.


flogrr
flogr@yahoo.com

 
This awk program may do what you want. Set the lines per page variable (lpp) to the maximum number of lines you want on a page.
Code:
BEGIN { lpp=5 }
{
  if (NR > 1 && $0 == &quot;=====&quot;) {
    if (np + n > lpp) {
      print &quot;^L&quot;
      np = 0
    }
    for (j=0;j<n;j++) print a[j]
    np += n
    n = 1
    a[1] = $0
  }
  else {
    a[n++] = $0
  }
}
Hope this helps. CaKiwi
 
Thanks CaKiwi!... it works perfect your program.
.. the only change i did was not to use &quot;^L&quot; char,
but instead i used: printf &quot;\f&quot; coz is in
ms-dos and ^L is not recognized as 'form feed' char

=]

kevin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top