Use the following properties: "DocumentUseCustomExtensions" and "DocumentExtensions"
See examples:
https://docs.kentico.com/api9/content-management/pages#Pages-Pagemanagement
and use:
page.SetValue("DocumentExtensions", ".pdf");
page.SetValue("DocumentUseCustomExtensions", true);
although I'm pretty sure you can set them directly
node.DocumentExtensions = ".pdf";
node.DocumentUseCustomExtensions = true;