6

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

enter image description here

And this is the best output I got (from PDFgear)

enter image description here

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.

8
  • 3
    If you have acrobat pro, the fastest is to edit the pdf, delete the image and re-insert it from the original file (right-click -> place image)
    – 1NN
    Commented Jan 26 at 21:30
  • 1
    @1NN I finalized the job after a couple hours saving original images and replacing them. It was a lot of work, but at least my PDF has quality images now! Thank you!
    – Z0q
    Commented Jan 27 at 0:48
  • 1
    @Z0q the problem is less about downsampling but the compression used. JPG is utterly unsuitable for anything requiring sharp details, including screenshots. If you want better quality, use ZIP compression only. The resulting PDF will be larger, of course, this is the price to pay. You can try downsampling and ZIP, but you have to decide whether it's OK for you.
    – Gábor
    Commented Jan 27 at 22:15
  • 2
    Third, well, professional printing and Word doesn't really go hand in hand. :-) Of course, it will probably be out of your area of expertise, but if you need something to be printed professionally, you should normally use an appropriate desktop publishing program, not a word processor. (And preferably inserting the code fragments as text, not image).
    – Gábor
    Commented Jan 27 at 22:20
  • 10
    Also, next time around, you could try to invert the color scheme, white background. You may prefer dark mode on your monitor but there's hardly any reason to make it so in printed text. Actually, it's much harder to print in good quality and much harder to read in the end. Not to mention the amount of ink wasted. :-)
    – Gábor
    Commented Jan 27 at 22:27

7 Answers 7

9

The issue is that images will be downsampled in pdf files, usually to 300dpi. But you can change that

  • In Word, go to 'Print..'
  • select Adobe pdf as your printer
  • open printer properties
  • from the "default settings", choose "high quality print", then click on "Edit..."
  • Select "image" on the left-hand side, then under "color images", set "Bicubic downsampling" to at least 600 dpi. Experiment what gives you an acceptable quality.

See the below screenshot for reference: enter image description here

EDIT

I realize now it is possible to simply turn downsampling OFF, as in the following screenshot. Like that, images retain their full resolution. However, since images are transformed to jpg, file size might increase in respect to original png files with indexed colors.

enter image description here

7
  • 2
    Great solution, but is this available on Adobe Reader or only paid versions of Acrobat? A DPI of 1200 is the minimum to ensure quality isn't lost, 600 will result in subpar quality when zooming in at >100%
    – JW0914
    Commented Jan 27 at 13:12
  • It is much better, but there are still some glitches, such as letters in sentences being cut off in a line / row. For example a bit from the top of all letters on a certain line, while other lines are in tact
    – Z0q
    Commented Jan 27 at 13:30
  • When setting the minimum DPI to 1200 It seems to provide the same quality. However, the newly created PDF is 265 MB instead of the 13 MB PDF that I have when replacing the images manually
    – Z0q
    Commented Jan 27 at 14:05
  • @Z0q See my edit. And yes, png will probably use less space than jpg, since it uses indexed colors.
    – 1NN
    Commented Jan 27 at 20:27
  • 1
    @1NN PNG does use less space, but PDF doesn't support PNG directly, AFAIK. What other options are available in Compression dropdown (besides JPEG)?
    – trlkly
    Commented Jan 27 at 22:39
6

To get the best PDF quality, copy the text on the screen and paste into the Word document; that is, do not depend on the screen shot (variable document quality).

Done as suggested, following conversion into PDF is excellent.

I do it as I have suggested here.

The other possibility is Acrobat Pro to convert. I have used Pro and it is good but still has limitations. This may be helpful in the case of very numerous screen shots.

3
  • Thank you, I thought about this and will consider it if I don't find another way to convert the document as-is including hundreds of screenshots :)
    – Z0q
    Commented Jan 26 at 21:43
  • Hundreds of screen shots: you are kind of stuck here. Maybe try a trial of an OCR reader
    – anon
    Commented Jan 26 at 22:47
  • By accident 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, though I'd still say the accepted answer seems most suitable for the question about any type of screenshot.
    – Z0q
    Commented Feb 7 at 10:25
