473,379 Members | 1,386 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,379 software developers and data experts.

Printing Problem - How to get CORRECT bounds of page

Hi,

Ok I am doing a print app, what I am trying to do is get the EXACT
boundaries of the page, I want to print to the top left, 0,0, which is fine,
but bottom right is a problem.

When I use ".VisibleClipBounds.Width" I get the correct with the first time,
for the default printer, that is set to A4.

If I select another printer from the list, it gets a bit hairy.
If the printer is not set to A4, the ".VisibleClipBounds.Width" are wrong.

If I set the page size to A4 is still does not work, it seems to me that the
page settings are the setttings for the default selected printer, even if
you select another printer.

Here is some code:

Private Sub printBtn_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles printBtn.Click

Dim blah As New PrintDocument
blah.DocumentName = "mydoc.doc"

AddHandler blah.PrintPage, AddressOf PrintPage

Dim printDialog1 As New PrintDialog
printDialog1.Document = blah

If (printDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK) Then

blah.PrinterSettings = printDialog1.PrinterSettings

blah.Print()
End If

End Sub

Private Sub PrintPage(ByVal sender As Object, ByVal ev As
PrintPageEventArgs)

Dim myWidth as single = ev.Graphics.VisibleClipBounds.Width
Dim myHeight as single = ev.Graphics.VisibleClipBounds.Height

ev.Graphics.DrawImage(printLogoImage.Image, (myWidth -
printLogoImage.Image.Width), (myHeight - printLogoImage.Image.Height),
printLogoImage.Image.Width, printLogoImage.Image.Height)

End Sub

''''''''''''''''
When you do this:
'''''''''''''''''''''''''''''''''''''''''''''''''' ''
For i As Int16 = 0 To
ev.PageSettings.PrinterSettings.PaperSizes.Count - 1
If ev.PageSettings.PrinterSettings.PaperSizes(i).Kind =
PaperKind.A4 Then
ev.PageSettings.PaperSize =
ev.PageSettings.PrinterSettings.PaperSizes(i)
Exit For
End If
Next


it does not update "VisibleClipBounds"

Any suggestions???
Thankyou
Joshua

Nov 20 '05 #1
1 1930
* "Joshua Anderson" <jo**@mastermind.net.au> scripsit:
Ok I am doing a print app, what I am trying to do is get the EXACT
boundaries of the page, I want to print to the top left, 0,0, which is fine,
but bottom right is a problem.

When I use ".VisibleClipBounds.Width" I get the correct with the first time,
for the default printer, that is set to A4.

If I select another printer from the list, it gets a bit hairy.
If the printer is not set to A4, the ".VisibleClipBounds.Width" are wrong.

If I set the page size to A4 is still does not work, it seems to me that the
page settings are the setttings for the default selected printer, even if
you select another printer.


Maybe you want to determine phys. margins:

<http://www.google.com/groups?selm=uLE8v9%23iDHA.2328%40TK2MSFTNGP12.phx. gbl>

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

<http://www.plig.net/nnq/nquote.html>
Nov 20 '05 #2

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

Similar topics

4
by: Jody Gelowitz | last post by:
I am having a problem with printing selected pages. Actually, the problem isn't with printing selected pages as it is more to do with having blank pages print for those pages that have not been...
16
by: gb | last post by:
Hi All, Ive created a popup page using 'var openWindow = window.open("new","pop")' And added content using openWindow.document.write(" "); statements. But now I would like to be able to print...
7
by: anders | last post by:
Hi! I have a panel formed as an A4-page, in this panel I have som labels, pictureboxes and a datagrid. How can I print the complete panel vith all it's controls? Regards Anders Aleborg
1
by: Dan Bass | last post by:
I've got a custom control that makes use of DrawString and DrawBezier, drawn from the graphics object passed by in the PaintEventArgs for the Paint event. I've not printed anything via c#...
1
by: Gidi | last post by:
Hi, I've created a form that prints a document which i created (with the printDocument class), I draw the page's lines and text. when i'm printing it on my computer, with my printer, the...
6
by: randy1200 | last post by:
I'm using Visual Studio 2005 and C#. I need to print a WinForm used for data entry as a graphic. In other words, I need to print the exact WinForm the user sees on the screen. I searched through...
3
by: Richard MSL | last post by:
I have an application that prints documents that it creates. It uses what I believe is a standard .NET way of doing so, like this: PrintDocument pd = new PrintDocument(); pd.PrintPage += new...
2
by: deepakfordotnet | last post by:
Hi, First of all let me confess that I could not get the solution to the same problem from an earlier post Printing :by Mr.Richard MSL (dated September 24th 2006) working. (Replied by Mr.Walter...
1
by: mehdi | last post by:
Hi, Consider a printing scenario where I have to draw the entire page on a 827x1169 (.01 inch) size. Thereafter, the entire bitmap has to be resized to fill a given Bounds rectangle (keeping the...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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.