473,385 Members | 1,912 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

PRINTING and changing paper size

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.


Nov 21 '05 #1
3 31753
"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/>

Nov 21 '05 #2
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/>

Nov 21 '05 #3
"D Witherspoon" <dw**********@noway.org> schrieb:
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.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Chris Bingham | last post by:
Hi everyone, Does anyone know how to fix the paper orientation depending on the paper size used when printing with the WebBrowser control please? What I've got is a HTML file, containing 1 big...
7
by: tm | last post by:
I am trying to print a form using the following code, everything works fine but the margins are not acted upon. What I am I doing wrong? Private Sub CaptureScreen() Dim myGraphics As...
2
by: Sukh | last post by:
Hi I am stuck with a problem Can anyone help me out from this... I am printing a report on pre-printed continue paper using dot-matrix printer using vb.net. Data is printing on all the...
9
by: Sukh | last post by:
Hello anyone, I am printing a pre-printed continue paper on dot-matrix printer using vb.net winform. For printing I am creating custom size paper and selecting the same for printing. Everything...
6
by: Brewtzaff | last post by:
Hello, I have a little problem to print my reports on custom sized paper. I got a db containing clubmembers, a query which selects only the needed infos to print out my membershipcards. My...
1
by: Anne DeBlois | last post by:
Hi, I want to programatically set the paper size of a print document. I created a class that inherits PrintDocument, so I can print some database records on 8" x 10" paper. I added this line...
8
by: Steve Macleod | last post by:
Hi, I was wondering if anyone had a solution for printing HTML elements (especially style elements). I do not wish to make any changes to the page, other than in the <css media="print"block. I can...
2
by: Brad Pears | last post by:
I have a vb.net 2005 application and am using the print preview screen. This screen has a printer icon on it that the user can use to print the document currently being viewed. It uses the default...
9
by: Gurbinder Kaur | last post by:
Hi, i have made a project for printing fee receipt. Using Windows-XP, VBasic 6.0 & Ms-Access-97. i have designed a form for prinring receipts. m paper-size is 5x10. Two copies of bills in this...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.