Ok so I think your problem may be solved while dealing user interaction preferences. As you let native placement progress bars to appear, it does refresh the screen. So if you prevent those, you avoid refreshments and you should be good:
var main = function(){
//Let's store script preferences for further reset
var sp = app.scriptPreferences.properties,
//Set some new properties
np = {
//This will prevent screen refresh to the condition you…
enableRedraw:false,
//…set no interaction as dialogs would refresh teh screen
userInteractionLevel:UserInteractionLevels.NEVER_INTERACT,
},
//A reference to our main folder
fo,
//a reference to a possible error
error = false;
//Checking if context is ok so you avoid useless processing
if ( !app.documents.length || !app.selection.length ) return;
//Now you cand edit preferences
app.scriptPreferences.properties = np;
//.parent will return a Folder Object instance or should I say a File instance of type Folder
fo = File($.fileName).parent;
//Calling teh secondary routine
//try/catch will avoid script exit with script preferences not resetted.
try {
doPlacement ( fo );
}
catch(err){
error = true;
}
//because it's good habit to reverse user preferences
app.scriptPreferences.properties = sp;
alert( error? "An error occured", "Everything went fine");
}
var doPlacement = function(folder){
//A filter function to only retrieve PDF type files
var pdfFilter = function(f){ return /\.pdf$/i.test(f.name); },
//A reference to the retrieved pdf
pdfFile = folder.getFiles ( pdfFilter ),
//a reference to the sum of pdf files
n = pdfFile.length;
//Exit if no pdf files. That will avoid further useless processing
if ( !n ) return;
//Attibuting first PDF File object of the array to pdfFile
pdfFile = pdfFile[0];
//getting selection count
n = app.selection.length;
//Looping through selection
while ( n-- ) {
//obviously you want to deal with textframes only
if (app.selection instanceof TextFrame){
replaceAllCharsWithFile(app.selection, pdfFile);
}
}
}
//a third routine to replace all characters with supplied file
var replaceAllCharsWithFile = function(textFrame, file){
var placedFile;
var chars = textFrame.characters;
var n = chars.length;
var dup;
//removing any contents
textFrame.contents = "";
//looping through characters number
while (n--) {
if(!placedFile) {
placedFile = textFrame.insertionPoints[0].place(file)[0];
placedFile.fit(FitOptions.FRAME_TO_CONTENT);
//Not sure you need to double with PROPORTIONALLY
//as FRAME_TO_CONTENT would make the frame to adapt to the pdf image ?
}
else {
//Rather than re-placing and re-fitting
//we just duplicated the initial placed file
placedFile.parent.parent.duplicate(LocationOptions.AT_END, textFrame.insertionPoints[-1] );
}
}
}
//fastEntireScript is buggy
var u;
app.doScript ( "main();", u, u, UndoModes.ENTIRE_SCRIPT );