It’s not really a “screen capture” at that point if you want content that’s not visible on the screen.
But that having been said, if your app will let you print the document/page, you should be able to print to a PDF file (or to the Preview app).
Of course, you may not get the same thing. For instance, when I tried printing a TidBits Talk page by typing CMD-P, it opened a popup window with a magic URL ( First impressions of macOS 26 Tahoe ) that has every post in the topic, formatted with a different (print-oriented) template and tries to print that. Completely different from a screen-shot.
(If I use Firefox’s menu-bar to print, what I get is an ugly mess, probably due to Discourse’s infinite-scroll logic. I assume that’s why CMD-P generates a differently-formatted version of the content.)
This reminds me of a situation at one of my first jobs. We were selling a GUI library package. Among its features was a novel (at the time) “print screen” feature where, instead of capturing and printing pixels from the screen, it told the app to re-draw its window using a drawing-context object associated with the printer. This would generate PostScript on Mac and Unix platforms (and would make platform-specific drawing-primitive calls on Windows and OS/2). The result was a beautiful rendering at the printer’s full resolution, with razor-sharp text and vector graphics. We’d use these screen-shots in our advertising literature, which caused reviewers to accuse us of publishing mock-ups, since the (72 dpi) screens of the time didn’t look nearly as good.