Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 13
  1. #1
    Utente di HTML.it
    Registrato dal
    Jul 2006
    Messaggi
    128

    stampa like-browser

    Buongiorno, quando lancio questo comando
    codice:
    RUNDLL32.EXE MSHTML.DLL,PrintHTML "d:\test\quadratura_titoli_warning.html" "nome-stampante"
    viene aperta la finestra di stampa e vuole che
    1) prema "stampa"
    2) specifichi il nome del file

    Vorrei in qualche modo creare qualcosa di automatico che inserito il nome/path di ouput, senza nč invii nč digitazioni ulteriori, mi facesse la stampa.
    Grazie mille per l'aiuto

  2. #2
    Utente di HTML.it
    Registrato dal
    Jul 2006
    Messaggi
    128
    ho trovato qualcosa usando ExecWb ma non so dove partire... aiuto!

  3. #3
    Utente di HTML.it L'avatar di Kahm
    Registrato dal
    Dec 2004
    residenza
    Rome
    Messaggi
    3,582
    Originariamente inviato da patrick82
    ho trovato qualcosa usando ExecWb ma non so dove partire... aiuto!
    puoi specificarmi il linguaggio
    o al massimo l'ambiente di sviluppo?

    cosi' ti posso aiutare!!

    ciao
    NN vi diro mai chi sono in realta,
    tutti i miei 3D sono orfani, non insistete per farmi rispondere ai 3D aperti da me

  4. #4
    Utente di HTML.it
    Registrato dal
    Jul 2006
    Messaggi
    128
    Ciao, guarda, se fosse c++.NET sarebbe l'ideale ma anche VB.NET
    devo farlo girare su windows 2000 server. pensavo uno script in batch ma ripeto, tutto va bene. grazie

  5. #5
    Utente di HTML.it
    Registrato dal
    Jul 2006
    Messaggi
    128
    ?

  6. #6
    Utente di HTML.it L'avatar di Kahm
    Registrato dal
    Dec 2004
    residenza
    Rome
    Messaggi
    3,582
    in automatico non ho niente
    cmq posso consigliarti di usare il print document ,in questo modo ti fai una schermata sulle impostazioni della stampante e carichi il file su un printPreview dal quale in anteprima gli mostri il file

    su codeproject c'č molto materiale sul printPreview
    NN vi diro mai chi sono in realta,
    tutti i miei 3D sono orfani, non insistete per farmi rispondere ai 3D aperti da me

  7. #7
    Utente di HTML.it L'avatar di cassano
    Registrato dal
    Aug 2004
    Messaggi
    3,002
    codice:
    Public Class PrintingExample
        Private printFont As Font
        Private streamToPrint As StreamReader
        Private Shared filePath As String
        
        Public Sub New()
            Printing()
        End Sub    
        
        ' The PrintPage event is raised for each page to be printed.
        Private Sub pd_PrintPage(sender As Object, ev As PrintPageEventArgs)
            Dim linesPerPage As Single = 0
            Dim yPos As Single = 0
            Dim count As Integer = 0
            Dim leftMargin As Single = ev.MarginBounds.Left
            Dim topMargin As Single = ev.MarginBounds.Top
            Dim line As String = Nothing
            
            ' Calculate the number of lines per page.
            linesPerPage = ev.MarginBounds.Height / printFont.GetHeight(ev.Graphics)
            
            ' Iterate over the file, printing each line.
            While count < linesPerPage
                line = streamToPrint.ReadLine()
                If line Is Nothing Then
                    Exit While
                End If
                yPos = topMargin + count * printFont.GetHeight(ev.Graphics)
                ev.Graphics.DrawString(line, printFont, Brushes.Black, leftMargin, _
                    yPos, New StringFormat())
                count += 1
            End While
            
            ' If more lines exist, print another page.
            If Not (line Is Nothing) Then
                ev.HasMorePages = True
            Else
                ev.HasMorePages = False
            End If
        End Sub
         
        ' Print the file.
        Public Sub Printing()
            Try
                streamToPrint = New StreamReader(filePath)
                Try
                    printFont = New Font("Arial", 10)
                    Dim pd As New PrintDocument()
                    AddHandler pd.PrintPage, AddressOf pd_PrintPage
                    ' Print the document.
                    pd.Print()
                Finally
                    streamToPrint.Close()
                End Try
            Catch ex As Exception
                MessageBox.Show(ex.Message)
            End Try
        End Sub 'Printing    
        
        ' This is the main entry point for the application.
        Public Shared Sub Main()
            Dim args() As String = System.Environment.GetCommandLineArgs()
            Dim sampleName As String = args(0)
            If args.Length <> 1 Then
                Console.WriteLine("Usage: " & sampleName & " <file path>")
                Return
            End If
            filePath = args(0)
        End Sub
    End Class
    e questo se vuoi usare una prin dialog prima....

    codice:
    ' Declare the PrintDocument object.
    Private WithEvents docToPrint As New Printing.PrintDocument
    
    ' This method will set properties on the PrintDialog object and
    ' then display the dialog.
    Private Sub Button1_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles Button1.Click
    
        ' Allow the user to choose the page range he or she would
        ' like to print.
        PrintDialog1.AllowSomePages = True
    
        ' Show the help button.
        PrintDialog1.ShowHelp = True
    
        ' Set the Document property to the PrintDocument for 
        ' which the PrintPage Event has been handled. To display the
        ' dialog, either this property or the PrinterSettings property 
        ' must be set 
        PrintDialog1.Document = docToPrint
    
        Dim result As DialogResult = PrintDialog1.ShowDialog()
    
        ' If the result is OK then print the document.
        If (result = DialogResult.OK) Then
            docToPrint.Print()
        End If
    
    End Sub
    
    ' The PrintDialog will print the document
    ' by handling the document's PrintPage event.
    Private Sub document_PrintPage(ByVal sender As Object, _
       ByVal e As System.Drawing.Printing.PrintPageEventArgs) _
           Handles docToPrint.PrintPage
    
        ' Insert code to render the page here.
        ' This code will be called when the control is drawn.
    
        ' The following code will render a simple
        ' message on the printed document.
        Dim text As String = "In document_PrintPage method."
        Dim printFont As New System.Drawing.Font _
            ("Arial", 35, System.Drawing.FontStyle.Regular)
    
        ' Draw the content.
        e.Graphics.DrawString(text, printFont, _
            System.Drawing.Brushes.Black, 10, 10)
    End Sub
    il tutto preso da msdn....cercate cercate

  8. #8
    Utente di HTML.it
    Registrato dal
    Jul 2006
    Messaggi
    128
    scusa la mia ignoranza ma non č VB.NET o sbaglio?

  9. #9
    Utente di HTML.it L'avatar di cassano
    Registrato dal
    Aug 2004
    Messaggi
    3,002
    č vb.net 2005.

  10. #10
    Utente di HTML.it
    Registrato dal
    Jul 2006
    Messaggi
    128
    Scusa ancora una cosa, mi dice che il tipo Font,StreamReader e PrintPageEventArgs non sono definiti. siccome vengo dal "c" e di visual studio so proprio poco, mi sa mica dirmi come faccio ad includerli nel progetto? grazie

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.