Skip to content

Instantly share code, notes, and snippets.

@moluapple
moluapple / Import Multi-Page PDF.jsx
Last active December 12, 2015 13:09
置入多页面PDF (Illustrator CC 2015)
var doc = activeDocument,
f = File.openDialog ('选择文件 ', '*.pdf'),
p = prompt ('置入第 1 到?页', 5, '指定页数')
i = 0;
for (; ++i <= p;) {
app.preferences.setIntegerPreference('plugin/PDFImport/PageNumber', i);
doc.placedItems.add().file = f;
}
app.preferences.setIntegerPreference('plugin/PDFImport/PageNumber', 1);
@moluapple
moluapple / find visual center.jsx
Last active September 17, 2023 06:16
[Illustrator] 寻找不规则形状中心点(find visual center of an irregularly shaped polygon with Illustrator)
(function() {
var doc = app.activeDocument,
lays = doc.layers,
WORK_LAY = lays.add(),
NUM_LAY = lays.add(),
i = lays.length - 1,
lay;
// main working loop
for (; i > 1; i--) {
@moluapple
moluapple / GBKDecode.jsx
Last active September 18, 2017 14:01
GBK 乱码 fix
function GBKDecode(str) {
var f = File('gbk.txt'), gbk;
f.encoding = 'BINARY';
f.open('w'), f.write(str), f.close();
f.encoding = 'GBK';
f.open('r');
gbk = f.read();
f.close(), f.remove();
return gbk
}