Is it possible to implement paging similar to MS Word in a rich text editor using JavaScript.

I need to implement an editor using JavaScript that contains text in pages. If i type text that exceeds the ficed limit of a page then automatically a new page is created and text overflows to the new page with formatting intact. Also if I copy large text from another source then it should calculate the number of pages depending on the text length and divide it into pages with all the formatting of the original text.

I need to break the text into lines based on pixel size using only JavaScript, HTML and CSS.

If i delete contents from inside a page then contents from the next page should be populated in the current page and if all the contents from a page is deleted then the page should be deleted. Almost every paging feature in MS word should be implemented in this one.