Fitting More Code On Printed Page In Notepad++

codefontsnotepadprintingsource code

At the moment, I'm trying to print a snippet of code that is about 1.03 pages long. The last several lines start on the next page. As a result, I waste an entire page, and it's also much harder to follow because it's on two pages.

After much effort, I managed to locate the ability to change the font size, however when I decrease the font size it actually doesn't seem to fix the problem. I decreased the font size from 10pt to 8pt, and there are still the exact same number of lines on the first page. The characters are indeed smaller, however it seems that the line height is the exact same. When I put the two pages side by side, the lines line up exactly.

The reason I'm printing with Notepad ++ directly is to preserve the filename and line numbers. So if there isn't a way to get Notepad ++ to do this, is there an online utility of some kind which is directly for this purpose? To be clear, I need to have only the small selection of the code printed, not the entire file, or I need to start the line numbers at a value higher than 1. All of the utilities I found so far typically did not give me output I could directly print, and I have yet to find one that has a line number offset or the ability to put the filename in the header.

Limited solutions:

  • Printing from Notepad ++. Fails to fit the code on the page.
  • Copying into Microsoft Word and adding line numbers manually. This is quite labour intensive, and I'd like a solution that works very quickly to print code. Also, no syntax highlighting unless I do it manually.
  • Copying into Microsoft Excel. This removes the need to manually increment the line numbers, but formatting is quite limited and there's once again no syntax highlighting unless I do it manually.
  • Does not print C++ syntax highlighting. No way to change line number. Lots of headers and footers in printed output.
  • Prints with a massive header. No way to adjust line numbers.
  • and copy into HTML and then print from browser. Requires manually adjusting all the line numbers.
  • Messes up the formatting and does not add line numbers.
  • Making my own utility. While I could do this fairly quickly, the syntax highlighting seems like it would be much more complex than any other part.

The code is C++ code. I'm hoping for a solution that isn't limited to C++ though. If I have to, I'll make my own utility and forego syntax highlighting, but this seems like something someone would surely have done already.

Best Answer

The following works for me. Go to Settings > Style Configurator. Set the font size to something slightly smaller than the current setting. In my case it was 11 pt, so I set it to 10. Make sure you tick "Enable global font size". The default is "blank" (at the top of the list), which seems to be about 10 pt.

That will change the font size of the whole document to the new size, and it will print in that size. A change from 10 to 9 pt should fit your document on 1 page.

Another thing you can try is to remove headers and/or footers, by removing the current entries for them in Settings > Preferences > Print. Before you do that, you may want to write down what they are...