Chuyển đến nội dung

SVG sang PDF

Chuyển hình vẽ vector sang PDF mà không biến nó thành điểm ảnh.

Xử lý trên thiết bị của bạn

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 translates the SVG's geometry into PDF drawing operations rather than rasterising it. Paths, rectangles, circles, ellipses, polygons, lines, strokes, fills and text all become PDF vectors, so the result stays sharp at whatever size a printer sets it. The parts of SVG that have no PDF equivalent are named in the result banner rather than drawn flat, so you learn what was left out instead of wondering why the artwork looks thin.

Use it when a printer, a form or a colleague asks for a PDF of something you only have as an SVG: a logo for a sign or a banner, a diagram exported from a drawing tool, an icon sheet, or a chart out of a plotting library that writes SVG and nothing else.

Cách hoạt động

  1. Drop your .svg files onto this page. Up to 100 at a time, each up to 25 MB.
  2. Choose the page size. Match makes the page exactly the size of the drawing plus the margin, which is what a print shop usually wants; A4, Letter and A3 centre the artwork on that sheet instead.
  3. Set the margin if you want whitespace around the drawing. It is 0 by default, because artwork sized to its own bounds is easier to place afterwards.
  4. Choose the background. Transparent leaves the page unpainted, which is right for something going on top of another design; white paints a white rectangle, which is right for anything printed on its own.
  5. Press Convert. Each SVG becomes a one-page PDF, and the banner names anything in the file that could not be drawn.

The easy way to build this tool is to rasterise: draw the SVG to a canvas and embed the pixels. It is also the wrong way, because the reason anybody converts SVG to PDF is to keep it sharp at print size, and a 150 dpi picture of a logo defeats the whole exercise. Here the geometry is translated instead, so the drawing scales like the original and a sign printed at two metres is as clean as an icon printed at two centimetres.

What that costs is honesty about the parts of SVG with no PDF counterpart. Filters, masks, clip paths more complicated than a rectangle, gradients, patterns, markers, use references, foreignObject, animation and anything scripted are collected as they are met and reported by name. Naming them is the point: gradient, filter tells you what to change in your drawing program, whereas two unsupported features tells you nothing. Flatten those parts to plain shapes in your editor and convert again.

Text is drawn as real PDF text, so it stays selectable and searchable, but the typeface named in the file is not the one you get. A font-family list is mapped onto the three families available here - anything mentioning mono, courier, consolas or menlo becomes monospace, anything mentioning serif, times, georgia or garamond becomes serif, and everything else becomes sans. Character widths therefore differ from the browser's rendering, so a tightly positioned label can shift. If exact position matters, convert the text to outlines in your drawing program first and it will come across as geometry.

Page size and scale interact in a way worth knowing before you tune either. With Match, the page is the drawing at your chosen scale plus twice the margin, and nothing is resized after that. With a fixed sheet, the drawing is scaled by your percentage and then reduced further if it still does not fit inside the margins - never enlarged past the sheet - and centred on the page. So on A4 a scale above 100 per cent has no effect once the drawing already fills the sheet.

Only images written into the file as data URIs are embedded. A linked image points at a file or a web address, and going out to fetch it would be an outbound request from a tool that promises none, so it is reported as a linked image instead of being retrieved. Each SVG becomes its own single-page PDF; if you want a set of drawings in one document, run Merge PDF on the results.

Công cụ này không làm được gì

  • Filters, masks, gradients, patterns, markers, use references, foreignObject and animation cannot be drawn. They are named in the result rather than approximated.
  • The typeface named in the file is not embedded. Text is set in one of three families and character widths differ, so tightly positioned labels can shift.
  • Linked images and other external references are not fetched, because that would be an outbound request. Only data URIs are embedded.

Câu hỏi thường gặp

PDF có còn sắc nét khi in ở cỡ lớn không?
Có. Hình vẽ được dịch thành các thao tác vector của PDF chứ không dựng thành điểm ảnh, nên trong tệp không có độ phân giải nào để cạn kiệt. Cùng một tệp PDF in ra sạch sẽ dù là logo cỡ danh thiếp hay tấm băng-rôn dài hai mét, và đó chính là toàn bộ lý do để chuyển SVG thay vì xuất một tệp PNG.
Kết quả báo có thứ không vẽ được. Điều đó nghĩa là gì?
Nghĩa là tệp dùng một tính năng SVG không có tương đương trong PDF - một bộ lọc, một mặt nạ, một dải màu chuyển, một hoạ tiết, một đường cắt phức tạp, một dấu (marker), một tham chiếu use, foreignObject hoặc một hiệu ứng động. Thay vì vẽ bẹt nó ra rồi để bạn thắc mắc vì sao hình trông sai, bộ chuyển đổi nêu tên thứ mà nó đã bỏ qua. Hãy làm phẳng hoặc mở rộng các phần tử đó trong chương trình vẽ của bạn rồi chuyển lại.
Chữ trong tệp SVG của bạn thì sao?
Nó được vẽ thành văn bản PDF thật, nên vẫn chọn được và tìm được trong tệp đã xong. Tuy nhiên phông trong tệp không được nhúng: tên họ phông được ánh xạ sang sans, serif hoặc đơn cách, và độ rộng khác với những gì trình duyệt vẽ. Với hình mà một nhãn phải nằm đúng chỗ bạn đặt, hãy chuyển chữ thành đường viền trước khi chuyển tệp.
Trang sẽ có kích thước bao nhiêu?
Với "Khớp", đúng bằng kích thước của hình cộng hai lần lề, lấy từ chiều rộng và chiều cao của tệp hoặc từ viewBox của nó. Một tệp SVG không khai báo cả hai sẽ quay về mức mặc định 300 x 150 point, vốn là mặc định của chính định dạng và thường là dấu hiệu tệp được viết bằng tay. Chọn A4, Letter hoặc A3 sẽ cho bạn tờ giấy đó với hình đặt ở giữa.
Hình của bạn có bị tải lên không?
Không. Tệp SVG được phân tích và vẽ vào một PDF bên trong trình duyệt của bạn, và không có gì về tệp được truyền đi - điều này cũng có nghĩa là một ảnh được liên kết không thể tải về, vì đó chính là yêu cầu mà công cụ này từ chối gửi. Tài nguyên duy nhất mà trang này tải là phông Noto, từ chính máy chủ của trang, và chỉ khi hình vẽ có chứa chữ.

Công cụ liên quan