473,748 Members | 6,037 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to change printer's physical print margins thru VB coding?

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
Jul 31 '06 #1
7 20723
You can use the margin property of

PrintDocument.D efaultPageSetti ngs

PrintDocument.D efaultPageSetti ngs.Margins.Top = ...
(hundredths of an inch)
PrintDocument.D efaultPageSetti ngs.Margins.Bot tom = ...
PrintDocument.D efaultPageSetti ngs.Margins.Lef t = ...
PrintDocument.D efaultPageSetti ngs.Margins.Rig ht = ...
(Imports System.Drawing. Printing)

http://msdn2.microsoft.com/en-us/lib...rs(d=ide).aspx

-tom

Mark ha scritto:
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
Jul 31 '06 #2
Hi Tom,
Thanks for reply
Using the code u sent sets the margins that we can see in print preview but
the physical margins of printer will be added to this margins. So I need to
change printer's physical margins by VB coding.

Another problem is that I am creating PrintDocument object but I am using
report viewer's print button to display print dialogue. I do not have any
idea how to handle this type of situation.

Any idea?

--
Osmotion Blue
"to************ **@uniroma1.it" wrote:
You can use the margin property of

PrintDocument.D efaultPageSetti ngs

PrintDocument.D efaultPageSetti ngs.Margins.Top = ...
(hundredths of an inch)
PrintDocument.D efaultPageSetti ngs.Margins.Bot tom = ...
PrintDocument.D efaultPageSetti ngs.Margins.Lef t = ...
PrintDocument.D efaultPageSetti ngs.Margins.Rig ht = ...
(Imports System.Drawing. Printing)

http://msdn2.microsoft.com/en-us/lib...rs(d=ide).aspx

-tom

Mark ha scritto:
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

Jul 31 '06 #3

Mark ha scritto:
Hi Tom,
Thanks for reply
Using the code u sent sets the margins that we can see in print preview but
the physical margins of printer will be added to this margins. So I need to
change printer's physical margins by VB coding.
make sure to set the also the right page size. There is no such a thing
like
"margins are added".
>
Another problem is that I am creating PrintDocument object but I am using
report viewer's print button to display print dialogue. I do not have any
idea how to handle this type of situation.
Never used report viewer. Be more specific: someone else may help you
>
Any idea?

--
Osmotion Blue
"to************ **@uniroma1.it" wrote:
You can use the margin property of

PrintDocument.D efaultPageSetti ngs

PrintDocument.D efaultPageSetti ngs.Margins.Top = ...
(hundredths of an inch)
PrintDocument.D efaultPageSetti ngs.Margins.Bot tom = ...
PrintDocument.D efaultPageSetti ngs.Margins.Lef t = ...
PrintDocument.D efaultPageSetti ngs.Margins.Rig ht = ...
(Imports System.Drawing. Printing)

http://msdn2.microsoft.com/en-us/lib...rs(d=ide).aspx

-tom

Mark ha scritto:
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
Jul 31 '06 #4
Hi Tom,
If we use this code
Dim p As New PrinterSettings ()
For Each s As String In PrinterSettings .InstalledPrint ers
p.PrinterName = s
MsgBox(p.Defaul tPageSettings.P rintableArea.To String)
Next
we will get each printer's default settings.

and if use
p.DefaultPageSe ttings.Margins. ToString
then this will give margins we can see in the print preview.

So if printer's default physical margin is 0 then we will not get any
difference between print preview and the printed page.

But if printer's default left physical margin is 17 (hundredth of inch) then
it will add extra 0.17 inch (0.43 cm) in addition to the left margin that we
set for the report.

--
Osmotion Blue
"to************ **@uniroma1.it" wrote:
>
Mark ha scritto:
Hi Tom,
Thanks for reply
Using the code u sent sets the margins that we can see in print preview but
the physical margins of printer will be added to this margins. So I need to
change printer's physical margins by VB coding.

make sure to set the also the right page size. There is no such a thing
like
"margins are added".

Another problem is that I am creating PrintDocument object but I am using
report viewer's print button to display print dialogue. I do not have any
idea how to handle this type of situation.

Never used report viewer. Be more specific: someone else may help you

Any idea?

