How to Convert Source Code to PDF with Syntax Highlighting

Paste or upload source code, add optional line numbers, choose a dark or light theme, and create a readable A4 or Letter PDF locally.

Convert code to PDF

Start with pasted code or a readable source file

1into1 Code to PDF accepts code pasted directly into the editor or a file selected from your device. Uploaded files are read as text rather than compiled or executed.

Use an optional header title when the PDF needs to identify the source file, module or snippet.

Highlighting is generic, not a full language parser

The renderer marks common keyword patterns, quoted strings, line and block comments, numbers and function-like names. Its keyword set spans several familiar programming styles, including JavaScript-like, Python-like, SQL-like and typed-language terms.

There is no programming-language selector and no claim that every token will match an IDE or compiler-grade syntax grammar.

Choose the PDF layout for reading or printing

Use Dark (Terminal) for a dark code-page appearance or Light (Print) for a white-background version. A4 and US Letter are both available in portrait or landscape.

The current font-size choices are 7.5pt, 8.5pt and 10pt, so landscape plus the smaller sizes can give wide source lines more horizontal room.

Whitespace and indentation need deliberate handling

Source code depends on spaces, tabs and line breaks for readability, and sometimes for program meaning. MDN documents how whitespace-preserving layouts differ from normal collapsed text rendering.

1into1 expands tab characters to four-space tab stops before laying out the source, then keeps code lines separate rather than flowing them like ordinary prose.

Verify special characters in the final PDF

Most ordinary Latin or ASCII source is written as vector PDF text. Lines containing broader Unicode or backslashes can be rendered locally as images to avoid corrupting visible characters or escape-heavy source.

Check regex-heavy lines, multilingual comments, emoji and unusual symbols after export when exact visual fidelity matters.

Official sources reviewed

  1. MDN — white-space CSS propertyExplains preserving spaces, tabs and line breaks versus collapsing ordinary text whitespace.
  2. MDN — tab-size CSS propertyDocuments tab-width concepts used when presenting indented preformatted text.