Ginister, on 29 January 2013 - 11:47 AM, said:
I've moved onto the print code but I'm getting the error "Out of memory" when I try and assign a file location to a print screen. I think it's because I have the wrong file type, but I'm not entirely sure.
Here's the code from the print form.
Here's the code from the print form.
PrintForm1.PrintFileName = CurDir() & "\Printout.png"
PrintForm1.Print()
You're right. It's actually encapsulated PostScript. You need to first make a bitmap of the client area of your form, then save it to a file in PNG format. Not as difficult as it seems...
Sub takescreenshot()
Try
Dim Img As New Bitmap(Me.Width, Me.Height)
Dim g As Graphics = Graphics.FromImage(Img)
g.CopyFromScreen(Me.Left, Me.Top, 0, 0, Img.Size)
g.Dispose()
Dim path As String = "j:\Printout.png"
Img.Save(path, Imaging.ImageFormat.Png)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
So, you need to do the following in order to print the form...
takescreenshot() ' saves the file
PrintForm1.PrintFileName = CurDir() & "\Printout.png" 'sets the filename to print from
PrintForm1.Print() ' prints the file
Edit: I haven't tried it, but your code might work if you save to a file with an extension of .eps
This post has been edited by lar3ry: 29 January 2013 - 12:46 PM

New Topic/Question
Reply





MultiQuote


|