Share via


XmlForm.Print Method (Boolean)

Prints the form content as it is rendered the form's active view by displaying the Print dialog box.

Namespace: Microsoft.Office.InfoPath
Assembly: Microsoft.Office.InfoPath (in microsoft.office.infopath.dll)

Syntax

'Declaration
'Usage

Parameters

  • showPrintDialog
    Set to true to display the Print dialog box to allow the user to configure where and how to print the form. When set to false, the form is printed on the default printer.

Exceptions

Exception type Condition

InvalidPrinterException

The form cannot be printed.

InvalidOperationException

The Print method was called from the ViewSwitched event.

InvalidOperationException

The Print method was called from the Loading event.

ArgumentNullException

The parameter passed to this method is null.

ArgumentException

The parameter passed to this method isnot valid. For example, it is of the wrong type or format.

SecurityException

The form template is not configured for Full Trust using the Security and Trust category of the Form Options dialog box.

Remarks

The Print (showPrintDialog) method raises exceptions if the method was called from event handlers for the ViewSwitched or Loading events, or is called from a form that is not fully trusted.

This member can be accessed only by forms opened from a form template that as been configured to run with full trust using the Security and Trust category of the Form Options dialog box. This member requires full trust for the immediate caller and cannot be used by partially trusted code. For more information, see "Using Libraries from Partially Trusted Code" on MSDN.

This type or member can be accessed only from code running in forms opened in Microsoft Office InfoPath 2007.

Note

If you host InfoPath 2007 in a Windows Form application by adding an InfoPath FormControl to the Windows form, calling XmlForm.Print(true) from the hosted InfoPath form will raise the following exception:InvalidCastException: Specified cast is not valid.There is no workaround for this in InfoPath 2007. This is not an issue in InfoPath 2010.

Example

In the following example, the Print (showPrintDialog) method of the XmlForm class is used to print the current view by displaying the Print dialog box.

this.Print(true);
Me.Print(True)

.NET Framework Security

  • PrintingPermission  for printing the form. Associated enumeration: System.Drawing.Printing.PrintingPermissionLevel.DefaultPrinting

See Also

Reference

XmlForm Class
XmlForm Members
Microsoft.Office.InfoPath Namespace