-1

I'm working on an e-shop. At some point in my code I have to show attributes and descriptions for many products in a single page.Attributes are a table and description can contain simple text and table,li,br tags etc...These which are stored in the database as html encoded string. So in my php file I load them from the db and decode them like this.

$description=html_entity_decode($description_from_db, ENT_QUOTES, 'UTF-8');
$attributes=html_entity_decode($attributes_from_db, ENT_QUOTES, 'UTF-8');

Later on I just do echo $description; an they are shown properly. All this HAS TO BE PRINTABLE and here comes the challenge.

When the attributes table and the description are long enough the exceed the printable page height and they get cut in half looking realy ugly. What I want to do is split the $description and $attributes strings and echo them with page breaks between the pieces where neccesary. The problem is that this must be done with respect to the tags inside these strings. I can't for example break the string in the middle of a tr tag.

Is there a way to break these strings maintaining the html elements that they contain intact ? I'm thinking it must be possible since html editors show a warning when a tag has been left unclosed.

Anonymous
  • 3,564
  • 3
  • 32
  • 56

1 Answers1

0

You can put page breaks in your HTML code, then the HTML will choose where to break itself:

https://css-tricks.com/almanac/properties/p/page-break

http://davidwalsh.name/css-page-breaks

KIKO Software
  • 10,480
  • 2
  • 13
  • 28
  • I am aware of that. The problem is that I have no control over these strings. They are allready stored by others in the database for 1500 products without printing in mind. So manipulating them in code seems the only way to do it. – Anonymous Mar 02 '15 at 19:53
  • Well, the only thing you can do then is search for possible locations to put these page-breaks. For instance in a
    .

    ,

    and
    . But it will be difficult to make it work right all the time. You're the only one who can find out.
    – KIKO Software Mar 02 '15 at 21:25