In google docs, when we paste lot of data it automatically splits it into pages which are printer friendly, How can I build this basic google docs type functionality. The source of data will be fetched from database instead of paste.
You could gradually fill a div with text using JavaScript. Check the height after each word and after reaching a certain height (e.g. ~25cm for DIN A 4) insert a new paragraph tag with page-break-before: always
to break the page in the print.