In Word I have a code screenshot.
I tried to convert it using many different ways (save as PDF, export to PDF, Print to PDF (Microsoft, Adobe, CutePDF), Adobe Acrobat (paid) Create PDF / Convert PDF (via plugin and application), various converter tools (PDFgear, pdfcreator, CutePDF, LibreOffice, other Word version).
And I tried various settings, such as High Quality, No compression, No loss, Embed fonts, Press-ready PDF (PDF/X) (which failed).
But I couldn't get the exported PDF to look the same. It varies in quality, some options are better than others, but none of them result in the exact same output. It is quite frustrating as I simply want to send a document for professional printing and I need a PDF, but I didn't expect it to be so difficult to get quality output from Word to PDF.
What would be the best option? And which settings do I use?
This is the screenshot in Word
And this is the best output I got (from PDFgear)
Update (two weeks later!)
As @John answered, by accident, almost two weeks later, I figured out that copying text from VSCode into Word in fact keeps the formatting, including the background! I should have done that way earlier. I might actually change all these screenshots, though I'd still say the accepted answer seems most suitable for the question about any type of screenshot.