Copy link to clipboard
Copied
Hi,
I got a script for gen pdf
I want put a progress bar, and make it working
but I don't know where I can put the progress bar
and how
//=====================================================================
var doc = app.documents;
app.findTextPreferences = null;
app.findTextPreferences.underline = true;
for(var i=0;i<doc.length;i++)
{
var found = doc.findText();
var _pages = [];
for(var j=0;j<found.length;j++)
{
var txfms = found
for(var k=0;k<txfms.length;k++)
{
_pages.push(txfms
}
}
for(var j=0;j<_pages.length;j++)
{
if(_pages
{
_pages.splice(j,1);
}
}
if(_pages.length != 0)
{
app.pdfExportPreferences.pageRange = _pages.toString();
doc.exportFile(ExportFormat.PDF_TYPE, new File(doc.fullName.toString().replace(/\.indd$/i,".pdf")), false);
}
_pages = [];
}
//=================================================================== Can I put progress bar in here?
var counter = new Window("palette");
counter.prompt = counter.add("statictext",[0,0,80,20]);
counter.show();
var cells = app.activeDocument.allCellStyles;
for(var i = cells.length-1; i > 0; i--){
counter.prompt.text = String(i);
cells.verticalJustification = VerticalJustification.bottomAlign;
}
counter.close();
//===================================================================
app.findTextPreferences = null;
alert("Done.");
thanks
Harvey
Copy link to clipboard
Copied
Progress bars are described here: http://www.kahrel.plus.com/indesign/scriptui.html
Peter
Copy link to clipboard
Copied
Hi harvey,
you can add this code in "front or back" part of your script, try this
main();
function main(){
var progress_win = new Window ("palette");
var progress = progress_bar(progress_win, 2, 'Processing ... Completed');
delay(1);
progress.value = progress.value+1;
delay(1);
progress.parent.close();
}
// delay function found here
//found here http://www.wer-weiss-was.de/theme157/article1143593.html
function delay(prmSec){
prmSec *= 1000;
var eDate = null;
var eMsec = 0;
var sDate = new Date();
var sMsec = sDate.getTime();
do {
eDate = new Date();
eMsec = eDate.getTime();
} while ((eMsec-sMsec)<prmSec);
}
/**
* Taken from ScriptUI by Peter Kahrel
*
* @param {Palette} w the palette the progress is shown on
* @param {[type]} stop [description]
* @return {[type]} [description]
*/
function progress_bar (w, stop, labeltext) {
var txt = w.add('statictext',undefined,labeltext);
var pbar = w.add ("progressbar", undefined, 1, stop);
pbar.preferredSize = [300,20];
w.show ();
return pbar;
}
by
hasvi
Copy link to clipboard
Copied
Hi Harvey,
Try this,
var doc = app.documents;
app.findTextPreferences = null;
app.findTextPreferences.underline = true;
for(var i=0;i<doc.length;i++)
{
var found = doc.findText();
var _pages = [];
for(var j=0;j<found.length;j++)
{
var txfms = found
.texts[0].parentTextFrames; for(var k=0;k<txfms.length;k++)
{
_pages.push(txfms
.parentPage.name); }
}
for(var j=0;j<_pages.length;j++)
{
if(_pages
=== _pages[j-1]) {
_pages.splice(j,1);
}
}
if(_pages.length != 0)
{
app.pdfExportPreferences.pageRange = _pages.toString();
doc.exportFile(ExportFormat.PDF_TYPE, new File(doc.fullName.toString().replace(/\.indd$/i,".pdf")), false);
}
_pages = [];
}
var counter = new Window("palette");
counter.prompt = counter.add("statictext",[0,0,80,20]);
counter.show();
var cells = app.activeDocument.allCellStyles;
var w = new Window('palette');
w.pbar = w.add('progressbar', undefined, 0, cells.length);
w.pbar.preferredSize.width = 300;
w.show();
w.pbar.value = 0;
for(var i = cells.length-1; i > 0; i--)
{
w.pbar.value += 1;
counter.prompt.text = String(i);
cells.verticalJustification = VerticalJustification.bottomAlign;
}
counter.close();
app.findTextPreferences = null;
alert("Done.");
Regards,
Chinna
Copy link to clipboard
Copied
Hi, Chinna
thank you for your help
but the progress bar not really work
may be the progress bar need to put at beginning
Harvey
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more