Forum Discussion
AlexeyKryuchkov
Alumni
14 years agoHi Ofer,
As far as I understand, the problematic file is created by a virtual printer. If so, there's no guarantee that the file is always exclusively open by the printer from the files creation till the end of writing data to it. Thus, I think we'll need to try using your developer's advice and use a function that will delay the execution until the document gets out of the printing queue:
As far as I understand, the problematic file is created by a virtual printer. If so, there's no guarantee that the file is always exclusively open by the printer from the files creation till the end of writing data to it. Thus, I think we'll need to try using your developer's advice and use a function that will delay the execution until the document gets out of the printing queue:
function test()
{
waitUntilTheDocumentIsNotInTheQueue("TestDocument");
}
function waitUntilTheDocumentIsNotInTheQueue(document)
{
var wmi = GetObject("winmgmts:{impersonationLevel=impersonate}");
var documentFound = false;
do
{
var documentFound = false;
e = new Enumerator(wmi.InstancesOf("Win32_PrintJob"));
for(; !e.atEnd(); e.moveNext())
{
var s = e.item();
if (s.Document == document)
{
documentFound = true;
break;
}
}
}
while (documentFound)
}