Printing in columns

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 

                I need some guidance here.  I've been fighting with this
problem for a few days now and not having a whole lot of luck.  I have some,
but I run into issues sooner or later.  So I'm hoping that someone here can
give me some ideas of how to better approach this, perhaps help with coding
as well.

 

                My data consists of a number of addresses in any number of
US states.  I need to format them as such:

 

                - have a title that consists of the state name, spanning the
full width of a

                - have all the addresses pertaining to that specific state
split into two columns and displayed below.

                - output everything to Letter size PDF.

 

                In very simple form, it looks something like this (hoping
this doesn't get mangled in formatting):

 

+-----------------------------------+

|           STATE NAME              |

+-----------------------------------+

|  Address 1      |   Address 5     |

|  Address 2      |   Address 6     |

|  Address 3      |   Address 7     |

|  Address 4      |                 |

+-----------------------------------+

 

                So far what I've been able to get done is so the data
sorting and matching up the addresses with their states.  I can format the
address the way I want them displayed and all.  All the way to where I start
outputting the data.  However .

 

                I have to account for page length so that my data doesn't
run past the page.  I have to account for the possibility that the current
state being processed will have some lines on one page and some more on the
next page . which is fine, but when that happens, I want the title repeated
on the next page like so: STATE NAME (Cont.)

 

                So here's how far I got:

                - grab data from CSV file

                - process/sort data

                - loop through data, line by line, inserting same state
addresses into an array()

                - when I encounter a new state, I move to output the current
contents of the array()

                - when it's time to output the array, I do:

                                - array_chunk($array, ceil(count($array)/2))

                                - output chunks into respective column

 

                The problem I have is when I reach the bottom of the page
while printing the first chunk.  Let's say I have 120 records to print, and
I only have room for 23 lines.  So initially the array gets split into two
chunks of 60 records each.  I start outputting data.  I reach the end of the
document and still have 37 lines left, so now what?

 

                Right now I'm thinking I need to take that remaining data,
merge it with the second chunk and start outputting that into the second
column till I reach the bottom of the page again (which would be 23 lines
later.)  At that point I will still have 74 record left (14 PLUS the initial
60 lines that was the original 2nd chunk.)  I start a new page, add the same
state name title, and go through the motions again of rechunking the
remaining data and outputting again.

 

                Does any of that even make sense?  Am I going on about it
the right way?  Is there a better way to do this to begin with?

 


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux