离线 · 无上传 · 浏览器本地完成Offline · no uploads · runs in the browser
SVG 转 PDF——先栅格化再铺页,本地离线SVG to PDF offline — rasterised, then laid on a page
图标、示意图、图表常常以 SVG 存着,而要交出去的地方要的是 PDF。这条链路是 SVG → PNG → PDF:先把 viewBox 归一、把活动性内容剥掉,再栅格化成位图,最后按像素尺寸铺成一页 A4 之外的「图即页面」。要知道它的取舍:产出里没有矢量,PDF 放大后是像素,文字不再是可编辑的文本——它适合「把这张图交出去」,不适合「交一份能改的图」。Icons, diagrams and charts live as SVG, while the thing asking for them wants a PDF. This route is SVG → PNG → PDF: the viewBox is normalised, active content is stripped, the result is rasterised to a bitmap, and that bitmap is laid on a page sized to its pixels. Know the trade-off: nothing in the PDF is vector, zooming shows pixels, and text is not editable text. It answers «send this picture over», not «send a drawing I can still edit».
这条链路怎么走How the route runs
SVGSVG PNGPNG PDFPDF
共 2 步,由扩展的路径搜索自动选出,中间产物不落盘。2 steps, chosen by the extension's own path search; intermediate results never touch the disk.
会保留什么What carries over
- 看得见的形状与颜色:栅格化在浏览器自己的 SVG 渲染上完成,包括渐变、描边与滤镜的可见结果The shapes and colours you can see: rasterisation uses the browser’s own SVG rendering, so gradients, strokes and filter results come across as rendered
- 页面尺寸跟着图片像素走(96 dpi 换算成 pt),横长的图自动用横向页,不会把一张窄图塞进固定栏宽再留出大片空白The page is sized from the bitmap’s pixels (96 dpi converted to pt) and turns landscape when the image is wide, instead of squeezing a narrow graphic into a fixed column of whitespace
- 尺寸取 `width`/`height` 或 `viewBox`;两者都没写时按 1024×1024 兜底,而不是在栅格化那一步失败Size comes from `width`/`height` or the `viewBox`; when neither is written, a 1024×1024 square is used rather than failing at the rasterising step
如实说明的限制What it does not do
- 产物是位图页:没有矢量路径,PDF 里也认不出文字——要能改的图形请继续用 SVG,要矢量 PDF 这条路给不了The page is a bitmap: no vector paths, and no text the PDF can recognise. Keep working in SVG if the artwork must stay editable; a vector PDF is not what this route can give
- 栅格化前会剥掉 `<script>` 元素与 `on*` 事件属性,绘制本身又走 `<img>`(浏览器在这个上下文里不执行脚本、也不取外部子资源)。所以靠动画或外部引用才画得出来的那部分,转出来会缺——这是刻意的安全取舍,不是丢件Before rasterising, `<script>` elements and `on*` handler attributes are removed, and the drawing itself happens in an `<img>` context, where the browser neither runs scripts nor fetches external subresources. Anything an animation or an outside reference was contributing is missing from the result — a deliberate safety trade-off, not a lost asset
- 超大画布会被等比缩到浏览器能安全栅格化的范围内(`fitToMaxDim`):不报错,但你拿到的像素比 viewBox 声明的要少An oversized canvas is scaled down proportionally to a size a browser can rasterise safely (`fitToMaxDim`): there is no error, but you get fewer pixels than the viewBox asked for
- 字体取决于本机装了什么:原件指定而本机没有的字体会由替代字形渲染,字宽因此可能不同Fonts depend on what is installed: a typeface the original names but this machine lacks is rendered with a substitute, so metrics can shift
实操提示Working with it
- 一批最多 200 个文件,单个文件上限 100 MB;多个 .svg 一起转会逐个产出各自的 .pdf。「合并为一份 PDF」那个开关对 SVG 批次不出现——SVG 要先经栅格化这一站,合并那条路只收已经是位图的格式Up to 200 files per batch and 100 MB per file; several .svg files yield one .pdf each. The merge-into-one-PDF switch does not appear for an SVG batch: merging only accepts formats that are already bitmaps, and SVG has a rasterising stop first
- 想把一批图并成一份多页 PDF,先把 SVG 转 PNG 再走 PNG 合并;只是想换格式而不是换容器,走 SVG 转 PNG 或 SVG 转 WebP 更省事To gather a set into one multi-page document, convert the SVGs to PNG and merge those; if you only need a different picture format, SVG to PNG or SVG to WebP is less work
常见问题Questions people actually ask
转出来的 PDF 能放大不失真吗?Does the PDF stay sharp when zoomed?
不能。这条链路先把 SVG 栅格化成位图再铺页,放大看到的是像素。需要可无限放大的 PDF,得由能直接输出矢量 PDF 的工具来做;本扩展全部在浏览器里画,交付的是渲染结果。No. The route rasterises the SVG first, so zooming shows pixels. Infinitely scalable PDF output needs a tool that writes vector PDF directly; everything here is drawn in the browser and delivers the rendered result.
从别处拿到的 SVG 也敢转吗?Is it safe to convert an SVG from somewhere else?
转换前先剥脚本与事件属性,绘制又走 `<img>`——浏览器在这个上下文里不执行 SVG 里的脚本,也不加载它引用的外部东西。所以「来源不明」的 SVG 最坏是画得不一样,而不是执行里面的代码。Scripts and event attributes are removed before conversion, and the drawing goes through an `<img>` — a context in which the browser runs no SVG script and loads nothing the file references. Worst case for an SVG of unknown origin is that it looks different, not that its code executes.
图标要交给外包做印前,文件会外发吗?If I hand an icon to a print vendor, does the file leave my machine?
转换这一步不会。扩展只有 storage 权限、没有 host 权限,读文件、剥脚本、栅格化、写 PDF 都在标签页内完成;把 PDF 发出去那一步是你自己的事。The conversion does not. The extension holds the storage permission only and no host permissions; reading, stripping, rasterising and writing the PDF all happen in the tab. Sending the PDF on is your own step.
不需要账号,也不需要联网:装好扩展后点图标,在新标签页里打开工作台,文件从磁盘直接选。No account and no network: install the extension, click its icon, and the workbench opens in a new tab reading straight off your disk.
从 Chrome 应用商店安装Install from the Chrome Web Store 安装步骤Install steps GitHub 源码Source on GitHub