Jump to content

Archived

This topic is now archived and is closed to further replies.

roopurt18

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

Recommended Posts

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.

[b]Layout of 1 Page in a PO[/b]
[img]http://www.ibswebview.com/test/po_imgs/po_format.JPG[/img]

[b]Image of a good PO[/b] - We can see that this PO is nicely laid out.
[img]http://www.ibswebview.com/test/po_imgs/good_po_01.JPG[/img]

[b]Bad PO #1[/b] - Here the verbage is too long and overlapping the footer.
[img]http://www.ibswebview.com/test/po_imgs/bad_po_01.jpg[/img]

[b]Bad PO #2[/b] - 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.
[img]http://www.ibswebview.com/test/po_imgs/bad_po_02.jpg[/img]

[b]Current Method for Generating a PO[/b]
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 [b]style="page-break-before: always;"[/b] 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.

[b]Probable Solution[/b]
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:
[code]
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
[/code]

I'm thankful for any responses.

Share this post


Link to post
Share on other sites
Why not ask people to upload their P.O. as a pdf or generate a pdf from the information they supply?

Share this post


Link to post
Share on other sites
[quote author=AndyB link=topic=106555.msg426205#msg426205 date=1157144719]
Why not ask people to upload their P.O. as a pdf or generate a pdf from the information they supply?
[/quote]

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.

Share this post


Link to post
Share on other sites
.. so you automatically generating a pdf from the data is not an option?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.