Jump to content


Photo

Document Formatting - Controlling Layout - Please move if wrong forum.


  • Please log in to reply
8 replies to this topic

#1 roopurt18

roopurt18
  • Staff Alumni
  • Advanced Member
  • 3,749 posts
  • LocationCalifornia, southern

Posted 01 September 2006 - 09:01 PM

This is a bit to read but I really appreciate any help in this matter.

I'm looking for a solution to a formatting problem.  Since I don't know which technology (PHP, CSS, JScript, etc.) will provide the best solution, I'm posting in this forum.  Please move this post into the appropriate forum if necessary.

The site is driven by PHP, MySQL, CSS, and Javascript so I'm open to any solutions involving those languages / technologies.

One feature of the site is to allow our clients to automatically upload purchase orders (POs) for their contractors to view online.  The contractors log in, view their POs, and print them on a standard 8 1/2" x 11" sheet of paper.  The problem is each PO follows the same basic layout, but specifics need to change according to our clients' data.

Each PO has a header and footer which need to be printed on each page of the PO.  Then there are a variable number of items to be printed in a table layout.  The items are optionally followed by a variable length custom verbage, typically legal information.  The factors controlling the number of pages in a PO are the number of items in addition to the length of each item and the length of the custom verbage.

Layout of 1 Page in a PO
Posted Image

Image of a good PO - We can see that this PO is nicely laid out.
Posted Image

Bad PO #1 - Here the verbage is too long and overlapping the footer.
Posted Image

Bad PO #2 - Here the PO has extended to two pages.  The cause is some of the PO items are too tall.  This is causing a second page to be generated without the header and footer copied.  We can also see that the footer is being overwritten by the items that didn't fit on the page.
Posted Image

Current Method for Generating a PO
The header and footer are the same size on every PO.  The number of items for a PO are counted and based off of 10 items per page the total number of pages is calculated.  As each 10th item is printed, a new div with the style="page-break-before: always;" is created that includes the header.  Then the items are printed from where the previous page left off.  On each page, the footer is positioned absolutely with CSS.

Probable Solution
I'm thinking I'll have to calculate how tall each line of text is on the page and instead of page-breaking every 10th item, I'll page-break when printing the next item will extend into the footer.  However, the height of each line may not be the same for every client.  I can try and control it with CSS but there are no absolute garauntees that I know of.

So before I go fussing around with that, is there a reliable method, perhaps PHP or JScript standard that will tell me tall a chunk of text will be on the final page?

It would be nice to do something like:
PrintHeader();
foreach(Item){
  if(ItemExtendsIntoFooter()){
    PrintFooter();
    PageBreak();
    PrintHeader();
  }
  PrintItem(Item);
}
// I will then need to print the custom verbage, which may extend to one or more pages.
$Verbage = GetVerbage(); // Return verbage text that will fit on the current page
do{
  PrintText($Verbage);
  PrintFooter();
}while($Verbage = GetVerbage()); // Continue until no more verbage

I'm thankful for any responses.
PHP Forms : Part I | Part II

JavaScript: Singleton

http://www.rbredlau.com

#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 01 September 2006 - 09:05 PM

Why not ask people to upload their P.O. as a pdf or generate a pdf from the information they supply?
Legend has it that reading the manual never killed anyone.
My site

#3 roopurt18

roopurt18
  • Staff Alumni
  • Advanced Member
  • 3,749 posts
  • LocationCalifornia, southern

Posted 05 September 2006 - 05:17 PM

Why not ask people to upload their P.O. as a pdf or generate a pdf from the information they supply?


The P.O. data is coming from server-software.  Previously, client's had to generate a P.O., create a pdf, and then upload it.  If the P.O. had to be revised, they would have to repeat the entire process.  Our client's are home builders, some of which generate hundreds of P.O.s per day.

Now we're sending data from the server-software to our site via a dbf file and what used to take our clients an entire afternoon or day now takes about 5 minutes.
PHP Forms : Part I | Part II

JavaScript: Singleton

http://www.rbredlau.com

#4 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 05 September 2006 - 05:22 PM

.. so you automatically generating a pdf from the data is not an option?
Legend has it that reading the manual never killed anyone.
My site

#5 roopurt18

roopurt18
  • Staff Alumni
  • Advanced Member
  • 3,749 posts
  • LocationCalifornia, southern

Posted 05 September 2006 - 06:25 PM

I don't see how generating a PDF is going to save me any trouble.

My problem at the moment is that not every line in a P.O. is the same height and there's no real method to control it via HTML and CSS.

If I generate PDf documents with the information they supply, it's a whole other can of worms.  Do I generate the PDF every time they view the P.O. and delete it at the end of the day?  Or do I generate it once and keep it around for a while?  Then I'd have to go through the trouble of formatting the PDF.  Our webhost has PDFLib Lite installed, which means it can only write a single line of text at a time, no text areas.  That puts me right back at square one:  How much text fits on a single line?

Unless you know something about PDF generation I don't, I'd rather not go that route.
PHP Forms : Part I | Part II

JavaScript: Singleton

http://www.rbredlau.com

#6 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 05 September 2006 - 07:49 PM

I suggested pdf because - unlike web pages - there is absolute control over the position of headers and footers AND they can be forced on to every page of a multi-page document regardless of how many pages the document has.  pdf files can be generated on the fly, with headers and footers.

http://www.rustyparts.com/pdf.php

That might help. Other than that I can't think how you can handle the random/variable length of user input while having some sort of absolute position control in a printed document.  Trying to count lines and work out the height of things is going to fall apart as soon as a user changes the font size.
Legend has it that reading the manual never killed anyone.
My site

#7 roopurt18

roopurt18
  • Staff Alumni
  • Advanced Member
  • 3,749 posts
  • LocationCalifornia, southern

Posted 05 September 2006 - 08:02 PM

From first glance it looks as if that just converts from HTML to PDF.  I guess there's no way to escape the problem of calculating just how much text fits on a line.  The best I can hope to do is control it with the PDF format.

Meh!
PHP Forms : Part I | Part II

JavaScript: Singleton

http://www.rbredlau.com

#8 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 05 September 2006 - 09:52 PM

Thanks, anyway? At least I tried.
Legend has it that reading the manual never killed anyone.
My site

#9 roopurt18

roopurt18
  • Staff Alumni
  • Advanced Member
  • 3,749 posts
  • LocationCalifornia, southern

Posted 05 September 2006 - 10:23 PM

Don't get me wrong, I'm glad you replied and I do appreciate it.  My disappointment isn't with you at all AndyB, but with the fact that there isn't an easier way.
PHP Forms : Part I | Part II

JavaScript: Singleton

http://www.rbredlau.com




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users