[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 853
  • Last Modified:

To add a pagebreak to the text file

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
0
pvsbandi
Asked:
pvsbandi
  • 2
3 Solutions
 
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.
0
 
Joseph O'LoughlinCommented:
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.
0
 
pvsbandiAuthor Commented:
Would it be possible to give an example code based on the attached text?
0
 
Joseph O'LoughlinCommented:
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
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now