jfuck
Messages postés59Date d'inscriptionmercredi 31 mars 2004StatutMembreDernière intervention31 mars 2009
-
19 janv. 2009 à 17:02
cs_fauve
Messages postés661Date d'inscriptionvendredi 2 décembre 2005StatutMembreDernière intervention23 mars 2011
-
20 janv. 2009 à 22:38
Hello,
voila je cherchais comment imprimer un fichier HTML à partir d'une URL, en cherchant sur le forum j'ai vu que beaucoup de gens avait le meme probleme...mais que peu de monde avait la réponse.
Je vous donne ma solution qui fonctionne, c'est un script qui vient de l'aide microsoft (c'est pas de moi) c'est efficace :
Private Sub PrintHelpPage()
' Create a WebBrowser instance.
Dim webBrowserForPrinting As New WebBrowser()
' Add an event handler that prints the document after it loads.
AddHandler webBrowserForPrinting.DocumentCompleted, New _
WebBrowserDocumentCompletedEventHandler(AddressOf PrintDocument)
' Set the Url property to load the document.
webBrowserForPrinting.Url = New Uri("http://urlquivabien.html")
End Sub
Private Sub PrintDocument(ByVal sender As Object, _
ByVal e As WebBrowserDocumentCompletedEventArgs)
Dim webBrowserForPrinting As WebBrowser = CType(sender, WebBrowser)
' Print the document now that it is fully loaded.
webBrowserForPrinting.Print()
MessageBox.Show("print")
' Dispose the WebBrowser now that the task is complete.
webBrowserForPrinting.Dispose()
End Sub
il suffit dappeler la fonction PrintHelpPage() (et de mettre la bonne url)
Voila j'epsère que ca vous aidera parce que moi j'ai bien galéré la dessus :).
cs_fauve
Messages postés661Date d'inscriptionvendredi 2 décembre 2005StatutMembreDernière intervention23 mars 20118 20 janv. 2009 à 22:38
Salut,
Voici ton code que j'ai modifié un peu et qui fonctionne parfaitement :
Note : Je préfère celui-là car on peut sélectionner l'imprimante sur laquelle on veut imprimer, on peut la configurer, définir le nombre de copies, si on veut imprimer toutes les pages ou seulement quelques unes.
Private Sub PrintHelpPage(ByVal URL As String)
' Crée une instance d'un WebBrowser.
Dim webBrowserForPrinting As New WebBrowser
' Ajoute un évènement qui appellera la fonction PrintDocument
' dés que le document sera entièrement chargé.
AddHandler webBrowserForPrinting.DocumentCompleted, AddressOf PrintDocument
' Défini la page web qui doit être imprimée.
webBrowserForPrinting.Url = New Uri(URL)
End Sub
Private Sub PrintDocument(ByVal sender As Object, ByVal e As WebBrowserDocumentCompletedEventArgs)