To add a pagebreak to the text file

pvsbandi
pvsbandi used Ask the Experts™
on
Greetings,

I have a text file (attached).
 I have a requirement to add pagebreaks to a text file.
So, wherever the header with the below text shows up, we need to move it to the next page.
"1REPORT ID:  SIDFA2PR                              ADULT SUPPORT ENFORCEMENT SYSTEM " 

 Please help.
Report-03.txt
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
ste5anSenior Developer
Commented:
There is no such thing like a page break in a text file. Whether there is a "page break" or not depends on the output device. The only thing which exists is the form feed ASCII character (FF, 0x0C).

So you need to read you text file line by line. When the line is your header line add the FF in front of it.
Commented:
Ste5an is correct.  For printers that recognise the epson esc 2p codes the escape sequence for a form feed is per
http://www.fidcal.com/printercodes/
charcter 12 in decimal, C in hex.
This assumes there's no header on the file when sent to the printer instructing the printer to treat the file as postscript or another page description language.

Author

Commented:
Would it be possible to give an example code based on the attached text?
Commented:
The format looks like a VM CMS Spool file from an IBM mainframe or similar, where the first column dictates page breaks etc, with
1 indicating a page break and
0 indicating that the line is longer than the report width, e.g. a 128 column line wrapped to 80 columns.
Your code will need to
Loop through all the lines of text.
Check whether the left most character is a zero character.  If it's not the first page, output a page brake, then the rest of the line.
Optionally, if the first character is 0, append the following line (tricky flow control in your loop).
You are likely already familiar with the left command.
http://msdn.microsoft.com/en-us/library/y050k1wb(v=vs.90).aspx

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial