如何使用c#从adobeillustrator (.ai) TextFrame中获取字体大小
本文关键字:TextFrame 获取 字体 ai 何使用 adobeillustrator | 更新日期: 2023-09-27 17:54:28
我在c#中使用Adobe Illustrator库成功读取了Adobe Illustrator文件,但我无法获得TextFrame的FontSize。有人能帮忙吗?下面是我使用的代码:
Illustrator.Application aiApp = new Illustrator.Application();
Illustrator.Document doc = aiApp.Open(@"K:'test'test.ai",Illustrator.AiDocumentColorSpace.aiDocumentRGBColor, null);
List<Label> _labela = new List<Label>();
int cntr = 0;
foreach (TextFrame tf in doc.TextFrames)
{
_labela.Add(new Label());
// caktojme vetite per secilen label
_labela[cntr].Name = "lblTextFrame" + cntr;
_labela[cntr].AutoSize = true;
_labela[cntr].Text = tf.Contents;
_labela[cntr].ForeColor = Color.FromArgb((int)tf.Layer.Color.Red, (int)tf.Layer.Color.Green, (int)tf.Layer.Color.Blue);
_labela[cntr].Top = Math.Abs((int)tf.Top);
_labela[cntr].Left = Math.Abs((int)tf.Left);
cntr++;
}
foreach (Label lbl in _labela)
{
//lbl.BackColor = Color.Black;
this.Controls.Add(lbl);
this.SuspendLayout();
this.Refresh();
}
}
我没有看到TextFrame的任何属性。字形大小? ?(。有什么建议?
你看的字体名称&大小像这样
for (int i = 1; i <= doc.TextFrames.Count; i++)
{
Illustrator.TextFrame tF = doc.TextFrames[i];
Illustrator.TextFont objFont = tF.TextRange.CharacterAttributes.TextFont;
double size = tF.TextRange.CharacterAttributes.Size;
Console.WriteLine("Size: {0}, FontName: {1})", size, objFont.Name);
}