PRINTING and changing paper size

D

D Witherspoon

No matter what I do the default paper size is always either A3 or 11 by 8.5
..

Here is the code.

Dim dlg As DialogResult

pd.DocumentName = "Weld Image"

Dim pkPaperSize As New Printing.PaperSize("sdfgsfdg", 850, 1100)

pd.DefaultPageSettings.PaperSize = pkPaperSize

prnt.Document = pd

prnt.AllowSomePages = False

prnt.AllowSelection = False

prnt.PrintToFile = False

prnt.PrinterSettings.DefaultPageSettings.PaperSize = pkPaperSize

dlg = prnt.ShowDialog()

If dlg = DialogResult.OK Then

pd.PrinterSettings = prnt.PrinterSettings

pd.Print()

End If



In the OnPrint event I have also tried setting the correct paper size to get
this to go. Nothing works worth a shit.
 
H

Herfried K. Wagner [MVP]

D Witherspoon said:
No matter what I do the default paper size is always either A3 or 11 by
8.5

\\\
PrintDocument1.DefaultPageSettings.PaperSize = _
New PaperSize("My Custom format", 100, 100)
///
 
D

D Witherspoon

Yeah, you would think that would work..

Should create a 1" by 1" page.

I've tried all of that.

I have changed the PaperSize on the PrintDocument.DefaultPageSettings object,
the
PrintDocument.PrinterSettings.DefaultPageSettings object

and the

e.PageSettings object in the PrintPage event.

none of this does anything. thats why I am getting frustrated. it defaults to A3... prints it, the printer asks you to instert A3 paper.

What am I doing wrong? Am I wasting my time... is this an impossible feat.... Here is all the code if you want to take a look and see if you can spot something...

Private Sub PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles pdImage.PrintPage

Dim pen As New System.Drawing.Pen(Color.Tan)

'Dim rect As New System.Drawing.Rectangle(25, 25, 750, 1050)

Dim img As Image = upbImage.Image

Dim largestRatio As Double = Math.Max(img.Width / 700, img.Height / 780)

Dim mx As System.Drawing.Drawing2D.Matrix = New System.Drawing.Drawing2D.Matrix(1.0 / largestRatio, 0, 0, 1 / largestRatio, 0, 0)

Dim ps As New Printing.PaperSize("paper", 100, 100)





e.PageSettings.PaperSize = ps

e.PageSettings.PaperSize.Height = 100

e.PageSettings.PaperSize.Width = 100

e.PageSettings.Landscape = False

e.Graphics.Transform = mx

e.Graphics.DrawImageUnscaled(img, 0, 25)

Dim rushes

' Create font and brush.

Dim drawFont As New Font("Arial", 10)

Dim drawBrush As New SolidBrush(Color.Black)

' Create point for upper-left corner of drawing.

'Dim x As Single = 20.0F

Dim y As Single = 20.0F

' Set format of string.

Dim drawFormat As New StringFormat

' drawFormat.FormatFlags = StringFormatFlags.DirectionVertica

e.Graphics.DrawString(CurrentAssy.PartNo, drawFont, drawBrush, 40.0F, y, drawFormat)

e.Graphics.DrawString("Mod Note: " & CurrentAssy.ModNote, drawFont, drawBrush, 275.0F, y, drawFormat)

e.Graphics.DrawString("Date Printed: " & Format(Now(), "MMM-dd-yyyy"), drawFont, drawBrush, 450.0F, y, drawFormat)



'e.PageSettings.PaperSize.PaperName = "letter"

'e.PageSettings.PaperSize.Height = 85

'e.PageSettings.PaperSize.Width = 110

'e.PageSettings.Landscape = False

'Dim i As Integer

'For i = 0 To e.PageSettings.PrinterSettings.PaperSizes.Count - 1

'e.PageSettings.PrinterSettings.PaperSizes.Item(i).Kind = Printing.PaperKind.Letter

'If e.PageSettings.PrinterSettings.PaperSizes.Item(i).Kind =Printing.PaperKind.Letter Then

' Exit For

'End If

'Next



End Sub

Private Sub utbImage_ToolClick(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinToolbars.ToolClickEventArgs) Handles utbImage.ToolClick

Dim pd As Printing.PrintDocument

pd = pdImage

If upbImage.Image Is Nothing Then

MsgBox("No Image To Print", MsgBoxStyle.Exclamation)

Exit Sub

End If

Select Case e.Tool.Key

Case "Preview"

pd.DocumentName = "Weld Image"

Dim pkPaperSize As New Printing.PaperSize("fgsfdg", 100, 100)

pd.DefaultPageSettings.PaperSize = pkPaperSize

upDlg.PrintPreviewControl.Document = pd

upDlg.TopMost = True

upDlg.ShowDialog()

Case "Print"

Dim dlg As DialogResult

pd.DocumentName = "Weld Image"

Dim pkPaperSize As New Printing.PaperSize("sdfgsfdg", 100, 100)

pd.DefaultPageSettings.PaperSize = pkPaperSize

pd.DefaultPageSettings.Landscape = False

pd.PrinterSettings.DefaultPageSettings.Landscape = False

pd.PrinterSettings.DefaultPageSettings.PaperSize = pkPaperSize

prnt.Document = pd

prnt.AllowSomePages = False

prnt.AllowSelection = False

prnt.PrintToFile = False









'prnt.PrinterSettings.DefaultPageSettings.PaperSize = pkPaperSize

'prnt.PrinterSettings.DefaultPageSettings.Landscape = False

MsgBox(pd.DefaultPageSettings.ToString)

dlg = prnt.ShowDialog()

If dlg = DialogResult.OK Then

pd.PrinterSettings = prnt.PrinterSettings

pd.PrinterSettings.DefaultPageSettings.Landscape = False

pd.PrinterSettings.DefaultPageSettings.PaperSize.Height = 850

pd.PrinterSettings.DefaultPageSettings.PaperSize.Width = 1100

pd.PrinterSettings.DefaultPageSettings.Margins.Left = 0

pd.PrinterSettings.DefaultPageSettings.Margins.Right = 0

pd.PrinterSettings.DefaultPageSettings.Margins.Top = 0

pd.PrinterSettings.DefaultPageSettings.Margins.Bottom = 0

pd.Print()

End If

End Select

End Sub
 
H

Herfried K. Wagner [MVP]

D Witherspoon said:
Yeah, you would think that would work..

Should create a 1" by 1" page.

I've tried all of that.

Mhm... It works just fine on my machine. Maybe the problem is related to
the printer you are using.
 
Top