How to convert a text file (TXT) to PDF
Updated
Contents
To convert a text file to PDF, open Text to PDF, drop your .txt file on the page or paste the text into the Text content box, press Create PDF, then press Download PDF. You get a paginated PDF on US Letter (8.5 × 11 in) pages.
Every page carries a small heading, the file's name without its extension, or “text” for pasted text, and a page-of-total count in the footer. Long lines wrap at spaces, a word too long for one line is broken, tabs become spaces, and blank lines and leading indentation are kept. There are no settings for page size, font or margins.
The PDF is made in your browser, so your text stays on your device and there is no account to create. The text can be up to 2 MB.
Step by step
- 1Open the Text to PDF tool.
- 2Drop a .txt file on the box that says “Drop a TXT file here, or browse”, or click browse to choose one. Loading a file replaces whatever is in the box.
- 3Or paste or type straight into the Text content box. The figure beside its heading counts the characters and the size as you go, and you can edit the text before converting.
- 4Press Create PDF. The button reads Creating PDF… while the pages are set.
- 5Under “PDF created”, press Download PDF. notes.txt is saved as notes-pdf.pdf, and pasted text as text-pdf.pdf.
- 6Press Start over to clear the box for the next text.
How the file is read
A file whose name ends in .txt or .text, or that your system labels plain text, is accepted. For a .log, .csv or other text file, paste its contents into the box or rename it to .txt first.
A file that starts with a byte-order mark is read in the UTF-8 or UTF-16 encoding it declares. Otherwise its bytes are inspected and it is read as UTF-16, UTF-8 or Windows-1252, the encoding older Windows programs save in, and a note under the box names the encoding whenever it had to be assumed. Other legacy encodings, such as Cyrillic Windows-1251 or Shift-JIS, are not detected and come out with the wrong letters, so save those as UTF-8 first.
Fonts, columns and other scripts
Western European text is set in Courier, one of the fonts PDF readers supply themselves, so nothing is fetched or embedded. Western European, Central European, Baltic, Turkish, Russian, Ukrainian, Bulgarian and Serbian text, box drawing and ← → ↑ ↓ ↔ ↕ are set in a monospace face. Where Courier cannot draw a character but that face can, as with Polish or Russian letters, the monospace face is fetched from pdf.xyz's own site and embedded, so columns lined up with spaces stay lined up as long as each line fits the page width.
Any other character, in the text or in the file's name, moves the whole body to a proportional Noto face, and space-aligned columns then stop lining up. The scripts the bundled faces draw are Bengali, Latin, Greek, Cyrillic, Devanagari, Hiragana, Katakana, Kanji, Hangul, and Han. Arabic and Hebrew text and emoji stop the conversion with an explanation, and so does a mix of scripts that need different fonts, such as Chinese and Bengali in one file. Nothing is swapped for a placeholder.
Plain text, Markdown, or several files
Text to PDF prints the text as it is, which suits notes, logs and transcripts. For headings, bold, lists or code blocks, write the text as Markdown and use Markdown to PDF, which also runs in your browser.
It converts one text at a time. To make one PDF from several files, paste them into the box one after another and convert once, or convert each file and then join the PDFs in order with Merge PDF.
Common questions
Is my text sent to a server?
No. The PDF is made in your browser tab, and the text stays on your device. The only thing the page may fetch from pdf.xyz is a font file, when your text or file name needs characters beyond Western European, and that request carries none of your words.
How large a text file can I convert?
Up to 2 MB, whether you load a file or paste. A file larger than that is turned away when you load it, and the text is measured again when you press Create PDF. Chinese or Bengali characters take several bytes each, so such text reaches the cap at fewer characters than English.
Is there a setting for A4 paper, another font or wider margins?
No. Every PDF is US Letter (8.5 × 11 in), with fixed margins and text size, and the page heading is also the document's Title property. For more control over the look, write Markdown and use Markdown to PDF.
Which languages come out correctly?
Western European text, and text in Bengali, Latin, Greek, Cyrillic, Devanagari, Hiragana, Katakana, Kanji, Hangul, and Han, gets a font that can draw it. Arabic and Hebrew text and emoji are refused with an explanation, and so is any script without a bundled font; the message shows the characters it could not draw.
Why do the accented letters in my file look wrong?
The file is probably in a legacy encoding other than Windows-1252, such as Windows-1251 or Shift-JIS, which is read as Windows-1252. Save it as UTF-8 in your text editor and load it again. A note under the box says when an encoding was assumed.