Voici mon code :
----------------------------------------------------------------------
A insérer dans ClassCommun
----------------------------------------------------------------------
PublicSharedSub PrintReport(ByVal MyURL AsString)
Dim URL AsString = MyURL
Dim LocalFile AsString = "\\Cheminserveur\FicheClient.PDF"
'Recopie du report dans un fichier temporaire
DownloadWebFile(URL, LocalFile)
'Impression du fichier temporaire et envoye à acrobat
PrintAdobePDF(LocalFile)
'supression du fichier temporaire
If IO.File.Exists(LocalFile) Then IO.File.Delete(LocalFile)
EndSub
PublicSharedSub PrintAdobePDF(ByVal Filename AsString)
Dim myProcess AsNew Process()
myProcess.StartInfo.FileName = Filename
myProcess.StartInfo.WorkingDirectory = New IO.FileInfo(Filename).DirectoryName
myProcess.StartInfo.CreateNoWindow = True
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
myProcess.StartInfo.Verb = "Print"
myProcess.Start()
IfNot myProcess.HasExited Then
myProcess.WaitForInputIdle(5000)
Dim i AsInteger = 1
Dim lbRunning AsBoolean = True
While lbRunning And i <= 20
System.Threading.Thread.Sleep(500)
SelectCase myProcess.HasExited
CaseTrue : lbRunning = False
CaseFalse : lbRunning = Not myProcess.CloseMainWindow
EndSelect
i += 1
EndWhile
If lbRunning AndAlsoNot myProcess.HasExited Then myProcess.Kill()
myProcess.Dispose()
EndIf
EndSub
PublicSharedSub DownloadWebFile(ByVal URL AsString, ByVal DestFilename AsString)
Dim WebFile As System.Net.WebRequest
Dim LocalFile As System.IO.FileStream
Dim Buffer(16384) AsByte
Dim BytesRead AsLong
WebFile = System.Net.WebRequest.Create(URL)
WebFile.Credentials = System.Net.CredentialCache.DefaultCredentials
LocalFile = New IO.FileStream(DestFilename, IO.FileMode.Create)
With WebFile.GetResponse.GetResponseStream
Do
BytesRead = .Read(Buffer, 0, 16384)
LocalFile.Write(Buffer, 0, BytesRead)
LoopUntil BytesRead = 0
.Close()
EndWith
WebFile = Nothing
LocalFile.Flush()
LocalFile.Close()
LocalFile = Nothing
EndSub
----------------------------------------------------------------------
A insérer dans la page de code
----------------------------------------------------------------------
PrintReport (Nom du report)