Printing a wmf file

feurich

Well-known member
Joined
Oct 21, 2003
Messages
168
Location
Holland
Im trying to print a *.wmf file in the top center of the page, but it doesnt seem to work.
I know it has something to do with img.fromfile("F:\patch1.wmf")

Can anyone help me..???

Cire
 
This is what i have till now

I also want to print the readable text under the Barcode, but the distance between the barcode and the distance between the readable tekst is not equal so the readable tekst gets printed through the barcode,
Is there a way of preventing this? and how do I print a wmf image top center of the printed page ?

GreetZ,

Cire

[VB]
Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim oControl As Control
Dim strPrint As String
Dim X As Integer = 20 *** X coordinate of the printed text
Dim Y As Integer = 200 *** Y Coordinate of the printed text
Dim OffSet As Integer

For Each oControl In Me.Controls
If oControl.Name <> "btnPrint" And oControl.Name <> "cboIndexSet" And oControl.Name <> "cboPatch" Then

If TypeOf oControl Is TextBox Then
strPrint = strPrint & "*" & oControl.Text & "*" & vbCrLf & vbCrLf
End If
If TypeOf oControl Is ComboBox Then
strPrint = strPrint & "*" & oControl.Text & "*" & vbCrLf & vbCrLf
End If
If TypeOf oControl Is DateTimePicker Then
strPrint = strPrint & "*" & oControl.Text & "*" & vbCrLf & vbCrLf
End If
End If
Next
e.Graphics.DrawString(strPrint, New Font("Free 3 of 9 Extended", 36, FontStyle.Regular), Brushes.Black, X, Y)
e.Graphics.DrawString(strPrint, New Font("Arial", 22, FontStyle.Regular), Brushes.Black, X, (Y + 40))
e.HasMorePages = False
End Sub
[/VB]
 
Last edited by a moderator:
Solution ??

Here is what I did. Maybe there is a better solution.

In the button_Click
Code:
Dim ImageToPrint as Image
Private Sub btnPreview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPreview.Click


        Try
            Specify current page settings
            PrintDocument1.DefaultPageSettings = PrintPageSettings
            ImageToPrint = PictureBox1.Image *** Load picture into image object.
            PrintPreviewDialog1.Document = PrintDocument1
            PrintPreviewDialog1.ShowDialog()

        Catch ex As Exception
            MessageBox.Show(ex.Message)

        End Try
    End Sub

In the PrintPage Event.....
Code:
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
        Dim ImageForpage As Image
        Dim ImageRectangle As New RectangleF(50, 50, 700, 100)
        
        ImageForpage = ImageToPrint
        e.Graphics.DrawImage(ImageForpage, ImageRectangle)
    End Sub

If anyone has a more elegant solution please let me know.

Cire
 
Back
Top