private class Point
{
public double Left { get; set; }
public double Top { get; set; }
}
/// <summary>
/// 转换为先对画布的坐标
/// </summary>
/// <param name="cp">需要转换的当前坐标</param>
/// <param name="dp">画布坐标</param>
/// <returns></returns>
private Point GetRelativeCoord(Point cp, Point dp)
{
Point p = new Point { Left = cp.Left - dp.Left, Top = cp.Top - dp.Top };
return p;
}
/// <summary>
/// 根据相对画布坐标获得全局坐标
/// </summary>
/// <param name="cxdp">当前相对画布坐标</param>
/// <param name="dp">画布坐标</param>
/// <returns></returns>
private Point SetRelativeCoord(Point cxdp, Point dp)
{
Point p = new Point { Left = cxdp.Left + dp.Left, Top = cxdp.Top + dp.Top };
return p;
}
//获得画布坐标
Illustrator.Artboard artb = iDocsys.Artboards[1];
Point dp = new Point { Left = artb.ArtboardRect[0], Top = artb.ArtboardRect[1] };
Point p = SetRelativeCoord(new Point { Left = l, Top = -600 }, dp);
Illustrator.TextFrame newTextFrame = duanlayer.TextFrames.Add();
newTextFrame.Contents = text;
newTextFrame.Left = p.Left;
newTextFrame.Top = p.Top;
发表评论 取消回复