本文介绍了将图形输出为PDF时,能否将特殊符号/西里尔字母输出到绘图标签中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图以PDF格式导出图形列表作为单独的框架,以便随后借助外部实用工具(如pdf2swf)编译矢量SWF动画。不幸的是,一些特殊字符(例如程度符号或三重点)在导出的PDF文件中被损坏。这也是所有俄文的命运。请注意,当Mathematica直接从Mma导出到SWF时,它会在列表中栅格化图形,这在我的情况下会产生不令人满意的结果。

单个图形可以在图形编辑器中手动编辑,但几百帧视频几乎不可能。一些符号可以通过以下自定义函数来保存:

  ExportPDF [filename_,elem_,$ b $ opts:OptionsPattern [导出,概要 - > True}]]:= Module [{$ elem},
$ elem =样式[elem,Background - >没有];
如果[OptionValue [Outlines] == True
,$ elem =
首先@ ImportString [ExportString [$ elem,PDF],PDF,
TextMode - > 概述]
];
Export [filename,$ elem,FilterRules [{opts},Options [Export]]]
]

不幸的是,它并不总是有帮助的。
解决方案

一个解决方法是导出到EMF,而不是PDF格式:

 导出[C:\\ 1.emf,
Plot [Sin [x ],{x,0,Pi},PlotLabel - >
\:0420 \:0443 \:0441 \:0441 \:043a \\::0438 \\::0435 \\:0431 \\::0443 \\:043a \\:0432 \\ \\:044b]]

如果您愿意,可以进一步将EMF转换为PDF或SWF。请参阅有关高质量EMF导出的一般提示从 Mathematica



另一种看似可靠的工作方式是仅将转换成西里尔语文本,然后放置使用 Inset 或使用 Labeled

  plotLabel = 
首先@ ImportString [ExportString [
\:0420 \:0443 \:0441 \:0441 \:043a \:0438 \:0435 \:0431 \:0443 \:043a \:0432 \:044b,
PDF],PDF];
标记[Plot [Sin [x],{x,0,Pi}],plotLabel,Top]

或者您可以直接使用概述文本作为 PlotLabel

  Export [C:\\1.pdf,Plot [Sin [x],{x,0,Pi},PlotLabel  - > plotLabel]] 

您可以通过编写一个简单的例程来概括此方法:

  cyrFix = First @ ImportString [ExportString [#,PDF],PDF]& 

您可以如下使用它:

<$导出[C:\\1.pdf,
绘图[Sin [x],{x,0,Pi},PlotLabel - >
cyrFix @\:0420 \:0443 \:0441 \:0441 \:043a \:0438 \:0435 \:0431 \:0443 \:043a\: 0432 \:044b]]


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.

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.

解决方案

One workaround is to export to EMF instead of PDF format:

Export["C:\\1.emf",
 Plot[Sin[x], {x, 0, Pi}, PlotLabel ->
   "\:0420\:0443\:0441\:0441\:043a\:0438\:0435 \:0431\:0443\:043a\:0432\:044b"]]

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 with Labeled:

plotLabel =
  First@ImportString[ExportString[
    "\:0420\:0443\:0441\:0441\:043a\:0438\:0435 \:0431\:0443\:043a\:0432\:044b",
       "PDF"], "PDF"];
Labeled[Plot[Sin[x], {x, 0, Pi}], plotLabel, Top]

Or you can use the outlined text directly as PlotLabel:

Export["C:\\1.pdf", Plot[Sin[x], {x, 0, Pi}, PlotLabel -> plotLabel]]

You can generalize this method by writing a simple routine:

cyrFix = First@ImportString[ExportString[#, "PDF"], "PDF"] &

You can use it as follows:

Export["C:\\1.pdf",
 Plot[Sin[x], {x, 0, Pi}, PlotLabel ->
  cyrFix@"\:0420\:0443\:0441\:0441\:043a\:0438\:0435 \:0431\:0443\:043a\:0432\:044b"]]

这篇关于将图形输出为PDF时,能否将特殊符号/西里尔字母输出到绘图标签中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 08:09