I have an ASP/VB page that outputs text (as a stream), for a report, that my users print (All of the text is inside of a PRE tag). I've modified the output to include css so that the page will break at the appropriate spots.
@media all
{
.page-break{ display:none; }
}
@media print
{
.page-break{display:block;page-break-before:always;}
}
I read in the stream, loop through each line and check for the text
PAGE: I then prepend the following html code in front of the line that includes
PAGE:
<div class="page-break"></div>
05/25/2012 12:55 PACKING LIST PAGE: 002
This works the way I want it to. The problem that I'm having is that I have two blank lines that are directly above the break point that I want to remove. I know that I can simply
not write those blank lines, as I go through my for each, but here is where I'm having my problem. There are other areas in the output that has blank lines that I don't want to remove. So I can't simply remove every blank line that I come across. I only want to remove the blank lines that are directly above my page break.
Here is a portion of my code:
dim obPageStream
set obPageStream = obPageData.Stream
dim bytes
dim bytetext
dim text
dim lines
dim line
do
bytes = obPageStream.Read(8192)
bytetext = BinaryToString(bytes)
text = text + bytetext
loop while ubound(bytes) > 0
lines = Split(text, vbCrLf)
for each line in lines
if InStr(line, "PAGE:") > 0 then
if InStr(line, "PAGE: 001") > 0 then
Response.Write(line + vbcrlf)
else
Response.Write("<div class=" + chr(34) + "page-break" + chr(34) + ">" + "</div>" + line + vbcrlf)
end if
else
Response.Write(line + vbcrlf)
end if
next
Response.End()
As you can see it's very simple. Any help that you all can offer would be greatly appreciated. Thank you very much!