How to take a high-resolution screenshot including OnGUI()?

I have a game with a little OnGUI() interface and I want to take a screenshot that is 8K big, so I can print it on a poster. How can I take a screenshot including the OnGUI()?

I guess you could close this for being a duplicate question ( Super-High Resolution Camera - Questions & Answers - Unity Discussions, How Do I Take a Super High Res Screenshot? - Questions & Answers - Unity Discussions ).

You can use Application.CaptureScreenshot and pass in a value for the superSize parameter to have Unity render a frame at a higher resolution (presumably using render to texture) and use that for the screenshot.

You can also create your own camera that renders to a high resolution render texture and do a manual render with that camera. I assume that’s pretty much what CaptureScreenshot does. You might need to do this in order to include the GUI.