arst06d
Programmer
- Nov 29, 2002
- 324
Hi
I need to print one or more access report in snapshot (.snp) format. To do this I build the Object and write it to the document. I I set the height & width then it displays fine.
When I come to print it, I write the Object, grab the newly written object and try to call its print method. I get a javascript error saying "Missing or Invalid snapshot file". Now we know this is not true, as we can see the report displayed in the viewer.
I think it's possibly a timing issue - if I put an alert in after I grab the new object and before I call the print method then it works fine. Without the alert - error.
I've tried putting in pauses using the function shown but still the same.
This is driving me mad - can anyone enlighten me?
Code:
function printReport(strReport)
{
var strObj;
//alert(strReport);
strObj = "<OBJECT id=SnapshotViewer style='LEFT: 0px; TOP: 0px' height='0%' width='0%' classid='CLSID:F0E42D60-368C-11D0-AD81-00A0C90DC8D9' VIEWASTEXT>";
strObj = strObj + "<PARAM NAME='_ExtentX' VALUE='16933'>";
strObj = strObj + "<PARAM NAME='_ExtentY' VALUE='12700'>";
strObj = strObj + "<PARAM NAME='_Version' VALUE='65536'>";
strObj = strObj + "<PARAM NAME='SnapshotPath' VALUE='" + strReport + "'>";
strObj = strObj + "<PARAM NAME='Zoom' VALUE='4'>";
strObj = strObj + "<PARAM NAME='AllowContextMenu' VALUE='-1'>";
strObj = strObj + "<PARAM NAME='ShowNavigationButtons' VALUE='-1'></OBJECT>";
var snpDiv = document.getElementById("snapshotDiv");
snpDiv.innerHTML = strObj;
//pausecomp(2000);
var snp = document.getElementById("SnapshotViewer");
//pausecomp(1000);
//alert(snp);
snp.PrintSnapshot(false);
}
function pausecomp(millis)
{
date = new Date();
var curDate = null;
do { var curDate = new Date(); }
while(curDate-date < millis);
}
</script>