如何tag/mark Ai文件中的一个对象并保存为pdf格式?

How to tag/mark an object in Ai file and keep it in a pdf format?

我有 AI 文件,我使用 AITagSuite 标记了一些艺术作品

(标签实际上存储为艺术对象字典中的字符串条目)

我想在不丢失标签的情况下将 ai 文件转换为 pdf。当我将 ai 文件转换为 pdf 时,我无法访问标签。

知道如何 tag/mark Ai 文件中的对象并将其保存在 pdf 中吗?

我还考虑过使用其他一些可以将 AI 文件作为输入并将其转换为带有标签的 pdf 的库,知道吗?

先谢谢你

这里是示例,您可以如何从 Illustrator 中将标记路径项的属性保存在类似 JSON 的文件中,并从该文件中读回它们:

var items = app.activeDocument.pathItems;

// add tags to a couple of pathItems
var tag = items[0].tags.add();
tag.name = 'tag1';
tag.value = '123';

var tag = items[1].tags.add();
tag.name = 'tag2';
tag.value = '456';

// put all tagged pathItems into the array 'tagged_items'
// and add to each of the items its properties:
// 'tags':            Array of object: [{name:value},{name:value},...]
// 'color':           Array of Numbers and Sting, for example: [10,0,25,15,'CMYKColor'] or [56.9845,'GrayColor']
// 'geometricBounds': Array of Numbers: [y1,x1,y2,x2]

var tagged_items = [];

var i = items.length;
while (i--) {
    var item = items[i];
    if (item.tags.length == 0) continue; // skip if the pathItem has no tags

    var tags = []; // make an array of tags
    for (var t=0; t<item.tags.length; t++) {
        var key = item.tags[t].name;
        var value = item.tags[t].value;
        var tag = {};
        tag[key] = value;
        tags.push(tag);
    }

    var fillColor = []; // make an array of fillColor properties
    for (var c in item.fillColor) fillColor.push(item.fillColor[c]);

    // put the item into the array of tagged items
    tagged_items.push  (
        {
            'tags': tags,
            'fillColor': fillColor,
            'geometricBounds': item.geometricBounds,
        }
    );  
}

// save the array in JSON-like file
var file = File('d:/tagged_items.json');
file.open('w');
file.write(tagged_items.toSource());
file.close();

// read the array from the file and show the properties
var file = File('d:/tagged_items.json');
var tagged_items = $.evalFile(file);
for (var i in tagged_items) alert('pahtItem ' + i + ':\n' + props(tagged_items[i]));


// ----------------------------------------------------------------------------
// returns a string with all properties of a given object
function props(obj) { 
    msg = '';
    for (var p in obj) msg += p + ': ' + obj[p].toSource() + '\n';
    return msg;
}

如果您设法使用 Acrobat 阅读 JSON 类文件并将其属性与 PDF 文件中对象的属性进行比较,您就有机会完成您的任务。

这只是一个例子。它不能很好地处理组、专色等。