Good Morning! Well it was a pretty quiet week. I had a lot of work related things to do so that is what I pretty much did. My daughter has been released to huber so that has got us all in an uproar as she needs many things. It will be interesting to see how this turns out. I pray for her daily despite everything that has happened.
Today’s topic is one that confounds many programmers. The PrintDocument object! Yes I can hear the snarling and gnashing of teeth going on out there. What we want to do is make the PrintDocument object follow our orders to make the document of legal size. If you have any experience with this you know this is not an easy task! Don’t forget if your printer does not support legal paper size (it happens) this will not work. Anyway, make it a great day!
Dim storedPageSettings As PageSettings = New PageSettings()
Dim PSize As PaperSize = Nothing
For Each PaperSizeContained As PaperSize In PrintDocument1.PrinterSettings.PaperSizes
If (PaperSizeContained.RawKind = Printing.PaperKind.Legal) Then
PSize = PaperSizeContained
If (PSize Is Nothing) Then
Throw New Exception("Oops! Can’t find Legal paper for this printer.")
storedPageSettings.PaperSize = PSize ‘<– this is the issue
storedPageSettings.Landscape = True
Dim dlg As New PrintPreviewDialog()
PrintDocument1.DefaultPageSettings = storedPageSettings
dlg.Document = PrintDocument1
Technorati Tags: vb.net,.NET Framework,csharp,Default,Paper,Size,Document,Legal,topic,PrintDocument,task,printer,PageSettings,