473,569 Members | 2,526 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Override Printer Margins (?)

Hi,

We are developing a database application in Visual Basic.NET 2005. The
application will print label pages. Using the PrintDocument and GDI+
classes, I noticed a slight change when printing to a laser printer and when
printing to an inkjet printer. It's got to be the margins (defined by the
printer driver).

Is it possible to programmaticall y override the driver's margins in VB (at
our risks)? If so, how to? Thanks in advance,

ANNE DEBLOIS
Jul 3 '06 #1
5 11133
Hi Anne,

Thank you for your post.

Based on my understanding, your question is how to control printed page's
margin. If I've misunderstood anything, please feel free to post here.

You can force the printer use your specified margins by setting
PrintDocument.D efaultPageSetti ngs.Margins, for example:

PrintDocument1. DefaultPageSett ings.Margins = New Printing.Margin s(0, 0,
0, 0)
PrintDocument1. OriginAtMargins = True
PrintPreviewDia log1.Document = PrintDocument1
PrintPreviewDia log1.ShowDialog ()

When OriginAtMargins is true, the Graphics object location takes into
account the PageSettings.Ma rgins property value and the printable area of
the page. When OriginAtMargins is false, only the printable area of the
page is used to determine the location of the Graphics object origin, the
PageSettings.Ma rgins value is ignored.

Hope this helps. Please feel free to post here if anything is unclear.

Regards,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 4 '06 #2
Hi,

I think you got it right, at least for now, I think this is what I was
looking for.

Thank you, Mr. Wang!

Anne

"Walter Wang [MSFT]" <wa****@online. microsoft.coma écrit dans le message
de news: EZ************* *@TK2MSFTNGXA01 .phx.gbl...
Hi Anne,

Thank you for your post.

Based on my understanding, your question is how to control printed page's
margin. If I've misunderstood anything, please feel free to post here.

You can force the printer use your specified margins by setting
PrintDocument.D efaultPageSetti ngs.Margins, for example:

PrintDocument1. DefaultPageSett ings.Margins = New Printing.Margin s(0, 0,
0, 0)
PrintDocument1. OriginAtMargins = True
PrintPreviewDia log1.Document = PrintDocument1
PrintPreviewDia log1.ShowDialog ()

When OriginAtMargins is true, the Graphics object location takes into
account the PageSettings.Ma rgins property value and the printable area of
the page. When OriginAtMargins is false, only the printable area of the
page is used to determine the location of the Graphics object origin, the
PageSettings.Ma rgins value is ignored.

Hope this helps. Please feel free to post here if anything is unclear.

Regards,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

Jul 4 '06 #3
Hi,

Appreciate your update and response. If you have any other questions or
concerns, please do not hesitate to contact us. It is always our pleasure
to be of assistance.

Have a nice day!

Regards,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 5 '06 #4
Hi,

I am sorry for the delay. I just tried the code you provided:
PrintDocument1. DefaultPageSett ings.Margins = New Printing.Margin s(0, 0,
0, 0)
PrintDocument1. OriginAtMargins = True
I added this code to print a rectangle located at the very upperleft corner
of the page:

Dim rectangle As New Rectangle(0, 0, 400, 80)

e.Graphics.Fill Rectangle(Brush es.Cyan, rectangle)

e.Graphics.Draw Rectangle(Pens. Cyan, rectangle)
I tried it two different printers, and I got my rectangle printed within a
1-inch margin!! Something has got to be wrong in my code...

Anne
Sep 20 '06 #5
Hi,

I also changed the following line:
PrintDocument1. DefaultPageSett ings.Margins = New Printing.Margin s(0, 0, 0,
0)

To this code:
PrinterDocument 1.PrinterSettin gs.DefaultPageS ettings.Margins = New
Printing.Margin s(0,0,0,0)

Still no luck

I even changed the zeros for 200, and expected a 2-inch margin, but again I
got 1 inch.

What might be the problem? I am using .NET 2.0 (VS 2005)

ANNE DEBLOIS

"Anne DeBlois" <an*********@co mmunity.nospama écrit dans le message de
news: e2************* *@TK2MSFTNGP06. phx.gbl...
Hi,

I am sorry for the delay. I just tried the code you provided:
> PrintDocument1. DefaultPageSett ings.Margins = New Printing.Margin s(0,
0,
0, 0)
PrintDocument1. OriginAtMargins = True

I added this code to print a rectangle located at the very upperleft
corner of the page:

Dim rectangle As New Rectangle(0, 0, 400, 80)

e.Graphics.Fill Rectangle(Brush es.Cyan, rectangle)

e.Graphics.Draw Rectangle(Pens. Cyan, rectangle)
I tried it two different printers, and I got my rectangle printed within a
1-inch margin!! Something has got to be wrong in my code...

Anne

Sep 20 '06 #6

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

Similar topics

2
3442
by: qumpus | last post by:
My program right now generates USPS style shipping label using System.Drawing.Graphics. It works fine except that the printer prints really slowly. I want to make my program take advantage of true type fonts. So I assume it's possible to send Font Type and the text to the printer, and the printer should digest and print faster. Still, barcode...
1
2064
by: Kinetic - Paul G | last post by:
Hi All Hope someone can help out . . . I have a system that worked fine in A97 .and Win 98 with NT server . . . 10 PCs running a front end MDB and usual backend MDB with tables on the server. All PCs have identical printer setups pointing to a Xerox and a Canon printer on the network.
3
4844
by: bla | last post by:
Hello all, Does anybody have working sample VBA code to change printerdriver in a report and to get a list of available drivers and there functionality? It is for Access 2000. This version of Access has no printer collection object yet. I need to work with the DevMode and DevNames properties of a report object. Please, you help me the...
0
1253
by: cnlai | last post by:
I used Panasonic printer KX P-1124 to preview 2 MS Access reports. In one preview, the left margin was adjusted (I supposed it was the unprintable region); the right margin remained what I set. In another preview, the left margin was adjusted as above; however the right margin was also adjusted (the unprintable right margin was set to 0)....
8
9602
by: Tinus | last post by:
Hello all, Because you have been so helpfull the last couple of times, I thought after testing and wasting more than 20 pages (and google-ling for 3 days :-( ). I would ask you again for your help. The problem is this: If I print a rectangle which begins at (0,0) and the margins are also set to 0 (l:0, t:0, r:0, b:0) then it prints fine...
2
2995
by: Lighting_dragon | last post by:
Hi. I try to get the printable area of the printer (Margins). I have used Defaultpagesettings.Printersettings.Margins.Top, .Left, .... But it didn't give the true values. Posted Via Usenet.com Premium Usenet Newsgroup Services ---------------------------------------------------------- ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **...
7
2742
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 Graphics = Me.CreateGraphics() Dim s As Size = Me.Size memoryImage = New Bitmap(s.Width, s.Height, myGraphics) Dim memoryGraphics As Graphics =...
7
20690
by: Mark | last post by:
Hi, I am creating application in VB 2005. and when I print report it adds extra 0.45 cm margin on left and top, and the reason for this is physical margins of printer. Is it possible to change printer's physical margins using VB coding? Cheers -- Osmotion Blue
0
848
by: vijiraji | last post by:
How to set Printer Margin i.e., setting Top, Left, Right and Bottom margin for the page being printed? I am not using Print Page event of PrintDocument control. in .NET C# Language. Thanks in Advance.
0
7700
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7614
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7676
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5513
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3642
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2114
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.