Forum Replies Created
-
AuthorPosts
-
Theunis De Jong
Member“It doesn't work for me” is a bit concise. What does(n't) it do that you would(n't)?
I'm not sure if it's mentioned in that thread but there are good reasons not to blindly apply your rule to any word at the end of a paragraph. What. if it's quite a long word, coincidentally?
Theunis De Jong
MemberTried the suggestions in this? https://forums.adobe.com/message/4098840
Theunis De Jong
MemberJesse, I think it would! But better put the ^ “Start of Paragraph” at the beginning, just to make sure it will only remove the right text.
(Sure, there is little chance that particular text may occur inside a sentence, but better make it double-safe!)
Theunis De Jong
MemberI spotted a tiny tiny error —
if (endpg >= app.activeDocument.pages.length)
in line 32 should read
if (endpg > app.activeDocument.pages.length)
but I dare not enter the Editor again … (As it is, this script now fails if you attempt to copy stuff all the way up to the very last page.)
Theunis De Jong
MemberThe copying-and-pasting bits are scriptable, but unfortunately the scripting interface doesn't allow access to your 'selected range of pages' in the Pages panel. (If this happens to get added in CS6, it'd be a welcome addition … I could think of a few useful things to do with it!)
Oh sure you can use Master pages (in fact, do you have reasons not to?), but I've had some fun writing this quick Javascript. It uses logical page numbers, unencumbered by stuff like roman numeral preambles and separe sections, so take care to enter the right ones.
//DESCRIPTION: Multi Copy to Multi Pages
// A Jongware script, 2-Feb-2012
// Make sure there is something appropriate selected
if (app.documents.length > 0 && app.selection.length > 0 && !(app.selection[0].hasOwnProperty(“baseline”)))
{
if (parseFloat(app.version) < 6)
multiCopy (app.selection);
else
app.doScript(multiCopy, ScriptLanguage.JAVASCRIPT, app.selection, UndoModes.ENTIRE_SCRIPT, “Multi Copy to Multi Pages”);
} else
{
alert (“No valid selection.nPlease select one single object with the black arrow before running this script.”);
}function multiCopy (sel)
{
originalPage = app.layoutWindows[0].activePage.documentOffset;
pagerange = prompt (“Apply to page range (logical page numbers):”, String(originalPage+1)+”-“+String(app.activeDocument.pages.length));
if (pagerange != null)
{
pagerange_nrs = pagerange.match(/^(d+)-(d+)$/);
if (pagerange_nrs.length == 3)
{
// ID pages start counting at 0, so subtract 1:
startpg = Number(pagerange_nrs[1])-1;
if (startpg < 0)
{
alert (“Surely you are joking? You can't start at page 0!”);
return;
}
endpg = Number(pagerange_nrs[2]);
if (endpg >= app.activeDocument.pages.length)
{
alert (“Surely you are joking? You can't continue after the last page!”);
return;
}
// Subtracting 1 not necessary for the end page
// (that's due to JavaScript for..loop behavior)
for (i=startpg; i<endpg; i++)
{
if (i != originalPage)
{
for (j=0; j<sel.length; j++)
sel[j].duplicate (app.activeDocument.pages[i]);
}
}
} else
alert ('Bad page range. Please use “from-to” syntax using logical page numbering.');
}
}(Edit: next time watch out for possible post enhancements..)
(Edit II: 3rd time lucky?)
Theunis De Jong
MemberLook in your Scripts panel, under Application. There you can find FindChangeByList, a handy script that reads its input fromman accompanying plain text file.
As a footnote to the above script: you cannot remove text and apply a paragraph style at once. If there is no text in the “Change To” field but there is some formatting specified, ID just apllies the formatting — and, in general, that's a good thing too! But in your case, you have to use each find command twice.
First, have it look for
^Report Type:
(and add a space after that), and apply your Type style in the Change To field. Then repeat the same Find, but this time do not apply any formatting, so it will delete the text. Doing everything twice manually is a bore, but the FindChangeByList script won't mind.
January 29, 2012 at 4:52 pm in reply to: Applying None Master page to one of the facing pages #61574Theunis De Jong
MemberInDesign really doesn't like objects that spill over to the adjacent page. Just this month, we fell into this trap when we removed two pages from an otherwise ready-for-press document, and when it was printed we noticed ID had put all of the pages-spanning on top of everything else. That needed reprinting … and it was a full colour job …
So now I always take care to cut off images at the binding page side. It's a bother, but better safe than (again) sorry.
But your outer glow problem is something else. In your case you could try this: draw an empty rectangle on top of the page (taking care to align it exactly on the binding edge); cut your glowing image; select the empty rectangle and use “Paste Into”. If I'm correct, this will neatly clip off the glowing border.
Theunis De Jong
MemberIt sounds to me that printer just can't handle the live transparency in your PDF. Even though it's not a problem from InDesign, Adobe already provided a fix by allowing you to work around it: export to a dumbed-down PDF that no longer uses live transparency.
Theunis De Jong
MemberHere is a script that will relentlessly remove all except in the list “keepThese”. Your example script replaces it with another, this one does not (so you might want to make sure this is what you meant).
Note that it solely tests the name of each character style, not if and where it is inside any style group. If you have two styles named “test” in two different groups, both will remain.
// Put your “keep” style names in here:
var keepThese = [ “test”, test2 ];charStyles = app.activeDocument.allCharacterStyles;
for (i=charStyles.length-1; i>=1; i=i-1)
{
if (!inList (keepThese, charStyles[i].name))
charStyles[i].remove();
}function inList (list, item)
{
var i;
for (i=0; i<list.length; i++)
if (list[i] == item)
return true;
return false;
}Theunis De Jong
MemberAh, I was too optimistic :(
The script is still beautified, but only on line 30. Right after the last i in the line that reads
for (i = links.length-1; i>=0; i–)
there should be two hyphens, not one single en-dash.
Theunis De Jong
MemberIt was easy – – surprisingly so! Kasyan's script did all the work, but he checks explicitly for a placed InDesign page. It took only a little check to find out under what name a placed Photoshop image is stored (see the commented-out “alert” line in my version below). It turned out to be a type of “Image” with a link type of “Photoshop” …
… (After about half an hour of head scratching..)
In fact it was so easy I decided to take it to the next level :) I added a little dialog that shows a selection of checkboxes, and you can turn each one on or off as you wish. The “layer names” list does not come from your placed images — although it is possible to read all of them, you'd get a load of extra names as well. You can adjust the list of names near the top of the function “Main”.
An oddity I ran into: it seems changing layer visibility invalidates the image and re-creates the link! That lead to the aforementioned bout of head-scratching, as suddenly “in the middle of the script”, it would report that the referenced image had disappeared! So I took a shortcut here: “refresh” the link on line 43, rather than re-using the loaded variable “placedFile”. Oh well, that's the sort of thing I do for fun.
So here is the script; it seems wrapping it up inside {pre} and {code} tags defeat WordPress post-beautifications (curly quotes, en-dashed) but if not, at least now you know what to look for.
Main();function Main()
{
var page, placedFile, links, layer, i, j, k,
doc = app.activeDocument,
pages = doc.pages;
var checklist = [];var layernames = [ “English”, “French”, “Dutch”, Russian ];
var ilDialog = app.dialogs.add({name:”Image Layers on/off”, canCancel:true});
with (ilDialog)
{
with(dialogColumns.add())
{
with(dialogRows.add())
{
staticTexts.add ({staticLabel:”Check to show, uncheck to hide”});
for (i=0; i<layernames.length; i++)
{
with(dialogRows.add())
checklist.push (checkboxControls.add({staticLabel:layernames[i], checkedState:false}));
}
}
}
}
var numChanges = 0;
var imageChange;
if (ilDialog.show() == true)
{
links = doc.links;
for (i = links.length-1; i>=0; i–)
{
placedFile = links[i].parent;
// show the internal type of this image:
// alert (placedFile.constructor.name+” / “+placedFile.itemLink.linkType);
if (placedFile.constructor.name == “Image” && placedFile.itemLink != null && placedFile.itemLink.linkType == “Photoshop”)
{
imageChange = false;
for (k=0; k<layernames.length; k++)
{
layer = links[i].parent.graphicLayerOptions.graphicLayers.item(layernames[k]);
if (layer.isValid && layer.currentVisibility != checklist[k].checkedState)
{
layer.currentVisibility = checklist[k].checkedState;
imageChange = true;
}
}
if (imageChange)
numChanges++;
}
}
alert(“Done, made changes in “+numChanges+” images”);
} else
{
ilDialog.destroy();
}
}Theunis De Jong
MemberIt's the minus at the end, right before the closing parens. If you check, you will find it's probably an en-dash — one of the features I actually like about the forum! Every two hyphens get converted into an en-dash. So in Javascript code, you need to change them back to 2 hyphens, like this:
j++
(Hah, I wasn't going to fall in the same trap :) Where I typed a + you need a -.)
Theunis De Jong
MemberThere is no way a PageMaker script can work with InDesign.
Sorry, but that's the way it is. It's not just that the scripting language is different — PageMaker has its own unique built-in language, InDesign exports its scripting model to any programming language that supports importing external definitions — or that items have different names than in InDesign (“style” vs. “ParagraphStyle”, etc.). The entire document model, objects, commands, and properties is entirely different.
To “use” the same script in InDesign, it has to be rewritten from scratch — you cannot “change just the right bits” to make it work.
Theunis De Jong
MemberOh the irony — in a script from the writer of Add Undo to Your Script! I forgot to include the magic lines at the top that checks the InDesign version.
This is a quick fix: Insert the following lines below the 5th line (if (app.docu…), above the 6th line (app.doScript ..):
if (app.version < 6)
labelItem(app.selection[0]);
else— it ought to get the main part of the script up and running. Unfortunately, it's still possible that that in turn may contain CS4-specific constructions, so if it still fails call me back in the morning.
Theunis De Jong
MemberUmm, that is not a good fix.
What it does, in essence, is finding any of the individual characters inside the set. The entire part between the square brackets means “any single one of the characters inside” (the OR | does not work inside a [character set] as such, it merely adds the | character to the allowed ones). You can see it indeed doesn't work if you check your example
Afghanistan War 1919–1922, 169, 171
— all it does is it finds all digit strings that are preceded by a space — or by a comma, quote, colon, or pipe, as you can see if you insert a pipe anywhere inside a string of digits.
By the way, the reason your first try failed:
(?<=,” |, |: )d+
is because Lookbehind does not work with strings of different length, they all have to be of the same length. For the same reason you cannot use repeating codes (+, *, and ?) inside a Lookbehind — I guess it would make poor old InDesign work too hard, going over all possible combinations.
But you can work around this by making them two Lookbehinds:
((?<=,” )|(?<=, |: ))d+
The first one checks for “comma-quote-space”, the second one for “comma-space” or “colon-space”. They are grouped inside parentheses with an OR bar, so if one doesn't work, the other takes over.
-
AuthorPosts
