Hello,
Using modifyPageLayout (https://www.phpdocx.com/api-documentation/layout-and-general/modify-Word-page-layout-with-PHP) you can set custom values: width, height, marginTop... you need to apply custom as paperType. Other paper sizes are preset values of these options.
Regards.