By · Updated

Text to PDF

Convert Plain Text or a TXT File to PDF Online

No ratings yet

OneTask is free, with no sign-up, and built by one person.
If this tool saved you time, a coffee helps keep new ones coming.

How the Text to PDF works

Convert text to PDF in one step: paste plain text, pick a page size and font, and download a word-wrapped PDF ready to print, email or archive. Line breaks and blank lines are kept. The PDF is made in your browser, so the text is never uploaded.

Plain text is the most portable format there is, but it does not travel well as an attachment. A .txt file opens in a different font and width on every device, long lines may not wrap, and many upload forms, printers and document systems only accept PDF. Turning it into a PDF fixes the page size, font and layout so the text looks the same wherever it is opened.

When to convert text to PDF

How Text to PDF works

The PDF is built by pdf-lib, an open-source PDF library, inside your browser. Your text is split at its own line breaks first, so paragraphs, lists and blank lines stay where you put them. Tabs become four spaces. Each line is then measured with the real character widths of the chosen font and wrapped at the last space that fits between the margins. A word longer than the whole line, such as a long URL, is broken across lines rather than running off the page.

Lines are spaced at 1.35 times the font size, the comfortable default used by most word processors. When a page is full, a new one starts. If you give a title, it is stored as the PDF's title, which readers show in the window bar and search tools index.

Page sizes and fonts

Page Size Common in
A4 210 × 297 mm Everywhere outside North America
US Letter 8.5 × 11 in United States, Canada
A5 148 × 210 mm Booklets, notebooks, handouts
US Legal 8.5 × 14 in US legal and real estate forms

The three fonts are built into every PDF reader, so nothing has to be embedded and files stay small, often under 5 kB a page. Helvetica is clean for letters and notes. Times fits more words per line and suits long reading. Courier is monospaced, so every character is the same width.

Tips and pitfalls

Special characters. The built-in PDF fonts cover Western European letters, accents, curly quotes, dashes and the euro sign. Characters outside that set, such as Chinese, Arabic, Cyrillic, Greek or emoji, cannot be drawn and are replaced with a question mark. The tool lists exactly which characters were replaced so nothing is lost silently.

Line length for reading. About 60 to 80 characters per line is easiest to read. On A4 with 20 mm margins, 11 pt Helvetica gives roughly 90; raise the size or margins for long documents.

Monospace widths. At 10 pt, Courier fits about 80 characters on an A4 line with 20 mm margins, the classic terminal width, so 80-column text and code fits without wrapping.

Landscape for wide text. Spreadsheets saved as text, wide logs and long tables read better on a landscape page, which adds about 40% more width per line at the cost of fewer lines per page.

How to read the result

The stats show the number of pages, the total lines after wrapping and how many fit on a page, the word count and the PDF's file size. Press Download to save it.

FAQ

How do I convert a TXT file to PDF?

Open the .txt file in any text editor, select all and copy, then paste it into the Text box here. Choose a page size and font and press Download. The PDF keeps your line breaks and blank lines.

Why are some characters showing as question marks?

The PDF uses the fonts built into every reader, which cover Western European languages only. Characters from other scripts and emoji are replaced, and the tool lists which ones. For those, print the text to PDF from a browser or word processor instead.

Can I keep code or tables lined up?

Yes. Choose Courier, which gives every character the same width, so columns, indentation and ASCII tables stay aligned. Lower the font size if lines are long enough to wrap onto a second line.

Is my text uploaded?

No. The PDF is created by your browser on your own device and the text is never sent to a server, so private notes, letters and logs stay on your computer.

See also: all Documents tools, Units, Images, Audio & Video, Data & Code.

Related tools