Working on a Mac

Export code to PDF with syntax highlighting

You can do this with Note My, with the colouring intact. Here is which route to take, what governs the page, and when the print dialogue is the better one.

Someone has asked for the code as a PDF. A reviewer who will not clone the repository, a supervisor who wants an attachment, a compliance folder that takes documents and nothing else. A screenshot is unreadable by the third page, and a plain text file loses every colour that made the structure legible. What you want is a document that still reads like code: coloured, numbered down the margin, readable on a printed page.

Note My exports one directly. This guide covers where the export lives, what survives the trip out of the editor, how it differs from printing to PDF, and the handful of things that catch people out.

Note

The export runs entirely on your Mac. Nothing about the file is uploaded, there is no account and no sign-in, and the document never leaves the machine.

Export the file as a PDF

  1. Open the file and check what language it is in

    The colours in the PDF are the colours in the editor, so a glance at the screen tells you exactly what you are about to get. Fifteen code languages are coloured: Swift, Python, JavaScript, TypeScript, Java, C, C++, Ruby, HTML, CSS, PHP, Rust, Go, Kotlin and Shell, alongside a Plain Text prose mode.

    Our advanced language identifier sets the language for you, so most of the time there is nothing to do here. When you want to check it, or set it yourself, the status bar's Identify pill opens the Language Inspector, which states plainly — "Identified programming language: X" — and lets you override it from a pop-up before confirming.

  2. Choose the export

    Go to File ▸ Export As ▸ PDF…. It sits with two siblings, HTML with Syntax Highlighting… and RTF with Syntax Highlighting…, and syntax colouring survives in all three.

  3. Name it and pick a destination

    A standard macOS save panel appears, restricted to the PDF file type, so the extension is settled for you. Choose any folder you have access to.

  4. Open the result and look at it

    Not a formality — the finished document is your proof. Check the first page, one in the middle where the long lines live, and the last. Half a minute here turns a file you hope is right into one you know is right: the colouring in place, the long lines running to the end, the numbers down the margin where a reviewer expects them.

What the export does to your original file

Nothing, and that is the part worth being sure of before you hand a PDF to anyone. The exported document carries the colouring; your source file on disk is untouched. The colouring is something you see, not something added to your file, so opening a document and exporting it does not mark the file as edited and does not change a character of what you typed. You can export from a file you are halfway through reviewing and carry on exactly where you left off.

Our syntax engine puts the colouring you see on screen into the document you send, and it does the same for the HTML and RTF exports beside it. Keywords, strings, comments and numbers each keep their own colour, which is the whole point of the exercise: the person reading the PDF sees the shape of the code the way you see it, rather than a wall of undifferentiated black text.

The page always comes out in a monospaced typeface, so columns line up and indentation reads correctly even on a machine that has never had your editor font installed. All of it happens on your Mac: nothing is uploaded, and there is no account involved.

Export As ▸ PDF versus printing to PDF

macOS lets you save a PDF from any print dialogue, so there are two routes to a PDF of your code and they are not the same job.

Comparison of exporting a PDF and printing to PDF
File ▸ Export As ▸ PDF…Print… then save as PDF
How you get thereThe Export As submenu⌘P
How you check itOpen the finished PDFThe system print preview
Paper size and orientationThe standard page, settled for youSet in File ▸ Page Setup… (⇧⌘P), the standard macOS sheet
Page rangeThe whole documentChosen in the print dialogue
Syntax coloursPreservedPreserved

Use the export when you want the file and you want it now. Use the print route when the page itself matters — a specific paper size, landscape for wide code, or a page range. Both preserve the colouring in full, so you are choosing the page you want rather than choosing how good the code will look.

What a page contains is governed by six options, all of them on by default, in Settings ▸ Print & Export (⌘,).

The six print and export options and their defaults
OptionDefaultWhat it does
Line numbersOnNumbers in the margin, so a reviewer can say "line 214" and be understood.
Print-friendly themeOnA light theme on the page regardless of how the app looks on screen.
HeaderOnA page header.
FooterOnA page footer.
Wrap long linesOnLong lines wrap rather than being clipped at the margin.
File metadataOnPath and date information on the page.

The Settings window has fourteen panes and a sidebar search that reaches every row, so typing a few letters of an option name beats hunting for the pane. Switch the header off and the rows beneath it grey out, which is your sign that they no longer apply.

Tip

Soft wrap in the editor and "wrap long lines" on the page are separate settings. Wrapping the editor window changes what you see; it is not what decides whether a very long line is clipped on paper.

What happens to a dark theme on the way out

Working in a dark editor and printing a dark page are different desires, and only the first is on by default. The print-friendly theme puts a light page in front of your reader whatever appearance the app itself is wearing, and our syntax engine keeps keywords, strings, comments and numbers distinct from one another against white paper rather than letting them settle into a pale wash. What a reviewer actually needs from a code PDF — the shape of the code, at a glance, on paper — is what comes out.

That is the right default for nearly everything a code PDF is used for. If you genuinely want the dark appearance carried through — for a slide, say, rather than a page — turn the print-friendly theme off in Settings ▸ Print & Export and export again. Look at the result before you send it: dark pages that read well on screen can be hard going once someone prints them.

