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.ToolClickEventAr gs) 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.PaperSiz e = pkPaperSize
'prnt.PrinterSettings.DefaultPageSettings.Landscap e = 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.H eight = 850
pd.PrinterSettings.DefaultPageSettings.PaperSize.W idth = 1100
pd.PrinterSettings.DefaultPageSettings.Margins.Lef t = 0
pd.PrinterSettings.DefaultPageSettings.Margins.Rig ht = 0
pd.PrinterSettings.DefaultPageSettings.Margins.Top = 0
pd.PrinterSettings.DefaultPageSettings.Margins.Bot tom = 0
pd.Print()
End If
End Select
End Sub
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message news:%2****************@TK2MSFTNGP15.phx.gbl...
"D Witherspoon" <dw**********@noway.org> schrieb: 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)
///
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>