PyCharm 2024.3 Help

Print files

The Print option allows you to print hard copies of the selected files or specific code fragments and save them as PDF documents.

  1. In the main menu, go to File | Print.

  2. In the dialog that opens, select what you want to print:

    • File <name>: print the file, which is currently selected in the Project tool window or opened in the editor.

    • Selected text: print the code selected in the editor.

    • All files in directory: print all files in the directory that is selected in the Project tool window . Additionally, you can enable the Include subdirectories option to print files located in subdirectories.

  3. If necessary, configure options on the Settings, Header and Footer, and Advanced tabs.

  4. Click Print.

    You will see the system Print dialog where you can select the printer you want to use.

    From this dialog, you can save the selected code as a PDF file.

Settings

In this tab, specify the basic print layout settings.

Item

Description

Paper size

Select a paper size.

Font

Select a font style and size.

Show line numbers

Print line numbers.

Show border

Print the border.

Orientation

Specify the paper orientation. The available options are:

  • Landscape

  • Portrait

Style

Specify the style of the printout by selecting the relevant checkboxes. The available options are:

  • Color printing: print code in color.

  • Syntax printing: print code with syntax highlighting. Otherwise, code will be printed as plain text.

  • Print as graphics: generate graphics and send it to the printer driver. Otherwise, the IDE sends text to the printer driver. This is a legacy option that might be helpful if there are printer driver issues.

    For example, if you clear this option and print to a PDF printer, you can select text in the result file. When the option is selected, you cannot select and copy text in a PDF file.

In this tab, specify the contents and placement of the header and footer.

Item

Description

Text line

Specify the contents of the header or footer. If necessary, combine plain text with print keywords. By default, PyCharm suggests printing the name of a file $FILE$ in the header and the current page number $PAGE$ of all pages $TOTALPAGES$ in the footer.

  • $FILE$ prints fully qualified file name.

  • $PAGE$

  • $DATE$

  • $TIME$

  • $FILENAME$ prints file name without the path.

  • $TOTALPAGES$

Placement

Specify whether the above line will be printed in the header or in the footer.

Alignment

Select an alignment.

Font

Specify a font style and size to print the header and footer text.

Advanced

Item

Description

Wrapping

Configure text wrapping. The available options are:

  • Do not wrap

  • Wrap at word breaks

Margins (inches)

Specify the margins in inches.

Last modified: 22 November 2024