6

In regards to the image resolution, I have a few things to note, and all of them are explained in more detail in a video.

If you really want to use a screenshot, keep the following things in mind

  • Try to insert an image with a very high resolution. So, if you can, zoom in on the code to create a "larger" screenshot.
  • Set the image quality options for your Word document to "High Fidelity" and make sure that image compression is deactivated.
  • when you save your Word document as a PDF, make sure that you select the best export settings (Optimize for "Standard", "High Fidely", etc.)

And this is really all you can do when it comes to screenshots. Of course there are third-party PDF export plugins for Word, but all of them will have some image quality loss.

What do I recommend instead?

  1. Paste the code directly into the Word document
  2. Create yourself a "code" style, which automatically formats the code nicely
  3. Optionally you can also use Notepad++ to paste the code into Word while preserving syntax highlighting, and then apply the style from step 2 so that the code sticks out compared to the rest of the document.

Added: And reading through the comments I saw that you are working with hundreds of screenshots. In this case, try the mentioned OCR functionality. For code it might not work in the best way but you could still give it a shot. Simply put all screenshots in a Word document and export the document as a PDF. Then open it in Adobe Acrobat Pro (they usually offer a free 7-day trial if you don't have it) and use the OCR function to make the code selectable. Like that you should be able to copy/paste it into Notepad++ for example where you can then activate syntax highlighting and afterwards you can copy/paste it nicely into Word.

3
  • 1
    @KJ I missed that indeed, but note that the answers here are not always only for a single individual but also for other people who might come here in the future and have the same problem. Since the copy/pasting with syntax highlighting and code-snippet box style wasn't mentioned in any other answer, I wanted to point out that approach.
    – Loeli
    Commented Jan 27 at 13:46
  • 1
    Worth noting that compression is only bad for image quality when you're using a "lossy" image format, such as jpg. If you have pngs (and if they don't get converted to jpgs is the process), then compression positively affects file size without negatively affecting quality.
    – jpaugh
    Commented Jan 27 at 21:34
  • While the question does not go for this answer, it is important. When I was working as a TA, I was ordered to reject documents which contained screenshots of code. Plain and simple. Text must be included as text so it can easily be read, searched and copied. There is no reason to rasterize text.
    – Hermann
    Commented Jan 28 at 23:00
2

I finalized the job after a couple hours saving original images and replacing them in Adobe Acrobat Pro as suggested by @1NN.

It was a lot of work, but at least my PDF has quality images now! Thank you!

0
2

Export the original text to PDF (from your IDE or whatever you have it in). Then convert the PDF to SVG (try both with text to path or preserve text as text) and insert the SVG. This way you have a vectorized image rather than a bitmap, which will preserve the quality (and reduce the file size).

3
  • Who downvoted and why? This method will give perfect result. It might be a bit more tedious than other methods (but not that much) so it all depends on your requirements.
    – d-b
    Commented Jan 28 at 1:17
  • 1
    I'm confused by the -1 too; for text screenshots, this is a viable approach. Upvoted. Perhaps the downvoter didn't understand that by "original text" you meant the text in the screenshot? It might be worth editing your answer for more verbosity and clarity.
    – marcelm
    Commented Jan 28 at 10:38
  • @marcelm Thank you for your upvote. I think the "from the IDE"-part is reasonably clear, don't you agree?
    – d-b
    Commented Jan 28 at 13:43
1

The problem starts with high resolution input (more than default Screen Level of 96 dpi)

follow the sizes and we see at 100% Word has reduced the quality during import to 75% size (This is a common error in MS Edge too, where the opposite happens and page size is stated as upscaled to 133% mm compared to real units ! Once the image has been downscaled it is also down sampled to 96 DPI and that is used for export to PDF. Hence as suggested the only way to improve the PDF is replace with the original.

enter image description here

For the future since we know why, we can ensure the import is 96 dpi and then it stays that way.

enter image description here

1

For consistent quality output from Word to PDF, consider using online platforms like Systweak PDF editor (official website), ensuring you select high-quality settings and embedding fonts for professional printing.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .