473,586 Members | 2,546 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

BUG: Printing

Hi,

I am working on the PrintDocument, PrintDialog, PageSetupDialog and
PrintPreviewCon trol components of Visual Studio .NET 2003. My developement
machine is running Windows XP.

There are some problems I encountered while using them. Please note that,
the Regional and Language setting on my machine is using "Metric"
measurement system (where the default is "US"). In this case, the
measurement unit is "milimeters " and not "inches".
PROBLEM #1
``````````````
The first problem is with PageSetupDialog . The following code,

Dim pagesettings As System.Drawing. Printing.PageSe ttings
Dim pagesetupdialog As System.Windows. Forms.PageSetup Dialog

pagesettings = New System.Drawing. Printing.PageSe ttings
With pagesettings.Ma rgins
.Left = 100
.Right = 100
.Top = 100
.Bottom = 100
End With

pagesetupdialog = New System.Windows. Forms.PageSetup Dialog
With pagesetupdialog
.PageSettings = pagesettings
.ShowDialog()
End With

' Values printed out are not the same as entered
With pagesettings.Ma rgins
Console.WriteLi ne(.Left)
Console.WriteLi ne(.Right)
Console.WriteLi ne(.Top)
Console.WriteLi ne(.Bottom)
End With

will reproduce the problem I'm facing.

Before calling the ShowDialog() method of the PageSetupDialog component, I
have already set the Margins to 100. Although my OS's measurement system is
set to "Metric", Visual Studio .NET still uses inches (0.01 in) for it's
measurement unit. In my case, the Margins are set to 1 inch.

On calling the ShowDialog() method, what you see is the margins are all set
to 10 (and the unit is milimeters). On clicking the OK button, the
PageSetupDialog component will convert the value entered in it's dialog to
inches (0.01 in). As the result, the margins after the ShowDialog() is
called are changed to 39 (100/2.54=39.xxxxxx) .

This surely is a BUG (or am I missing something here).

I have a solution for this problem and the code is as below.

Dim pagesettings As System.Drawing. Printing.PageSe ttings
Dim pagesetupdialog As System.Windows. Forms.PageSetup Dialog

pagesettings = New System.Drawing. Printing.PageSe ttings
With pagesettings.Ma rgins
.Left = 100
.Right = 100
.Top = 100
.Bottom = 100
End With

pagesetupdialog = New System.Windows. Forms.PageSetup Dialog
With pagesetupdialog
.PageSettings = pagesettings

' Keep the original setting
Dim marginSaved As System.Drawing. Printing.Margin s
marginSaved = pagesettings.Ma rgins

' Convert to milimeters
pagesettings.Ma rgins =
System.Drawing. Printing.Printe rUnitConvert.Co nvert(pagesetti ngs.Margins,
System.Drawing. Printing.Printe rUnit.Display,
System.Drawing. Printing.Printe rUnit.TenthsOfA Millimeter)

' Show the page setup dialog
If .ShowDialog() = DialogResult.Ca ncel Then
' If user clicked Cancel, restore the saved margin
pagesettings.Ma rgins = marginSaved
End If
End With

With pagesettings.Ma rgins
Console.WriteLi ne(.Left)
Console.WriteLi ne(.Right)
Console.WriteLi ne(.Top)
Console.WriteLi ne(.Bottom)
End With

But there is a problem with it. The conversion between milimeters and inches
causes the measurement to be inaccurate.
PROBLEM #2
``````````
The OriginAtMargins property of the PrintDocument component does not work
properly when the PrintDocument is added into the PrintPreviewCon trol.
Setting the value to True does not effect the preview shown by
PrintPreviewCon trol but the printed result is correct.
PROBLEM #3
``````````
When handling the PrintPage event of the PrintDocument, if the
OriginAtMargins of the PrintDocument is set to True and I set,

e.Graphics.Page Unit = GraphicsUnit.Mi llimeter

then the top margin is measured as milimeters while the left margin is
measured as inches.
The problem discuss above might not be bugs but I have checked the MSDN
library but it does not seem to help much. Any help is really appreciated.

Thanks in advance.
Jul 21 '05 #1
0 2283

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

Similar topics

0
2119
by: Programatix | last post by:
Hi, I am working on the PrintDocument, PrintDialog, PageSetupDialog and PrintPreviewControl components of Visual Studio .NET 2003. My developement machine is running Windows XP. There are some problems I encountered while using them. Please note that, the Regional and Language setting on my machine is using "Metric" measurement system...
34
1880
by: Marcel van Kervinck | last post by:
Dear all, I would like to confirm my suspicion of a compiler bug in gcc4 for MacOSX. The code example below expects that the initializer of 'v' sets all elements in v.u.bytes to zero, as specified by the C99 standard: """21 If there are fewer initializers in a brace-enclosed list than there are elements or members of an aggregate, the...
3
2653
by: Jochen Kalmbach | last post by:
Hello, if an PrinterSettings-Instance is not set-up correctly (for example just by using the default-constructor), then the "ToString()"_method will throw an exception! Unhandled Exception: System.ArgumentException: The value '0' is not a valid value for the enum 'Duplex'.
2
2220
by: Martin | last post by:
I have encountered a bug in print preview: In my program, data for printing is taken from arrays. When print preview is invoked or page is printed directly, it is ok, but when user prints from print preview, any data that was in array is not draw, so only thing printed is header and footer. Arrays with data are in the same scope as...
4
5381
by: Steph. | last post by:
Hi, Is there a BUG in the printdialog ? When I create a PrintDialog ans set the "DefaultPageSettings.Landscape" property to "false" and then display the dialog, select "Landscape" and click OK, the value of the "DefaultPageSettings.Landscape" is still false !!?? Code Exemple : PrintDialog PDialog = new PrintDialog();...
0
1162
by: Programatix | last post by:
Hi, I am working on the PrintDocument, PrintDialog, PageSetupDialog and PrintPreviewControl components of Visual Studio .NET 2003. My developement machine is running Windows XP. There are some problems I encountered while using them. Please note that, the Regional and Language setting on my machine is using "Metric" measurement system...
9
1666
by: Summercoolness | last post by:
it seems that the behavior of "print" is that it will round off properly for any floating point imperfection, such as shown in the first two samples. The third sample seems to be a bug? It doesn't know how to handle the floating imperfection in this case. 1.2344999999999999 1.2345 1.234
4
1799
by: Number 11950 - GPEMC! Replace number with 11950 | last post by:
When www.geoceanis.com is sent to the print preview or alternatively the printer, the second page is displayed or printed by IE, but lost to Gecko (Netscape, Firefox, Moxilla, etc...). NOTE: Both fixed and scrolling divs are present on this page... Is this a bug in IE or Gecko? What does the CSS/HTML need to get Gecko to send the second...
3
1362
by: William Chang | last post by:
Is the different behavior between __repr__ and __str__ intentional when it comes to printing lists? Basically I want to print out a list with elements of my own class, but when I overwrite __str__, __str__ doesn't get called but if I overwrite __repr__, __repr__ will get called. Is this a bug? For example:
0
7915
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
8339
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...
1
7965
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
6617
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
5712
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
5392
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3838
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
3869
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2345
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.