I know about standard way (see, e.g. here) to use publishing web in CSOM to create new pages in Pages library. The same code conditionally works in document libraries, but only partially: pages are created fine, but are not possible to edit afterwards. SharePoint editor gives a sort of internal error on them when you try to save changes.
However, in the same library where automatically created pages are not possible to edit, it is fairly possible to create new pages manually and edit them successfully.
Question is, how to make similar things in code and create a page in document library without using publishing web approach, which evidently does not work there, but still obtain a valid page, as it is done manually? Thank you.