--
Osmotion Blue
"to************ **@uniroma1.it" wrote:
You can use the margin property of
>
PrintDocument.D efaultPageSetti ngs
>
PrintDocument.D efaultPageSetti ngs.Margins.Top = ...
(hundredths of an inch)
PrintDocument.D efaultPageSetti ngs.Margins.Bot tom = ...
PrintDocument.D efaultPageSetti ngs.Margins.Lef t = ...
PrintDocument.D efaultPageSetti ngs.Margins.Rig ht = ...
>
>
(Imports System.Drawing. Printing)
>
http://msdn2.microsoft.com/en-us/lib...rs(d=ide).aspx
>
-tom
>
Mark ha scritto:
>
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
>
>

Jul 31 '06 #5
Use a PaperSize which matches *exactly* your paper (e.g. A4 or
whatever)
then set the margin to a value that includes (that is >=) the
"physical" margin
of the printer. Usually normal printers are not capable to use the
entire surface of the sheet
and leave some small margin, which I am calling "physical". Your margin
must be equal or greater than that in order not to have your drawing
clipped.

PrintDocument.D efaultPageSetti ngs.PaperSize = New
Printing.PaperS ize("Custom", 827, 1169) 'A4
'set margin so that they are at least equal to the "physical"
margins of the printer

[The PrintableArea property is not so important, unless you want to
make an attempt
to establish the size "physical" margins are. For you purposes you
might disregard this detail.
You can set it later, after you are already able to print fine with
arbitrary margins (anyway greater than the "physical" ones)]

-tom
Mark ha scritto:
Hi Tom,
If we use this code
Dim p As New PrinterSettings ()
For Each s As String In PrinterSettings .InstalledPrint ers
p.PrinterName = s
MsgBox(p.Defaul tPageSettings.P rintableArea.To String)
Next
we will get each printer's default settings.

and if use
p.DefaultPageSe ttings.Margins. ToString
then this will give margins we can see in the print preview.

So if printer's default physical margin is 0 then we will not get any
difference between print preview and the printed page.

But if printer's default left physical margin is 17 (hundredth of inch) then
it will add extra 0.17 inch (0.43 cm) in addition to the left margin that we
set for the report.

--
Osmotion Blue
"to************ **@uniroma1.it" wrote:

Mark ha scritto:
Hi Tom,
Thanks for reply
Using the code u sent sets the margins that we can see in print preview but
the physical margins of printer will be added to this margins. So I need to
change printer's physical margins by VB coding.
make sure to set the also the right page size. There is no such a thing
like
"margins are added".
>
Another problem is that I am creating PrintDocument object but I am using
report viewer's print button to display print dialogue. I do not have any
idea how to handle this type of situation.
Never used report viewer. Be more specific: someone else may help you
>
Any idea?
>
--
Osmotion Blue
>
>
"to************ **@uniroma1.it" wrote:
>
You can use the margin property of

PrintDocument.D efaultPageSetti ngs

PrintDocument.D efaultPageSetti ngs.Margins.Top = ...
(hundredths of an inch)
PrintDocument.D efaultPageSetti ngs.Margins.Bot tom = ...
PrintDocument.D efaultPageSetti ngs.Margins.Lef t = ...
PrintDocument.D efaultPageSetti ngs.Margins.Rig ht = ...


(Imports System.Drawing. Printing)

http://msdn2.microsoft.com/en-us/lib...rs(d=ide).aspx

-tom

Mark ha scritto:

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
Aug 1 '06 #6
Margins that I have set are greater than physical margins, but physical
margins are added to the margins that I have set.

And other issue is that I can not use PrintDocumnet object because I am
using report viewer.

Any idea?

"to************ **@uniroma1.it" wrote:
Use a PaperSize which matches *exactly* your paper (e.g. A4 or
whatever)
then set the margin to a value that includes (that is >=) the
"physical" margin
of the printer. Usually normal printers are not capable to use the
entire surface of the sheet
and leave some small margin, which I am calling "physical". Your margin
must be equal or greater than that in order not to have your drawing
clipped.

PrintDocument.D efaultPageSetti ngs.PaperSize = New
Printing.PaperS ize("Custom", 827, 1169) 'A4
'set margin so that they are at least equal to the "physical"
margins of the printer

