Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Printing with dialog

$
0
0

I am trying to print a dataviewgrid from a GUI I made but I am having trouble with it printing. Here is the code I have for the printing.

 $print = New-Object System.Windows.Controls.PrintDialog
 $printPaginator = New-Object System.Windows.Documents.DocumentPaginator
 $print.CurrentPageEnabled = $true
 $print.UserPageRangeEnabled = $true
 if ($print.ShowDialog() -eq $true)
 {
  $print.PrintDocument($printPaginator, "test")

 }

ERROR: New-Object : A constructor was not found. Cannot find an appropriate constructor for type System.Windows.Documents.DocumentPaginator.

MainForm.psf (452): ERROR: At Line: 452 char: 20

ERROR: + $printPaginator = New-Object System.Windows.Documents.DocumentPaginator

ERROR: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ERROR: + CategoryInfo : ObjectNotFound: (:) [New-Object], PSArgumentException

ERROR: + FullyQualifiedErrorId : CannotFindAppropriateCtor,Microsoft.PowerShell.Commands.NewObjectCommand

ERROR:


Viewing all articles
Browse latest Browse all 6937

Trending Articles