To add a pagebreak to the text file

Posted on 2014-08-08
Last Modified: 2014-09-09

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.
Question by:pvsbandi
    LVL 32

    Assisted Solution

    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.
    LVL 11

    Assisted Solution

    by:Joseph O'Loughlin
    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.

    Author Comment

    Would it be possible to give an example code based on the attached text?
    LVL 11

    Accepted Solution

    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.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    Recently I finished a vbscript that I thought I'd share.  It uses a text file with a list of server names to loop through and get various status reports, then writes them all into an Excel file.  Originally it was put together for our Altiris server…
    In this article we want to have a look at the directory attributes which are used by Microsoft to store the so called Security Identifiers (SID). These SIDs plays an important role in delegating and granting permissions and in authentication of trus…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now