SVG 转 PDF
把矢量图稿转换为 PDF,不把它变成像素。
这款工具完全在你的浏览器中运行。文件从不上传,你可以在浏览器的网络标签中亲自验证这一点。 亲自验证:打开浏览器的网络标签观察。你会看到一个查询你是否还有剩余任务的小请求,只包含工具名称和一段哈希,绝不会包含文件。
这款工具的作用
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.
工作原理
- Drop your .svg files onto this page. Up to 100 at a time, each up to 25 MB.
- 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.
- 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.
- 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.
- 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.
这款工具做不到的事
- 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.
常见问题
- 放大打印时 PDF 还会清晰吗?
- 会。图形被翻译成 PDF 矢量绘制操作,而不是渲染成像素,所以文件里没有会用尽的分辨率。同一个 PDF 既能作为名片上的徽标清晰打印,也能作为两米长的横幅清晰打印——这正是转换 SVG 而不是导出 PNG 的全部理由。
- 结果说有些东西无法绘制。那是什么意思?
- 这意味着文件用到了没有 PDF 对应物的 SVG 特性——滤镜、蒙版、渐变、图案、复杂的裁剪路径、标记、use 引用、foreignObject 或动画。转换器不会把它平涂出来、让你纳闷图稿为什么看起来不对,而是把跳过的东西一一列出。请在你的绘图程序里把那些元素平坦化或展开,再重新转换。
- 我 SVG 里的文字会怎样?
- 它会作为真正的 PDF 文本绘制,所以在成品文件里仍可选中和搜索。不过文件里的字体不会被嵌入:字体族名会被映射到无衬线、衬线或等宽,字符宽度与浏览器绘制的不同。对于标签必须精确落在你放置位置的图稿,请在转换文件之前先把文字转为轮廓。
- 页面会是多大?
- 选「匹配图形」时,正好是图形的大小加上两倍页边距,取自文件的 width 和 height,或它的 viewBox。两者都没声明的 SVG 会回退到 300 × 150 点,这是这种格式自己的默认值,通常表明文件是手写的。选择 A4、Letter 或 A3,则会给你那张纸,图形居中放在上面。
- 我的图稿会被上传吗?
- 不会。SVG 在你的浏览器中解析并绘制成 PDF,关于这个文件的任何东西都不会被传输——这也意味着无法去获取一张被链接的图片,因为那正是这款工具拒绝发出的请求。这个页面加载的唯一素材是 Noto 字体,来自本站点自己的源,而且只有在图形包含文字时才会加载。