Adobe
[rb] Removing textframe linkage with applescript
0You may sometimes need to be able to remove linkage between text frames in a particular document in Indesign. this script might come to the rescue:
tell application "Adobe InDesign CS2"
set theObjs to selection
if theObjs is equal to {} then
set theObjs to every text frame of document 1
end if
tell document 1 to set thebaseframe to make new text frame
repeat with tos in theObjs
if (class of tos as string) = "text frame" then
if end text frame of tos is not tos then
set next text frame of tos to next text frame of thebaseframe
set previous text frame of tos to previous text frame of thebaseframe
set autoflow thread orphaned of tos to true
end if
end if
end repeat
tell document 1 to delete thebaseframe
end tell
Extending illustrator capabilities with applescript
0While Illustrator offers a range of selection options that most of the time are enough for a particular scope, you might sometimes need to deal with a lot of stuff that come from other programs. This tiny script scrap might come to the rescue in many occasions:
tell application "Adobe Illustrator" set sel to selection set target to item 1 of sel set cls to class of target set objs to every page item of document 1 repeat with o in objs if (class of o is equal to cls) then set selected of o to true end if end repeat end tell
Getting content from a signed pdf document
0While most of the time the person that adds a signature for the document, disabling the editing of that document has good reasons for doing so, you sometimes might need to get that content to make some changes. For that you’ll need Acrobat Professional and OSX (tested on 10.4 … might work on 10.5 too):
First step: Open you pdf document with Preview and select the “Select tool” and select the part of the document that you need to edit and copy it.
Second step: Create a new document, hit paste and save it.
Note: at this point the document is editable but the fonts might come as garbage. However you can use the next steps to overcome that.
The next steps are only for flattening/outlining fonts.
Third step: Open the newly created document with Acrobat Professional and add a background to the document from Document -> Background – > Add and set the Opacity to 0(this is needed most of the time if you want to flatten the document).
Fourth step: Flatten the document from Advanced -> Print Production -> Flattener preview (check Convert all text to outlines if you want the fonts to be outlined) and save the document.
This should be it … now you should have an unlocked and working file.
Remove unnecessary shape points in Illustrator
0Did you ever got annoyed by those extra points in illustrator? This is something that might help …
var Geometry2DHelper = {
getSlope: function(pt1, pt2){
var i1 = pt1.anchor[1] - pt2.anchor[1];
var i2 = pt1.anchor[0] - pt2.anchor[0];
var slope = (i2 == 0) ? null : i1/i2;
return (slope == 0) ? 0 : slope;
},
getConstructionPoints: function(path) {
var pts = path.pathPoints;
var ctspts = "";
var x = 0;
if(pts.length < 3) return [];
for(i = pts.length - 1; i>=0;i--) {
var pt1 = (i == pts.length - 1) ? pts[0] : pts[i + 1];
var pt2 = (i == 0) ? pts[pts.length - 1] : pts[i - 1];
var slope = (this.getSlope(pts[i], pt1)!=null) ? this.getSlope(pts[i], pt1).toFixed(2) : null;
var slope2 = (this.getSlope(pts[i], pt2)!=null) ? this.getSlope(pts[i], pt2).toFixed(2) : null;
if(slope != slope2) ctspts += "|" + i + "|";
}
return ctspts;
},
remove: function(path, whitelist) {
alert(whitelist);
var pts = path.pathPoints;
if(whitelist=="") {
for(i = pts.length - 1; i>= 0; i--) {
if(i != pts.length - 1 && i!= 0) {pts[i].remove(); continue;}
}
return;
}
for(i = pts.length - 1; i>= 0; i--) {
if(whitelist.indexOf("|" + i + "|") < 0) {pts[i].remove(); }
}
},
isVertical: function(pt1, pt2) {
if(pt1.anchor[0].toFixed(1) == pt2.anchor[0].toFixed(1)) return true;
return false;
},
isHorizontal: function(pt1, pt2) {
if(pt1.anchor[1].toFixed(1) == pt2.anchor[1].toFixed(1)) return true;
return false;
}
}
for(j = app.activeDocument.pathItems.length - 1; j >= 0; j--) {
var x = Geometry2DHelper.getConstructionPoints(app.activeDocument.pathItems[j]);
//alert(x);
Geometry2DHelper.remove(app.activeDocument.pageItems[j], x);
}
Replace selected image with another in Indesign
0Ever needed to change a bunch of picture from one document with another in Indesign? This script does just that …
function indexOf(array, elem) {
for(j= 0; j < array.length; j++) {
if(array[j] ==elem) return true;
}
return false;
}
var rFile;
if(app.documents.length > 0){
var myDoc = app.activeDocument;
var docLinks = myDoc.links;
var myDialog = app.dialogs.add({name:"Parameters:", canCancel:true});
with(myDialog){
with(dialogColumns.add( {})){
with(borderPanels.add()){
with(dialogColumns.add()){
staticTexts.add({staticLabel:"Replace image:"});
}
with(dialogColumns.add()){
var mDrop = dropdowns.add({ stringList:GetLinks(docLinks), selectedIndex: 0});
}
}
}
}
if(myDialog.show() == true ) {
rFile = File.openDialog ("Replacement file:");
} else {
myDialog.destroy();
exit();
}
} else {
alert("There is no opened document.");
}
function GetLinks(lks) {
var lA = new Array();
var lAi = 0 ;
for(i=0; i < lks.length; i++){
if(indexOf(lA, lks[i].name) == false) { lA[lAi] = lks[i].name; lAi++; }
}
return lA;
}
var imgName = myDoc.links.item(mDrop.stringList[mDrop.selectedIndex]).name;
var vLinks = myDoc.links;
var o = 0;
for(i=vLinks.length-1; i >= 0; i--){
if(vLinks[i].name == imgName){
vLinks[i].relink(rFile);
}
}
for(i=vLinks.length-1; i >= 0; --i){
if(vLinks[i].status == LinkStatus.LINK_OUT_OF_DATE) vLinks[i].update();
}
Resize all items in selection to the desired size
0Let’s say you have a dozen circles that you want to resize from 2mm to 3mm … this script will help you do just that:
doc = app.activeDocument;
var sSize = prompt("Resize to how many millimeters?", "3", "Square size?");
var _s = (parseInt(sSize) == 'NaN') ? 0 : sSize;
var _w = new UnitValue(_s, "mm").as("pt");
var _h = new UnitValue(_s, "mm").as("pt");
if(doc.selection.length == 0) {
for(i = 0; i < doc.pathItems.length; i++) {
var x = Number((_w*100)/doc.pathItems[i].width);
var y = Number((_h*100)/doc.pathItems[i].height);
doc.pathItems[i].resize(x,y,true,true,true,true, 100, Transformation.CENTER);
}
} else {
for(i = 0; i < doc.selection.length; i++) {
var x = Number((_w*100)/doc.selection[i].width);
var y = Number((_h*100)/doc.selection[i].height);
doc.selection[i].resize(x,y,true,true,true,true, 100, Transformation.CENTER);
}
}
