Văn bản sang PDF
Trình bày tệp .txt, .log hoặc .csv thành một bản liệt kê PDF.
Công cụ này chạy hoàn toàn trong trình duyệt của bạn. Tệp của bạn không bao giờ được tải lên, và bạn có thể tự kiểm chứng điều đó trong tab mạng của trình duyệt. Tự kiểm chứng: mở tab mạng của trình duyệt và theo dõi. Bạn sẽ thấy một yêu cầu nhỏ hỏi xem bạn còn tác vụ nào không - một tên công cụ và một mã băm, không bao giờ là tệp.
Công cụ này làm gì
This sets a plain text file as a PDF, one line of the file to one line of the page. The defaults are those of a code listing rather than a letter - monospace, 10 pt, wrapping on - because almost nobody converts prose this way. People convert a log, a configuration file, a CSV or a source file, usually because something else insists on receiving it as an attachment or a printout.
Reach for it when a text file has to travel as a document: a log going onto a support ticket, a configuration file that has to sit in a change record, a CSV a colleague wants to read rather than open in a spreadsheet, or a source file heading for someone with nothing to open it in.
Cách hoạt động
- Drop your .txt, .log, .csv or .md files onto this page. Up to 50 at a time, each up to 50 MB.
- Choose the typeface. Monospace is the default and is what keeps the columns of a log or a CSV lined up; sans and serif are there for the rare file that is actually prose.
- Set the type size and line spacing. 10 pt is the default; 8 pt fits noticeably more on a sheet and is worth it for a long log.
- Decide about long lines. Wrapping folds anything wider than the column so it stays visible; with wrapping off, an over-long line is clipped at the page edge instead, which is the honest rendering of a file whose lines are meant to be lines.
- Turn on line numbers if you expect to refer to a particular line, then press Convert.
- Each file downloads as its own PDF.
Wrapping is the one option that changes what the document means, which is why it is offered rather than decided for you. A folded long line stays readable but stops being one line, and anyone counting lines or diffing the output against the original will notice. An unwrapped line is truthful about the file and runs off the sheet. Both are right sometimes: wrap a log you want to read, leave it unwrapped for a file where line boundaries carry meaning.
When wrapping is on, the fold is done carefully. Tabs are expanded to four spaces before anything is measured, the continuation is indented to match the leading whitespace of the line it came from, and the break is preferred at a space so a long path or identifier is not cut in half mid-word. The number of characters that fit is worked out from the actual width of a monospace digit at your chosen size, not guessed.
Line numbers are padded to the width of the largest number in the file and followed by two spaces, so they form a straight column and the text stays aligned all the way down. They are drawn as part of the text rather than in a margin, which means they come with you when you copy a line out of the finished PDF. That is what you want when quoting a line to somebody, and not what you want if you are going to paste the listing back into an editor.
The file is decoded as UTF-8, and a byte-order mark at the start is stripped - a BOM is a mark, not a character, and left in place it renders as an invisible-width glyph at the top of the first page in some viewers. Bytes that are not valid UTF-8 become the replacement character rather than aborting the conversion, so a file saved in an older Windows or Japanese encoding will convert but will show damage where the accented characters were. Windows, Unix and classic Mac line endings are all recognised as breaks.
The embedded font is Noto Sans Mono or Noto Sans, subsetted to the characters your file actually uses, which is what keeps a converted log at tens of kilobytes rather than megabytes. It does not cover Chinese, Japanese, Korean, Arabic or Indic scripts. Turning embedding off falls back to Courier, Helvetica and Times, which are WinAnsi only, and there a replacement character comes out as a question mark.
Công cụ này không làm được gì
- Chinese, Japanese, Korean, Arabic and Indic scripts are outside the embedded font's coverage, because the faces that would cover them are tens of megabytes each.
Câu hỏi thường gặp
- Điều gì xảy ra với những dòng quá dài so với trang?
- Khi bật xuống dòng, chúng được gập xuống dòng kế tiếp, thụt vào cho khớp với chỗ dòng gốc bắt đầu và ngắt ở một dấu cách nếu có. Khi tắt xuống dòng, chúng bị cắt ở mép trang, nên bạn thấy mỗi dòng tệp là một dòng trang và phần cuối của một dòng rất dài hoàn toàn không hiện ra. Hãy tắt nó khi ranh giới dòng quan trọng và bật khi khả năng đọc quan trọng hơn.
- Vì sao phông đơn cách là mặc định?
- Vì phông đơn cách là loại duy nhất giữ các cột thẳng hàng, mà phần lớn những gì người ta chuyển ở đây đều theo cột: nhật ký với dấu thời gian ở bên trái, tệp CSV, tệp cấu hình, mã nguồn có thụt lề. Với một phông tỷ lệ, những cột đó lệch nhau chỉ sau vài dòng. Vẫn có phông sans và serif cho thi thoảng một tệp đúng là văn xuôi.
- Ký tự có dấu của bạn hiện thành ký hiệu lạ. Vì sao?
- Tệp được giải mã theo UTF-8. Nếu nó được lưu bằng một bảng mã một byte cũ như Windows-1252, hoặc bằng một bảng mã tiếng Nhật, thì các byte của ký tự có dấu không phải là UTF-8 hợp lệ và được thay thế chứ không đoán mò. Hãy lưu lại tệp theo UTF-8 trong trình soạn thảo rồi chuyển lại. Dấu thứ tự byte (BOM), nếu có, được loại bỏ tự động.
- Bạn chuyển được nhiều tệp cùng lúc không?
- Có, tối đa 50 tệp trong một lần, và mỗi tệp thành một PDF riêng đặt tên theo tệp nguồn. Thiết lập trang, cỡ chữ, xuống dòng và đánh số dòng áp dụng cho tất cả, nên một thư mục nhật ký cho ra kết quả nhất quán. Ô tên tệp chỉ áp dụng khi bạn chuyển một tệp.
- Tệp của bạn có bị tải lên không?
- Không. Các byte được giải mã và dàn trang trong một Web Worker bên trong trình duyệt của bạn, và tệp PDF được tạo ngay tại đó. Yêu cầu duy nhất mà trang này gửi là để lấy phông Noto từ chính máy chủ của trang, và chỉ khi bật nhúng Unicode. Hãy mở thẻ mạng của trình duyệt và thử chuyển một tệp nếu bạn muốn tự kiểm tra thay vì tin lời chúng tôi.