UPDATE: an updated solution is provided in my post #18 later in this thread
I'll share an option for adding a print capability (including print to PDF) to Arduino IDE 2.x:
Arduino IDE 2.x is built on the Eclipse Theia IDE framework, which allows it to use VS Code extensions.
As Microsoft has not seen the need to add native printing support to VS Code, a free open source 3rd party extension named PrintCode was created to add the capability. This extension can be installed in Arduino IDE 2.x to do the same.
Install the extension
If you have used VS Code, you will be used to installing extensions via the manager in the application. Arduino IDE 2.x does not have that capability, so the extension installation process is different.
-
Open the extension's page on the Visual Studio Marketplace:
PrintCode - Visual Studio Marketplace -
Click the "Download Extension" link on the right side of the page.
-
Wait for the download to finish.
-
Unzip the downloaded
.vsix
file to a folder.
The result will look something like this:nobuhito.printcode-3.0.0/ ├── [Content_Types].xml ├── extension/ └── extension.vsixmanifest
ⓘ Despite the
.vsix
file extension, the downloaded file is really a ZIP archive. Depending on which unzipping utility you use, it may help to rename the file to use a.zip
extension. For example, on Windows that will allow you to right click the file and select "Extract All..." from the context menu. -
Create a folder named
plugins
under Arduino IDE's configuration folder:- Windows:
C:\Users\<username>\.arduinoIDE\
- Linux:
~/.arduinoIDE/
The
.arduinoIDE
folder is hidden by default in the file manager and terminal. - macOS:
~/.arduinoIDE/
The
.arduinoIDE
folder is hidden by default. You can make it visible by pressing the Command+Shift+. keyboard shortcut.
ⓘ If you are using Arduino IDE 2.0.4 or older, name the folder
extensions
instead ofplugins
, and substitute that folder name in the rest of the instructions. - Windows:
-
Copy the unzipped extension folder to the
plugins
folder you created.
(e.g.,C:\Users\<username>\.arduinoIDE\plugins\nobuhito.printcode-3.0.0
). -
If Arduino IDE is running, select File > Quit from the Arduino IDE menus to exit all windows.
Printing sketches
Because the printing support is provided by an extension, it works a bit differently than usual:
- Open the sketch you want to print in Arduino IDE.
- Select the sketch tab you want to print.
- Press the Ctrl+Shift+P keyboard shortcut (Command+Shift+P for macOS users) to open the "Command Palette".
- Select the "PrintCode" command from the menu.
The sketch file will now be rendered as a webpage in your browser and a print dialog will open. - Configure the print job to your preferences and click the "Print" button when you are ready.
Configuring the extension
In case the default behavior of the extension is not to your liking, it offers several configuration settings:
- Press the Ctrl+Shift+P keyboard shortcut (Command+Shift+P for macOS users) to open the "Command Palette".
- Select the "Preferences: Open Settings (UI)" command from the menu.
A "Preferences" tab will open in the Arduino IDE main panel. - Type
printcode
in the "Search Settings" field of the "Preferences" tab.
The settings for the PrintCode extension will be shown in the search results. - Adjust the PrintCode configuration according to your preferences.
- Click the X icon on the "Preferences" tab.
- Select File > Quit from the Arduino IDE menus
- Restart Arduino IDE.