Did you enable pd4ml.adjustHtmlWidth() mode? In this case, it scales the content down to fit the target page (in its initial portrait format). So after turning the page into landscape, its “extended” right side will always be blank.

If you enabled pd4ml.adjustHtmlWidth() mode, first try to switch it off.

The samples from https://old.pd4ml.com/cookbook/pdf_dynamic_format_change.htm seem to implement exactly what you needed