473,804 Members | 3,725 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Landscape printing in vb.net ??

Hello,

I can't seem to get printing to landscape working. Here is some of the code
I've tried.

'---------------------------------------------------------------------------------
Dim myDocument As PrintDocument = PreparePrintDoc ument()
Dim myPaperSize As PaperSize
Dim iSizeCount As Integer
Dim dlgPrint As New PrintDialog

iSizeCount = 0

' Set to our selected printer
myDocument.Prin terSettings.Pri nterName = PrinterList.Tex t
' This hides the print progress dialog
myDocument.Prin tController = New
System.Drawing. Printing.Standa rdPrintControll er
' Print Landscape
myDocument.Prin terSettings.Def aultPageSetting s.Landscape.Equ als(True)

For Each myPaperSize In myDocument.Prin terSettings.Pap erSizes
If myDocument.Prin terSettings.Pap erSizes(iSizeCo unt).Kind =
PaperKind.Numbe r10Envelope Then
myDocument.Defa ultPageSettings .PaperSize =
myDocument.Prin terSettings.Pap erSizes(iSizeCo unt)
Exit For
End If
iSizeCount = iSizeCount + 1
Next

' Ok let's try landscape one more time...
myDocument.Defa ultPageSettings .Landscape.Equa ls(True)
MsgBox(myDocume nt.DefaultPageS ettings.Landsca pe.ToString)

'dlgPrint.Docum ent = myDocument

'MsgBox(dlgPrin t.PrinterSettin gs.DefaultPageS ettings.Landsca pe.ToString)
'dlgPrint.ShowD ialog()

'MsgBox(dlgPrin t.PrinterSettin gs.DefaultPageS ettings.Landsca pe.ToString)

dlgPrintPreview .Document = myDocument
dlgPrintPreview .ShowDialog()

'Print immediately.
'myDocument.Pri nt(
'---------------------------------------------------------------------------------

The only time I ever get landscape to be active is if I display the
PrintDialog and allow the user to select it. I can't get it to work in code
no matter how many places I set it.

Jul 21 '05 #1
3 10616
Setting of the landscape mode should read like:

myDocument.Defa ultPageSettings .Landscape = True

Try that!
"MarcJ" wrote:
Hello,

I can't seem to get printing to landscape working. Here is some of the code
I've tried.

'---------------------------------------------------------------------------------
Dim myDocument As PrintDocument = PreparePrintDoc ument()
Dim myPaperSize As PaperSize
Dim iSizeCount As Integer
Dim dlgPrint As New PrintDialog

iSizeCount = 0

' Set to our selected printer
myDocument.Prin terSettings.Pri nterName = PrinterList.Tex t
' This hides the print progress dialog
myDocument.Prin tController = New
System.Drawing. Printing.Standa rdPrintControll er
' Print Landscape
myDocument.Prin terSettings.Def aultPageSetting s.Landscape.Equ als(True)

For Each myPaperSize In myDocument.Prin terSettings.Pap erSizes
If myDocument.Prin terSettings.Pap erSizes(iSizeCo unt).Kind =
PaperKind.Numbe r10Envelope Then
myDocument.Defa ultPageSettings .PaperSize =
myDocument.Prin terSettings.Pap erSizes(iSizeCo unt)
Exit For
End If
iSizeCount = iSizeCount + 1
Next

' Ok let's try landscape one more time...
myDocument.Defa ultPageSettings .Landscape.Equa ls(True)
MsgBox(myDocume nt.DefaultPageS ettings.Landsca pe.ToString)

'dlgPrint.Docum ent = myDocument

'MsgBox(dlgPrin t.PrinterSettin gs.DefaultPageS ettings.Landsca pe.ToString)
'dlgPrint.ShowD ialog()

'MsgBox(dlgPrin t.PrinterSettin gs.DefaultPageS ettings.Landsca pe.ToString)

dlgPrintPreview .Document = myDocument
dlgPrintPreview .ShowDialog()

'Print immediately.
'myDocument.Pri nt()
'---------------------------------------------------------------------------------

The only time I ever get landscape to be active is if I display the
PrintDialog and allow the user to select it. I can't get it to work in code
no matter how many places I set it.

Jul 21 '05 #2
That works great! I had tried that initially but must have done something
wrong because it didn't work either.

But riddle me this. Why doesn't
myDocument.Prin terSettings.Def aultPageSetting s.Landscape.Equ als(True) work?
Wouldn't that be the .net way of doing things? If not, what exactly is that
supposed to do??

