473,401 Members | 2,125 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,401 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 20646
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: 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: 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
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,...
0
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...
0
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,...
0
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...
0
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,...
0
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...

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.