I have used the solution from this stack overflow answer https://stackoverflow.com/a/64169219/16877178.
It works well and adds the page number, but sadly it removes the outlines/bookmarks from my pdf. Anyone here that can tell me a better way to add page numbers to a pdf in python or show me a way to keep the bookmarks?