Added LayoutManager to handle page & measure margins.

Moved margin managing part from parser to LayoutManager.