将图形导出为 PDF 时,可以导出绘图标签中的特殊符号/西里尔字母吗?
我正在尝试将图形列表导出为 PDF 格式的单独帧,以便随后借助外部实用程序(例如 pdf2swf)编译矢量 SWF 动画。遗憾的是,导出的 PDF 文件中的某些特殊字符(例如度数符号或三重点)已损坏。这也是所有俄语字母的命运。请注意,当直接从 Mma 导出到 SWF 时,Mathematica 会对列表中的图形进行栅格化,这在我的例子中产生的结果并不令人满意。
有没有办法在导出的图形中保留这些字母?
单个图形可以在图形编辑器中手动编辑,但对于数百帧视频几乎不可能。某些符号可以通过以下自定义函数保留:
ExportPDF[filename_, elem_,
opts : OptionsPattern[{Export, Outlines -> True}]] := Module[{$elem},
$elem = Style[elem, Background -> None];
If[OptionValue[Outlines] == True
, $elem =
First@ImportString[ExportString[$elem, "PDF"], "PDF",
"TextMode" -> "Outlines"]
];
Export[filename, $elem, FilterRules[{opts}, Options[Export]]]
]
不幸的是,它并不总是有帮助。
I am trying to export a list of graphics as separate frames in PDF format in order to then compile a vector SWF animation with the aid of external utility (such as pdf2swf). Unfortunately, some special characters (e.g. Degree sign or triple dots) are corrupted in the exported PDF files. That is also the destiny of all Russian letters. Note that Mathematica rasterises graphics in a list when it is directly exported from Mma to SWF, which yields unsatisfactory results in my case.
Is there a way to preserve those letters in exported graphics?
Single graphics can be manually edited in a graphics editors, but it is hardly possible for hundreds of frames for video. Some symbols can be preserved by the following custom function:
ExportPDF[filename_, elem_,
opts : OptionsPattern[{Export, Outlines -> True}]] := Module[{$elem},
$elem = Style[elem, Background -> None];
If[OptionValue[Outlines] == True
, $elem =
First@ImportString[ExportString[$elem, "PDF"], "PDF",
"TextMode" -> "Outlines"]
];
Export[filename, $elem, FilterRules[{opts}, Options[Export]]]
]
Unfortunately, it doesn't always help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一种解决方法是导出为 EMF 而不是 PDF 格式:
如果您愿意,可以进一步将 EMF 转换为 PDF 或 SWF。请参阅此处有关高质量 EMF 导出的一般提示来自Mathematica。
另一种看似可靠的方法是将仅西里尔文字转换为轮廓,然后使用
Inset
或Labeled
将其放置在图形中:或者您可以直接使用轮廓文本作为
PlotLabel
:您可以通过编写一个简单的例程来推广此方法:
您可以按如下方式使用它:
One workaround is to export to EMF instead of PDF format:
You can further convert EMF to PDF or SWF if you wish. See here general tips on high-quality EMF export from Mathematica.
Another way that seemingly works reliably is to convert only Cyrillic text to outlines and then place it in your graphics with
Inset
or withLabeled
:Or you can use the outlined text directly as
PlotLabel
:You can generalize this method by writing a simple routine:
You can use it as follows:
Mathematica 的 PDF 导出当前不支持西里尔字母,仅支持罗马、希腊、日语和一些技术符号。如果您使用的是 Mac,您可以选择“文件”>“文件”>“文件”。打印>另存为 PDF 作为解决方法。
Mathematica's PDF export does not curremtly support Cyrillic, only Roman, Greek, Japanese, and some technical symbols. If you are using a Mac you can choose File > Print > Save As PDF as a workaround.