'Save form as pdf (vb2010)

I have a form with one textbox, some labels and two buttons.

When I write the "ID" of a product in the textbox and press button1, the labels get filled with the data of that product (name, price etc).

When I press button2, the form is displayed in another window to be printed.

PrintForm1.PrintAction = Printing.PrintAction.PrintToPreview
PrintForm1.Print()

now, instead of printing the form, i want to save it as a pdf file (or docx)

Is there any way to do it?



Solution 1:[1]

The Printing.PrintAction also has an option to PrintToFile which writes to the system disc.

If RadioButton1.Checked = True Then
    PrintForm1.PrintAction = Printing.PrintAction.PrintToPrinter
ElseIf RadioButton2.Checked = True Then
    PrintForm1.PrintAction = Printing.PrintAction.PrintToPreview
Else
    PrintForm1.PrintFileName = _
  My.Computer.FileSystem.SpecialDirectories.CurrentUserApplicationData _
  & "Form1.eps"
    PrintForm1.PrintAction = Printing.PrintAction.PrintToFile
End If

Hope this gets you started. . .

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 remudada