【问题标题】:How to get FontSize from an Adobe Illustrator (.ai) TextFrame using C#?如何使用 C# 从 Adob​​e Illustrator (.ai) TextFrame 获取 FontSize?
【发布时间】:2013-01-01 10:36:18
【问题描述】:

我正在使用 C# 中的 Adob​​e Illustrator 库成功读取 Adob​​e 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.FontSize 的任何属性??? :( 。有什么建议吗!?

【问题讨论】:

    标签: c# font-size adobe-illustrator


    【解决方案1】:

    你这样读字体名称和大小

    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);
    }
    

    【讨论】:

      猜你喜欢
      • 2013-05-18
      • 2012-01-02
      • 1970-01-01
      • 2011-02-24
      • 2011-08-12
      • 2013-07-07
      • 1970-01-01
      • 2017-10-04
      • 2015-07-07
      相关资源
      最近更新 更多