[The PrintableArea property is not so important, unless you want to
make an attempt
to establish the size "physical" margins are. For you purposes you
might disregard this detail.
You can set it later, after you are already able to print fine with
arbitrary margins (anyway greater than the "physical" ones)]

-tom
Mark ha scritto:
Hi Tom,
If we use this code
Dim p As New PrinterSettings ()
For Each s As String In PrinterSettings .InstalledPrint ers
p.PrinterName = s
MsgBox(p.Defaul tPageSettings.P rintableArea.To String)
Next
we will get each printer's default settings.

and if use
p.DefaultPageSe ttings.Margins. ToString
then this will give margins we can see in the print preview.

So if printer's default physical margin is 0 then we will not get any
difference between print preview and the printed page.

But if printer's default left physical margin is 17 (hundredth of inch) then
it will add extra 0.17 inch (0.43 cm) in addition to the left margin that we
set for the report.

--
Osmotion Blue
"to************ **@uniroma1.it" wrote:
>
Mark ha scritto:
>
Hi Tom,
Thanks for reply
Using the code u sent sets the margins that we can see in print preview but
the physical margins of printer will be added to this margins. So I need to
change printer's physical margins by VB coding.
>
make sure to set the also the right page size. There is no such a thing
like
"margins are added".
>

Another problem is that I am creating PrintDocument object but I am using
report viewer's print button to display print dialogue. I do not have any
idea how to handle this type of situation.
>
Never used report viewer. Be more specific: someone else may help you
>

Any idea?

--
Osmotion Blue


"to************ **@uniroma1.it" wrote:

You can use the margin property of
>
PrintDocument.D efaultPageSetti ngs
>
PrintDocument.D efaultPageSetti ngs.Margins.Top = ...
(hundredths of an inch)
PrintDocument.D efaultPageSetti ngs.Margins.Bot tom = ...
PrintDocument.D efaultPageSetti ngs.Margins.Lef t = ...
PrintDocument.D efaultPageSetti ngs.Margins.Rig ht = ...
>
>
(Imports System.Drawing. Printing)
>
http://msdn2.microsoft.com/en-us/lib...rs(d=ide).aspx
>
-tom
>
Mark ha scritto:
>
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
>
>
>
>

Aug 1 '06 #7
Ah, that's all another story. I thought you were using a standard
PrintDocument.

About report viewer I know nothing (I prefer to code the report myself:
these tools are too primitive :).

-tom

Hinesh ha scritto:
Margins that I have set are greater than physical margins, but physical
margins are added to the margins that I have set.

And other issue is that I can not use PrintDocumnet object because I am
using report viewer.

Any idea?

"to************ **@uniroma1.it" wrote:
Use a PaperSize which matches *exactly* your paper (e.g. A4 or
whatever)
then set the margin to a value that includes (that is >=) the
"physical" margin
of the printer. Usually normal printers are not capable to use the
entire surface of the sheet
and leave some small margin, which I am calling "physical". Your margin
must be equal or greater than that in order not to have your drawing
clipped.

PrintDocument.D efaultPageSetti ngs.PaperSize = New
Printing.PaperS ize("Custom", 827, 1169) 'A4
'set margin so that they are at least equal to the "physical"
margins of the printer

[The PrintableArea property is not so important, unless you want to
make an attempt
to establish the size "physical" margins are. For you purposes you
might disregard this detail.
You can set it later, after you are already able to print fine with
arbitrary margins (anyway greater than the "physical" ones)]

-tom
Mark ha scritto:
Hi Tom,
If we use this code
Dim p As New PrinterSettings ()
For Each s As String In PrinterSettings .InstalledPrint ers
p.PrinterName = s
MsgBox(p.Defaul tPageSettings.P rintableArea.To String)
Next
we will get each printer's default settings.
>
and if use
p.DefaultPageSe ttings.Margins. ToString
then this will give margins we can see in the print preview.
>
So if printer's default physical margin is 0 then we will not get any
difference between print preview and the printed page.
>
But if printer's default left physical margin is 17 (hundredth of inch) then
it will add extra 0.17 inch (0.43 cm) in addition to the left margin that we
set for the report.
>
--
Osmotion Blue
>
>
"to************ **@uniroma1.it" wrote:
>

Mark ha scritto:

Hi Tom,
Thanks for reply
Using the code u sent sets the margins that we can see in print preview but
the physical margins of printer will be added to this margins. So I need to
change printer's physical margins by VB coding.

