Hi @sttk3, I worked out the parameters I think. Have a look at this:
/**
* Exploration of Document.getDocumentInfoAsText.
* @author m1b
* @discussion https://community.adobe.com/t5/illustrator-discussions/how-to-use-getdocumentinfoastext/m-p/14206023/thread-id/386366
*/
(function () {
/** Whether to return info on the document's selection. */
var SELECTED_ITEMS_ONLY = false;
/**
* Info types for Document.
* @enum {Number}
*/
var DocumentInfoType = {
DOCUMENT: 2,
OBJECTS: 3,
GRAPHIC_STYLES: 4,
BRUSHES: 5,
SPOT_COLOR_OBJECTS: 6,
PATTERN_OBJECTS: 7,
GRADIENT_OBJECTS: 8,
FONTS: 9,
LINKED_IMAGES: 10,
EMBEDDED_IMAGES: 11,
FONT_DETAILS: 12,
REPEAT_OBJECTS: 13,
};
// example:
var outputFile; // outputFile = File('~/Desktop/document_info.txt');
var result = getDocumentInfoAsText(app.activeDocument, [DocumentInfoType.FONTS, DocumentInfoType.GRAPHIC_STYLES], SELECTED_ITEMS_ONLY, outputFile);
if (result)
alert('Result:\n' + result);
})();
/**
* Wrapper for `Document.getDocumentInfoAsText`
* method just for experimenting.
* Returns the contents of the output file.
* @param {Documennt} [doc] - an Illustrator Document (default: active document).
* @param {Array<DocumentInfoType>} [infoTypes] - array of DocumentInfoTypes (default: all types).
* @param {Boolean} [selectionOnly] - whether to report on just the document's selection (default: false).
* @param {File} [outputFile] - the file to write result to (default: temporary file, deleted after use).
* @returns {String}
*/
function getDocumentInfoAsText(doc, infoTypes, selectionOnly, outputFile) {
// for convenience:
var ALL_DOCUMENT_INFO_TYPES = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13];
var doc = doc || app.activeDocument,
infoTypes = infoTypes || ALL_DOCUMENT_INFO_TYPES,
selectionOnly = selectionOnly === true,
f = outputFile || File(Folder.temp.fsName + '/getDocumentInfoAsText.txt'),
success;
if (!f.parent.exists)
f.parent.create();
try {
success = doc.getDocumentInfoAsText(infoTypes, f, selectionOnly);
} catch (error) {
alert(error);
}
if (!success)
return;
f.open('r');
var result = f.read();
if (outputFile == undefined)
f.remove();
return result;
};
- Mark