To add a pagebreak to the text file


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.

 Please help.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ste5anSenior DeveloperCommented:
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.
Joseph OLoughlinIT Support SpecialistCommented:
Ste5an is correct.  For printers that recognise the epson esc 2p codes the escape sequence for a form feed is per
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.
pvsbandiAuthor Commented:
Would it be possible to give an example code based on the attached text?
Joseph OLoughlinIT Support SpecialistCommented:
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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.