110,547
社区成员
发帖
与我相关
我的任务
分享
for(int i = 1; i <= fileNum; i++)
{
string epsPath = epsFilePath + @"\杂志预览_" + i + ".eps";
Illustrator.Document doc = app.Open(epsPath, Illustrator.AiDocumentColorSpace.aiDocumentRGBColor, null);
Console.WriteLine("AI打开eps: "+i);
Illustrator.Artboards boards = doc.Artboards;
double width = 125 * 72 / 25.4;
double height = 214 * 72 / 25.4; //mm换算为pt
if (boards.Count > 0)
{
Illustrator.Artboard board = boards[1];
object[] array = (object[])board.ArtboardRect;
array[0] = ((double)array[2] - width) /2 ;
array[3] = ((double)array[1] - height) / 2;
array[2] = width + (double)array[0];
array[1] = height + (double)array[3];
boards[1].ShowCenter = true;
object[] array2 = new object[] { array[0], array[1], array[2], array[3] };
board.ArtboardRect = array2;
}
。。。。
doc.Export(svgPath, Illustrator.AiExportType.aiSVG, svg);
//自定义ArtboardRect,是一个数组表示矩形,转为Illustrator画板参数表示:
//W: array[2]-array[0]
//H: array[1]-array[3]
//X: array[0]
//Y: array[3] (参考原点:左下角)