We have a web application with a page full of graphs and a button on the page for printing to a pdf. When the button is selected the user is forwarded to a print friendly version of the page and on pageload a clientside vbscript function is executed to kickoff the process of printing the document to a pdf file that is stored on the clients machine.
All the above works but only if the users changes their browser security settings under ActiveX controls and plug-ins:
Set the setting for: Initialize and script ActiveX controls not marked as safe (to ENABLE). Obviously for most clients this is a problem to let unmarked activeX controls function at will. Is there a way around this solution?
I'm using 2.06d
The code is:
sub RunPDF
On Error Resume Next
CommonDialog1.ShowSave
If Err.Number=32755 Then
Err.Clear
On Error Goto 0
Exit Sub
End If
On Error Goto 0
Set pdf = CreateObject("CDIntF.CDIntF")
pdf.DriverInit "SSPDF"
pdf.SetDefaultPrinter
pdf.DefaultDirectory = Left(CommonDialog1.FileName, Len(CommonDialog1.FileName) - Len(CommonDialog1.FileTitle)-1)
pdf.DefaultFileName = CommonDialog1.FileName
pdf.FileNameOptions = NoPrompt + UseFileName
alert("Please choose SSPDF")
window.print()
pdf.RestoreDefaultPrinter
end sub
Also included in the web page is:
<OBJECT CLASSID="CLSID:5220cb21-c88d-11cf-b347-00aa00a28331">
<PARAM NAME="LPKPath" VALUE="Common.lpk"/>
</OBJECT>
<OBJECT ID="CommonDialog1" WIDTH="0" HEIGHT="0" CLASSID="CLSID:F9043C85-F6F2-101A-A3C9-08002B2F49FB" codebase="http://activex.microsoft.com/controls/vb5/comdlg32.cab">
<PARAM NAME="CancelError" VALUE="1"/>
<PARAM NAME="DialogTitle" VALUE="Save to PDF"/>
<PARAM NAME="Filter" VALUE="PDF Files (*.pdf)|*.pdf|All Files (*.*)|*.*"/>
</OBJECT>
Even if I remove the save dialog box objects and add a specific path and file name to the subroutine I still run into the problem with the security setting.
Anyone have any suggestions other than have the client buy a separate PDF writter program.
Thanks in advance.