"Ben Solomon" wrote:
Setting of the landscape mode should read like:

myDocument.Defa ultPageSettings .Landscape = True


Jul 21 '05 #3
The statment

myDocument.Prin terSettings.Def aultPageSetting s.Landscape.Equ als(True)

might appear to set the landscape mode but I don't it really does at all.
The rest of the code sample is just fine I believe.

You might want to look up what the Equals method does.
It compiles but it doesn't set landscape mode... That's why
it only worked when the user selected it in the dialog. I believe
it checks if two expressions/objects are "equal"...


"MarcJ" wrote:
That works great! I had tried that initially but must have done something
wrong because it didn't work either.

But riddle me this. Why doesn't
myDocument.Prin terSettings.Def aultPageSetting s.Landscape.Equ als(True) work?
Wouldn't that be the .net way of doing things? If not, what exactly is that
supposed to do??

"Ben Solomon" wrote:
Setting of the landscape mode should read like:

myDocument.Defa ultPageSettings .Landscape = True

Jul 21 '05 #4

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

Similar topics

0
4578
by: gilga123 | last post by:
Trying & trying ad infinitum to print page in landscape mode from Java program - orientation is correct landscape but printing width will NOT go to landscape - always prints in portrait mode width - how to get width out to landscape?????? Graphics2D g2d = (Graphics2D)g; //Paper paper = new Paper(); Paper paper = pageFormat.getPaper(); //default portrait width=468 hi=648 x=72 y=72
0
1989
by: gilga123 | last post by:
Trying & trying ad infinitum to print page in landscape mode from Java program - orientation is correct landscape but printing width will NOT go to landscape - always prints in portrait mode width - how to get width out to landscape?????? Graphics2D g2d = (Graphics2D)g; //Paper paper = new Paper(); Paper paper = pageFormat.getPaper(); //default portrait width=468 hi=648 x=72 y=72
2
1320
by: Andrei Gavra via .NET 247 | last post by:
Hello. I have a problem when I choose landscape format forprinting. The page width and height are remaining the same asfor portrait format. In portrait format everything is ok and I'mposition my text in page based on page width, height and papermargins. I also want to say that the margins are different whenI choose landscape, but not the page size. I would appreciate very much any answer. -------------------------------- From: Andrei Gavra...
5
6875
by: cpopham | last post by:
I tried posting earlier and it never showed up.. I have a simple program to print a text file. I need to know how to change the page settings to landscape if it is not already in ladnscape mode. I do not want to use a dialog to do it and this appears the only way you can do it. I just need it to spit out the print in landscape orientation. Why is this so hard to do for something that should be easy.
3
349
by: MarcJ | last post by:
Hello, I can't seem to get printing to landscape working. Here is some of the code I've tried. '--------------------------------------------------------------------------------- Dim myDocument As PrintDocument = PreparePrintDocument() Dim myPaperSize As PaperSize Dim iSizeCount As Integer Dim dlgPrint As New PrintDialog
1
2018
by: lord.zoltar | last post by:
Hi, I'm trying to print a text report from an application. It works fine, except in landscape mode, which it seems to ignore. I have a function that handles the PrintPage even for the PrintDocument, and I even tried forcing it to print in landscape mode by adding: ev.PageSettings.Landscape = True (where ev is the parameter: ByVal ev As System.Drawing.Printing.PrintPageEventArgs) I also tried printDoc.DefaultPageSettings.Landscape = True...
6
3906
by: sheinaz | last post by:
Hi I am tryign to use this to print my table in landscape by default. i am new at the xsl and need some assistance. when i try to use the following i get the error: Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later. -------------------------------------------------------------------------------- Variable or parameter 'printingtype' cannot have both a select...
2
8468
by: FireStarter | last post by:
I am apparently unable to print landscape... maybe I'm doing something wrong here. I am adding a printDocument to a form. The form also has a textbox containing the text that I want to print and a button that triggers the printing. All properties of all objects are left intact for simplicity's sake. Code on the form:
6
5597
by: farukcse | last post by:
Dear sir, I have trouble with printing page with landscape. I am using java script to print the page. as well as I have set css file to print landscape but it is not working. I have used these line in css files, <style type="text/css"> <!-- @page { size: landscape; } -->
0
9706
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
9579
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
10575
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10330
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
10319
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,...
0
10076
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9144
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7616
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...
2
3816
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.