Naming the file

Choose the name yourself in the save panel. The PDF usually leaves the machine, and its name is the only label it carries: PaymentService.swift.pdf tells a reviewer what they have open, and Untitled 4.pdf tells them nothing at all.

Two small habits make the name do the work. Keep the original extension inside it, so a reader can tell a Swift file from a stylesheet before they open a single page. Then add whatever places the document for the person receiving it — a branch, a date, a ticket number, the review it belongs to. A name built that way survives a forwarded email and a folder full of attachments, and it saves you writing the covering note that would otherwise have to explain what the reader is looking at.

Exporting a very large file

No size limit is applied to the exports. A very large source file still exports, and what you get is the whole file, first line to last — it simply runs to more pages. Our large-file engine keeps a file that size comfortable to open and scroll, so reaching the export is not the hard part. Give a long one a moment to appear before you go hunting for it in Finder.

Do any tidying before you start. The toolbar Indent button opens the Indentation sheet, where you pick the language, the brace style and the width, and nothing in the document changes until you press Apply — you get to see the choice you are making before it is made. Our indentation engine then brings the whole file into line at once, so the shape of the code is settled before a single page is written. Let it finish, then export once and the tidy version is the one that goes out.

Troubleshooting

The PDF has no colour at all

The document is almost certainly still in Plain Text mode. Set the language yourself: open the Language Inspector from the status-bar Identify pill, choose the language, confirm, and export again. The editor recolours immediately, so you can see it has worked before you export a second time. A stylesheet or a snippet pasted into an untitled tab is the usual case here.

The colouring is for a different language

An unusual file extension, or a snippet pasted into a fresh tab with nothing else to go on, can read as a close relative of what you meant. You have the final say: open the Language Inspector from the status-bar Identify pill, pick the language you want from the pop-up and confirm. The editor recolours on the spot, and the next export carries that choice through to the page.

Long lines are cut off at the right edge

Check "wrap long lines" in Settings ▸ Print & Export. It is on by default, so if lines are being clipped it has been turned off at some point. Wrapping the editor window is a separate setting and does not affect the page.

The exported page is dark and hard to read

The print-friendly theme has been switched off. Turn it back on and export again; it produces a light page whatever appearance the app itself is using.

Putting Copy as HTML and Copy as RTF in the Edit menu

Both commands are yours to switch on in Settings ▸ Print & Export. Turn them on and they take their place in the Edit menu, ready to put coloured code straight onto the clipboard and into an email, a ticket or a document, with the highlighting intact. When you want a file rather than a clipboard, the Export As submenu is ready as it stands and asks nothing of Settings.

Three ways out of the editor

A PDF is the document you hand over, but it is one of three exports sitting together in the same submenu, and the colouring survives in every one of them. Pick by where the code is going:

  • PDF for anything that has to be read as a document — a review, an attachment, a compliance folder, a page that gets printed and marked up. Fixed pages, numbers down the margin, and a monospaced typeface so the indentation reads correctly on a machine that has never had your editor font installed.
  • HTML with Syntax Highlighting for code that has to live on a page — a wiki entry, an internal site, a handover document someone opens in a browser. The colouring travels with the markup, so the structure is legible wherever it is read.
  • RTF with Syntax Highlighting for a word processor — a report, a thesis chapter, a specification with code samples running through it. The document opens with the colours already in place and stays editable around them.
  • Copy as HTML and Copy as RTF for the same result without a file in between. Switch them on in Settings ▸ Print & Export and coloured code goes onto the clipboard, ready to paste into whatever is already open in front of you.
  • Nothing is uploaded, converted in a service, or previewed remotely. The whole export happens on your Mac, there is no account to create, and the file never leaves the machine.

Whichever you choose, the source file on disk stays exactly as you typed it. Exporting is something you do with a document, not something done to it, so you can send a colleague a PDF at eleven and carry on editing at five past.

Frequently asked questions

Does the PDF keep the syntax colours?

Yes. Syntax colouring survives in all three exports — PDF, HTML and RTF. Our syntax engine carries the colours you see on screen into the document you send, and your source file on disk is left exactly as you typed it.

Should I export as PDF or print to PDF?

Export when you want the file quickly and the default page is fine. Print (⌘P) when the page matters: paper size and orientation from File ▸ Page Setup… (⇧⌘P), a page range, and the system preview before you commit. Both preserve the colouring.

Can I get line numbers down the margin?

Line numbers are one of the six options in Settings ▸ Print & Export and they are on by default. If your result does not have them, check that switch first, then open the result again to confirm.

I use a dark theme. Will the PDF be dark?

You get a print-friendly light page by default, applied regardless of how the app itself looks, with a palette built for white paper so the colours stay legible and distinct on the page. Turn that option off in Settings ▸ Print & Export and export again if you want the dark appearance carried straight through.

Can I export a very large source file?

Yes, at any size. A very large document comes out in full, first line to last — it simply runs to more pages, and our large-file engine keeps a file that size comfortable to open and scroll on the way there. Do any reformatting first, then export once.

What do I need to run this?

A Mac running macOS 13.0 or later. Note My is a native, sandboxed Mac application from MAHTCA GLOBAL, with no account and no sign-in.