make sure to set the also the right page size. There is no such a thing
like
"margins are added".

>
Another problem is that I am creating PrintDocument object but I am using
report viewer's print button to display print dialogue. I do not have any
idea how to handle this type of situation.

Never used report viewer. Be more specific: someone else may help you

>
Any idea?
>
--
Osmotion Blue
>
>
"to************ **@uniroma1.it" wrote:
>
You can use the margin property of

PrintDocument.D efaultPageSetti ngs

PrintDocument.D efaultPageSetti ngs.Margins.Top = ...
(hundredths of an inch)
PrintDocument.D efaultPageSetti ngs.Margins.Bot tom = ...
PrintDocument.D efaultPageSetti ngs.Margins.Lef t = ...
PrintDocument.D efaultPageSetti ngs.Margins.Rig ht = ...


(Imports System.Drawing. Printing)

http://msdn2.microsoft.com/en-us/lib...rs(d=ide).aspx

-tom

Mark ha scritto:

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


Aug 2 '06 #8

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

Similar topics

5
7122
by: Hank | last post by:
My Access 2000 code has been running for several years in our main plant. Now we need to install it, as a stand-along application, at remote sites, some of which are out of state. My problem is the printer destination for special reports such as stickers and mailing labels. The Mailing Label report is, of course, designed here for a specific printer (Mailing Label). At another site, the name could be completely different. Other than...
1
1702
by: AngelCaido | last post by:
ok... so i have Internet Explorer open, with let say http://www.google.com i want my application to print that page into a file so i have a printer PS-Printer installed i dont know .. how .. to change the printer how to tell to explorer to print how to add the path of the saved file Thanks...
0
1075
by: gavin | last post by:
Want to print to a file in MDI Format. Have set up a Microsoft Office Document Image Writer Printer. How can I change the Default Folder in Printing Preferences in the Advanced Tab Programmatically?
2
1870
by: Dennis | last post by:
I use the PageSetUpDialog to set the margins on my HP Laser Jet 4 printer. I set both margins to 1 with a paper size of 8.5 x 11 (Letter). When printing, print starts as it should on the left margin but the right margin is 1/2 inch off, i.e., 1/2 inch from the right side of the paper instead of 1 inch). Has anyone else had this problem and if so, is there a reason it does this? In code, the graphics in the PrintPage event has the...
1
2834
by: scrawnyguns | last post by:
There's probably something easy I'm missing here. When I run a print operation in my program (Microsoft VB.Net Form) I have some code that sets the print margins so that it leaves a nice gap, however, these gaps do not work. No matter what I set the margins to, the printer (HP Color Laserjet) always prints the same (top left corner with about a 5mm gap). Please Help.
8
2882
by: Phil Stanton | last post by:
Using Access 2000 (Yes I know there is no Printer specified) and an MDE File (Yes I know I can't open a report in design view). Is there any way using VBA of temporarily changing the report's printer from the default printer for that report to a PDF995 printer (so that i can print it to a file for subsequent emailing) then back to the default Epsom 830 printer? Thanks for any help Phil
1
1362
by: Murty | last post by:
I am giving printout from windows xp. its give error message like "PRINTER CAN NOT PRINT SPOOLED REQUEST. SPOOLED PAGES ARE NOT PRINT "
3
4147
drhowarddrfine
by: drhowarddrfine | last post by:
I have a simple vbscript that extracts a web page, saves it to a file, then uses notepad to print that file to the default printer. What can I do to make it print to a specified non-default printer? txtfile.WriteLine(xmlhttp.responseText) txtfile.Close 'enable this to print 'oWS.Run "NotePad.exe /p " + path Unrelated, the page printed is set for letter size paper width so some lines print a few characters, then...
0
1620
by: bobi | last post by:
Hi, i have runn the sample on page http://www.codeproject.com/KB/dotnet/NET_Printer_Library.aspx?display=Print to manage the Printer Serrings but the problem is, that i need printer-permissions to set the settings. Are there other ways to change the printer settings from c# without "Manage Printers"-permission?
0
8991
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8830
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9324
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 most users, this new feature is actually very convenient. If you want to control the update process,...
1
6796
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4606
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3313
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
2
2783
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.