By the way, use this code in page resize. I got many issue when loading a layout and editing dimension after load. After some checks I see that in page resize dimension will get designer value, so after moving dimension editing in page resize event all works properly l. I hope this can help you