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

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 20590
You can use the margin property of

PrintDocument.DefaultPageSettings

PrintDocument.DefaultPageSettings.Margins.Top = ...
(hundredths of an inch)
PrintDocument.DefaultPageSettings.Margins.Bottom = ...
PrintDocument.DefaultPageSettings.Margins.Left = ...
PrintDocument.DefaultPageSettings.Margins.Right = ...
(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.DefaultPageSettings

PrintDocument.DefaultPageSettings.Margins.Top = ...
(hundredths of an inch)
PrintDocument.DefaultPageSettings.Margins.Bottom = ...
PrintDocument.DefaultPageSettings.Margins.Left = ...
PrintDocument.DefaultPageSettings.Margins.Right = ...
(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.DefaultPageSettings

PrintDocument.DefaultPageSettings.Margins.Top = ...
(hundredths of an inch)
PrintDocument.DefaultPageSettings.Margins.Bottom = ...
PrintDocument.DefaultPageSettings.Margins.Left = ...
PrintDocument.DefaultPageSettings.Margins.Right = ...
(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.InstalledPrinters
p.PrinterName = s
MsgBox(p.DefaultPageSettings.PrintableArea.ToStrin g)
Next
we will get each printer's default settings.

and if use
p.DefaultPageSettings.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.DefaultPageSettings
>
PrintDocument.DefaultPageSettings.Margins.Top = ...
(hundredths of an inch)
PrintDocument.DefaultPageSettings.Margins.Bottom = ...
PrintDocument.DefaultPageSettings.Margins.Left = ...
PrintDocument.DefaultPageSettings.Margins.Right = ...
>
>
(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.DefaultPageSettings.PaperSize = New
Printing.PaperSize("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.InstalledPrinters
p.PrinterName = s
MsgBox(p.DefaultPageSettings.PrintableArea.ToStrin g)
Next
we will get each printer's default settings.

and if use
p.DefaultPageSettings.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.DefaultPageSettings

PrintDocument.DefaultPageSettings.Margins.Top = ...
(hundredths of an inch)
PrintDocument.DefaultPageSettings.Margins.Bottom = ...
PrintDocument.DefaultPageSettings.Margins.Left = ...
PrintDocument.DefaultPageSettings.Margins.Right = ...


(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.DefaultPageSettings.PaperSize = New
Printing.PaperSize("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.InstalledPrinters
p.PrinterName = s
MsgBox(p.DefaultPageSettings.PrintableArea.ToStrin g)
Next
we will get each printer's default settings.

and if use
p.DefaultPageSettings.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.DefaultPageSettings
>
PrintDocument.DefaultPageSettings.Margins.Top = ...
(hundredths of an inch)
PrintDocument.DefaultPageSettings.Margins.Bottom = ...
PrintDocument.DefaultPageSettings.Margins.Left = ...
PrintDocument.DefaultPageSettings.Margins.Right = ...
>
>
(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.DefaultPageSettings.PaperSize = New
Printing.PaperSize("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.InstalledPrinters
p.PrinterName = s
MsgBox(p.DefaultPageSettings.PrintableArea.ToStrin g)
Next
we will get each printer's default settings.
>
and if use
p.DefaultPageSettings.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.DefaultPageSettings

PrintDocument.DefaultPageSettings.Margins.Top = ...
(hundredths of an inch)
PrintDocument.DefaultPageSettings.Margins.Bottom = ...
PrintDocument.DefaultPageSettings.Margins.Left = ...
PrintDocument.DefaultPageSettings.Margins.Right = ...


(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
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...
1
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...
0
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 ...
2
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...
1
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,...
8
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...
1
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
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?...
0
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...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.