Illustrator教程:C#对Illustrator (ai) 操作
Vivian 2018-04-26 来源 : 阅读 3403 评论 0

摘要:本文主要介绍了Illustrator教程的C#对Illustrator (ai) 操作,通过具体的解释说明,让我们从中学到Illustrator教程中C#对Illustrator (ai) 操作的代码,让我们对C#对Illustrator (ai) 操作越来越熟悉,能够在以后的学习中更加快速的弄明白其中的关键,便于更好的操作。

Illustrator教程:C#对Illustrator (ai) 操作

 

本文主要介绍了Illustrator教程的C#对Illustrator (ai) 操作,通过具体的解释说明,让我们从中学到Illustrator教程中C#对Illustrator (ai) 操作的代码,让我们对C#对Illustrator (ai) 操作越来越熟悉,能够在以后的学习中更加快速的弄明白其中的关键,便于更好的操作。

 

添加引用 Interop.Illustrator.dll,安装 Illustrator 后台在 com中找到 adobe  Illustrator cs* type library

 

[html] view plain copy
1. Illustrator.Application app = new Illustrator.Application();  
2.         Illustrator.Document doc = app.Documents.Add(Illustrator.AiDocumentColorSpace.aiDocumentCMYKColor, 400, 240);  
3.         //Illustrator.Document doc=app.Open("f://a.ai");  
4.   
5.         Illustrator.Layer layer1 = doc.Layers.Add();//新建图层  
6.         layer1.Name = "文字图层1";  
7.         Illustrator.TextFrame textFrame = layer1.TextFrames.Add();  
8.         //object[] position = new object[2] { 0, 0 };  
9.         //textFrame.Position = position;  
10.         textFrame.Contents = "测试文字";  
11.         textFrame.Left = 1;  
12.         textFrame.Top = 20;  
13.         textFrame.Rotate(0, null, null, null, null, null);   // 旋转  
14.         textFrame.CreateOutline();//文字转换成曲线  
15.   
16.   
17.         Illustrator.Layer layer = doc.Layers.Add();//新建图层  
18.         layer.Name = "文字图层2";  
19.   
20.         Illustrator.PathItem pt = doc.PathItems.Rectangle(100, 0, 300, 100);  
21.         Illustrator.TextFrame textFrame1 = layer.TextFrames.AreaText(pt);  
22.         textFrame1.Contents = "测试文字2word 123";  
23.         textFrame1.Rotate(0, null, null, null, null, null);   // 旋转  
24.   
25.         //文字样式开始  
26.         //字体设置  
27.         Illustrator.RGBColor rgbColor = new Illustrator.RGBColor();  
28.         rgbColor.Red = 255;  
29.         rgbColor.Green = 100;  
30.         Illustrator.CharacterStyle cs = doc.CharacterStyles.Add("bb");  
31.         Illustrator.CharacterAttributes cas = cs.CharacterAttributes;  
32.         cas.FillColor = rgbColor;  // 颜色  
33.         cas.TextFont = app.TextFonts["MicrosoftYaHei"];//字体  
34.         cas.Size = 30;  //文字大小pt  
35.   
36.         //描边  
37.         cas.StrokeWeight = 0.5;  
38.         Illustrator.RGBColor strokeColor = new Illustrator.RGBColor();  
39.         strokeColor.Red = 100;  
40.         strokeColor.Green = 255;  
41.         cas.StrokeColor = strokeColor;  
42.   
43.         cs.ApplyTo(textFrame1.TextRange, null);  // 应用到文字  
44.         //文字样式结束  
45.   
46.         //段对齐  
47.         Illustrator.ParagraphStyle ps = doc.ParagraphStyles.Add("aa");  
48.         Illustrator.ParagraphAttributes pa = ps.ParagraphAttributes;  
49.         pa.Justification = Illustrator.AiJustification.aiRight;  
50.         ps.ApplyTo(textFrame1.TextRange);  
51.   
52.   
53.         Illustrator.Layer layerPic = doc.Layers.Add();//新建图层  
54.         layerPic.Name = "图片图层";  
55.         //置入图片  
56.         Illustrator.PlacedItem pi = layerPic.PlacedItems.Add();  
57.         pi.File = "f://bottom01.gif";  
58.         pi.Top = 100;  
59.         pi.Left = 100;  
60.         pi.Rotate(45, null, null, null, null, null);  
61.         pi.Resize(400, 300, null, null, null, null, null, null);  
62.         pi.Embed();  
63.   
64.   
65.         Illustrator.IllustratorSaveOptions saveOptions = new Illustrator.IllustratorSaveOptions();  
66.         saveOptions.Compatibility = Illustrator.AiCompatibility.aiIllustrator14;//设置保存文件的版本,比如你可以使用aiIllustrator8等。  
67.         saveOptions.FlattenOutput = Illustrator.AiOutputFlattening.aiPreserveAppearance;  
68.         app.ActiveDocument.SaveAs("f://ai1.ai", saveOptions);   
69.         //app.ActiveDocument.Close(Illustrator.AiSaveOptions.aiDoNotSaveChanges);  
70.         //app.Quit();  
71.         app = null;

至此,关于C#对Illustrator (ai) 操作讲解完毕,本文由职坐标整理并发布,欢迎大家继续关注!更多关于Illustrator的内容请关注职坐标常用软件Illustrator频道!

 

 

 


本文由 @Vivian 发布于职坐标。未经许可,禁止转载。
喜欢 | 0 不喜欢 | 0
看完这篇文章有何感觉?已经有0人表态,0%的人喜欢 快给朋友分享吧~
评论(0)
后参与评论

您输入的评论内容中包含违禁敏感词

我知道了

助您圆梦职场 匹配合适岗位
验证码手机号,获得海同独家IT培训资料
选择就业方向:
人工智能物联网
大数据开发/分析
人工智能Python
Java全栈开发
WEB前端+H5

请输入正确的手机号码

请输入正确的验证码

获取验证码

您今天的短信下发次数太多了,明天再试试吧!

提交

我们会在第一时间安排职业规划师联系您!

您也可以联系我们的职业规划师咨询:

小职老师的微信号:z_zhizuobiao
小职老师的微信号:z_zhizuobiao

版权所有 职坐标-一站式IT培训就业服务领导者 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
 沪公网安备 31011502005948号    

©2015 www.zhizuobiao.com All Rights Reserved

208小时内训课程