Print to PDF

thebriansmith

New member
Joined
Mar 11, 2009
Messages
1
Programming Experience
1-3
I'm developing a database program in VBE 2008 and I want to be able to print a form as a PDF. Is there a relatively simple way to accomplish this?
 
Both with PDFsharp and iTextSharp libraries you can compose Pdf documents. You should be able to find learning resources on the internet for both of them.

To get an image of form you can do this:
VB.NET:
Dim bmp As New Bitmap(Me.Width, Me.Height)
Me.DrawToBitmap(bmp, New Rectangle(Point.Empty, Me.Size))
Or if some controls don't paint correctly you can copy what is currently displayed at screen:
VB.NET:
Dim bmp As New Bitmap(Me.Width, Me.Height)
Dim g As Graphics = Graphics.FromImage(bmp)
g.CopyFromScreen(Me.Location, Point.Empty, Me.Size)
g.Dispose()
 
Back
Top