我可以在 Mathematica 8 中更改导出为 pdf 设置吗?
我正在使用 Mathematica 绘制我需要的一些图形,然后在 Latex 中将它们用作 pdf。
问题是 Mathematica 使用 Acrobat 5.x 设置兼容性导出数字,我认为这会导致数字很大且未优化,当我在最终的 pdf 中包含几个数字时,有时仅打印一个就需要几分钟最终文件的页面。
有没有办法在 Mathematica 中更改 pdf 的输出设置? 我是否应该导出为 pdf、转换为 postscripts,然后使用新设置从 .ps 创建新的 pdf? 我应该导出 .eps 并转换为 pdf 吗? 有没有一种通过 Mathematica 创建优化 pdf 的一步方法?
快速示例(有点夸张,因此差异非常明显):我从 Mathematica 导出的 pdf (Export["C:/figure.pdf", %]) 大小为 1065kb,.pdf ->.ps -> ;.pdf 给出了 652kb 的最终文件,.eps->.pdf 给出了 610kb 的文件。 我不会在乳胶中使用任何这些,但它显示了设置的差异。
I am using Mathematica to plot a number of figures I require and then using them as pdfs in Latex.
The issue is that Mathematica exports the figures using Acrobat 5.x settings compatibility and I think this results in figures that are large, not optimized and when I have a couple of them in the final pdf, sometimes it takes minutes just to print a single page of the final document.
Is there a way to change the output settings for pdfs in Mathematica?
Should I export as pdfs, convert to postscripts and then create new pdfs from the .ps with new settings?
Should I export .eps and convert to pdf?
Is there an one step way to create optimized pdfs through Mathematica?
Quick example (and a bit exaggerated so the difference is quite obvious): The pdf I export from Mathematica (Export["C:/figure.pdf", %]) is 1065kb in size, .pdf ->.ps ->.pdf gives a final file of 652kb and .eps->.pdf a file of 610kb.
I would not use any of these in a latex but it shows the difference in the settings.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
pdf->ps->pdf
总是会为您提供较小的文件大小,这是一个神话。例如,考虑(在mathematica中)
(在shell中)
test.pdf
是446kB,而test1.pdf
在我的机器上有 11.5MB 之大!通常发生的情况是,当您使用 Mathematica 导出 PDF 文件时,它会存储文本(轴刻度线、标签等)、字体和图像,所有这些都会添加到文件中。如果您的矢量图形带有大量刻度线/标签,那么这些标记可能非常重要。执行
pdf->ps->pdf
将删除文件中的字体数据和文本数据,同时压缩图像,这就是您看到文件大小减小的原因。虽然在小放大倍数下无法观察到,但当您放大相当大的尺寸时,您会注意到差异。例如,将p
替换为在我的机器上生成
test.pdf
的 37kB 文件和test1.pdf
的 8kB 文件。 8kb 文件的质量比原始文件差(缩放至 600%+ 即可显示这一点)。您可以通过执行以下操作来查看mathematica存储在PDF文件中的纯文本信息。但是,对于更复杂的PDF文件,转换为
ps
然后返回pdf
并不一定是不错的选择,可能会导致文件大小增大。您可以尝试使用
Export
中的PDF选项,例如“AllowRasterization”
和ImageResolution
,甚至可以在保存之前对图像进行光栅化,但是我想你已经知道了。这是一种在mathematica 中减少文件大小的快速而肮脏的方法
文件大小现在只有12kB!它只有原始文件的三分之一,仅比从
pdf->ps->pdf
获得的文件稍大一点,并且质量比 8kB 的文件好得多(尽管与 pdf->ps->pdf 的文件质量不完全相同)在放大 1200% 及以上时可以看到差异)。发生的情况是,在导入和重新导出时,仅保存存储的图像。它的纯文本部分被丢弃,在这个小例子中,这恰好很重要。对于
DensityPlot
示例,仅减少到 425kB(仍然是下降而不是增加到 11MB)。It is a myth that
pdf->ps->pdf
will always give you a smaller file size. For e.g., consider(in mathematica)
(in the shell)
test.pdf
is 446kB, whereastest1.pdf
is a whopping 11.5MB on my machine!What happens normally, is that when you export a PDF file using Mathematica, it stores the text (axes tick marks, labels, etc), fonts and images, all of which add to the bulk. If you have vector graphics with lots of tick marks/labels, these can be quite significant. Doing
pdf->ps->pdf
will strip the file of font data and text data, at the same time compressing the image, which is why you see a decrease in file size. Although not observable at small magnifications, you will notice the difference when you zoom in considerably. For e.g., replacingp
withproduces a 37kB file for
test.pdf
and an 8kB file fortest1.pdf
on my machine. The quality of the 8kb file is poorer than the original (zooming to 600%+ shows this). You can see the plain text information that mathematica stores in the PDF file by doingHowever, for more complicated PDF files, converting to
ps
and then back topdf
is not necessarily a good option and can result in the file size blowing up.You can try playing with the options for PDF in
Export
, such as"AllowRasterization"
andImageResolution
, or even rasterize the image before saving, but I guess you already knew that.Here's a back-alley quick and dirty way of reducing file size from within mathematica
The file size is now only 12kB! It's only a third of the original, only slightly larger than that obtained from
pdf->ps->pdf
, and is of a much better quality than the 8kB one (although not exactly the same as the original. The differences can be seen at magnifications of 1200% and above).What happens is that upon importing and re-exporting, only the stored image is saved. The plain text part of it is thrown away, and in this small example, that happened to be significant. For the
DensityPlot
example, the reduction was only to 425kB (still, went down rather than blow up to 11MB).