如何快速将 10MB PDF 转换为 SVG 并具有适当的 Web 大小 [英] How to convert 10MB PDF to SVG quickly with appropriate size for web

查看:69
本文介绍了如何快速将 10MB PDF 转换为 SVG 并具有适当的 Web 大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我已经阅读了所有关于PDF 到 SVG"、PDF 到 PNG、PNG 到 SVG"的问题和答案,但没有成功完成我的任务.

Good day, I have read all questions and answers about "PDF to SVG", "PDF to PNG, PNG to SVG" and had no success in accomplishing my task.

我有一个大约 10mb 的 PDF(来自 archiCAD 的蓝图),在使用 pdf2svg 转换为 SVG 后,SVG 大约为 70mb.转换需要 14 秒,但由于 SVG 的大小,网页加载需要大约 150 秒.

I have a PDF that is about 10mb (blueprints from archiCAD) and after using pdf2svg to convert to SVG, the SVG is about 70mb. Conversion takes 14sec, but the web page load takes about 150sec because of the size of the SVG.

我的问题是 - 如何将 PHP 中的 PDF 转换为具有适合 Web 大小的 SVG 且不损失质量且不使用 gzip 压缩?

My question is - how can i convert PDF in PHP to SVG with appropriate size for web without quality loss and without gzipping it?

此代码将 PDF 转换为 70MB 的 SVG:

This code converts PDF to SVG that is 70MB:

$fileName = 'in.pdf';
$targetName = 'out.svg';
exec("pdf2svg ".escapeshellarg($fileName)." ".escapeshellarg($targetName));

这个将 PDF 转换为 500kb SVG,质量损失巨大,一些路径损失,文本损失等.

This one converts PDF to 500kb SVG with HUGE quality loss, some path loss, text loss, etc.

exec("convert -density 200 ".escapeshellarg($fileName)." middle.png");
exec("inkscape middle.png --export-plain-svg=".escapeshellarg($targetName));

我尝试过 imagemagick、autotrace、potrace、inkscape、pdf2svg.我尝试了将 pdf 转换为 svg"中的答案.其他问题(关于 SO)甚至都不是我需要的.

Ive tried imagemagick, autotrace, potrace, inkscape, pdf2svg. I tried the answer from "convert pdf to svg". Other questions (on SO) weren't even close to what I need.

我几乎阅读了 Google 上的所有链接,几乎每个主题都能完成我的任务,但它们都以小尺寸 PDF 开头,因此无法解决我的问题.

I've read almost every link on Google and almost every topic accomplish my task, but they all start with a with small size PDF so it doesn't solve my problem.

推荐答案

你为什么绝对想要 SVG?如果您使用 Ghostscript 缩小 PDF,图像将保持原样,只需更改分辨率即可.

why you want absolutly in SVG? If you reduce the PDF with Ghostscript, the images will stay like they are, just change resolution.

我已经使用 ghostscript 将 PDF 转换为更小的尺寸.它比使用 convert ( imagick ) 更简单、更快捷.

I've convert PDF in smallers size with ghostscript. It's easiest and faster than with convert ( imagick).

我想你可以在 http://www.ghostscript.com/doc/中找到current/Use.htm 答案的某些部分.

I think you can find in http://www.ghostscript.com/doc/current/Use.htm some parts of the answer.

我用它来减少电子书"质量的 PDF:

I use this for reduce PDF in "ebook" quality:

exec('gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook  -dNOPAUSE  -dBATCH -sOutputFile='.$outfile.' '.$file.' ',$output, $return_var);

这篇关于如何快速将 10MB PDF 转换为 SVG 并具有适当的 Web 大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