Hello,
I'm trying to print more than one page using the PrintDocument object.
I set "e.HasMoreP ages = True" after completeing the first page in the
"PrintDocument1 _PrintPage" subroutine, and then "exit sub". When
"PrintDocument1 _PrintPage" is called for the second page, it skips to the
code to print the second page and then returns, setting "e.HasMoreP ages =
False".
Everything seems to work however, when I look at my printout the second page
overwrites the first page. How do I keep the second page from overwriting
the first page?
--
Islay 3 10586
> I'm trying to print more than one page using the PrintDocument object. I set "e.HasMoreP ages = True" after completeing the first page in the "PrintDocument1 _PrintPage" subroutine, and then "exit sub". When "PrintDocument1 _PrintPage" is called for the second page, it skips to the code to print the second page and then returns, setting "e.HasMoreP ages = False".
Everything seems to work however, when I look at my printout the second page overwrites the first page. How do I keep the second page from overwriting the first page?
I don't know why you are having a problem, but I do know that I ran into
something fishy regarding e.HasMorePages. The documentation claims that it
is an ordinary boolean property, but I had problems when I accessed it more
than once during a PrintPage event. So, I now compute a local boolean
HasMorePages for my own purposes, and I guarantee one and only one execution
per event of
e.HasMorePages = HasMorePages
and no other accesses to e.HasMorePages. If you use e.HasMorePages more
widely than this, you may have the same kind of problem I did. FYI FW 1.1,
Windows XP, all SPs current.
Thanks for responding so quickly. I tried your suggestion but it didn't help.
I also noticed something else strange. My print routine is called more than
once even if I set "e.HasMoreP ages = false" before I exit after creating the
first page. I only access e.HasMorePages once in the routine. The second
page is still overwriting the first page.
--
Islay
"AMercer" wrote: I'm trying to print more than one page using the PrintDocument object. I set "e.HasMoreP ages = True" after completeing the first page in the "PrintDocument1 _PrintPage" subroutine, and then "exit sub". When "PrintDocument1 _PrintPage" is called for the second page, it skips to the code to print the second page and then returns, setting "e.HasMoreP ages = False".
Everything seems to work however, when I look at my printout the second page overwrites the first page. How do I keep the second page from overwriting the first page?
I don't know why you are having a problem, but I do know that I ran into something fishy regarding e.HasMorePages. The documentation claims that it is an ordinary boolean property, but I had problems when I accessed it more than once during a PrintPage event. So, I now compute a local boolean HasMorePages for my own purposes, and I guarantee one and only one execution per event of e.HasMorePages = HasMorePages and no other accesses to e.HasMorePages. If you use e.HasMorePages more widely than this, you may have the same kind of problem I did. FYI FW 1.1, Windows XP, all SPs current.
I also found that VB.Net (VS.Net 2003, .Net Framework 1.1) HasMorePages is
not functioning as designed (or as documented). It appears that the
PrintPage event will cycle twice whether HasMorePages is set to "True" or
"False". In my case, when I had additional pages of information to print,
the page eject was not being sent to the printer until the second cycle.
This resulted in one page printing on-top of another page. After much hair
pulling, I determined that it was a bug and wrote code to work around this
bug.
Example:
' Dim a Class Variable such as:
Dim pageCycle as boolean = False
'in the PrintPage handler, include the following:
'************** *************** **********
'This code is here to handle a bug in the PrintPage event that will
not
'eject a page until the event cycles through two event cycles when the
'System.Drawing .Printing.Print PageEventArgs.H asMorePages property has
'been set to true.
If printcycle = True Then
printcycle = False
Exit Sub
End If
printcycle = True
'************** *************** **********
To work around the "two Cycle" PrintPage event when HasMorePages is "False",
include code in your loop to exit the loop if the string buffer is nothing.
Example:
Dim line As String = Nothing
' Calculate the number of lines per page.
linesPerPage = ev.MarginBounds .Height /
printFont.GetHe ight(ev.Graphic s)
'Now iterate over the stream and printing out each line
While count < linesPerPage
line = stringToPrint.R eadLine()
If line Is Nothing Then
Exit While
End If
yPos = topMargin + count * printFont.GetHe ight(ev.Graphic s)
ev.Graphics.Dra wString(line, printFont, Brushes.Black,
leftMargin, _
yPos, New StringFormat)
count += 1
End While
I hope Microsoft reads this disscussion forum because I do not know how to
report bug.
Hope this helps This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Randy |
last post by:
Hello,
I'm trying to print a dataGrid using PrintDocument control. My datagrid has
about 23 columns so it is fairly wide. When I use the PrintControl, it
prints only the part of the dataGrid that is visible on screen. I tried
using PrintPreviewDialog too but it still only shows just what is visible in
the dialog that houses the dataGrid. I want to get all the datagrid printed.
Maybe wrapping it would be the only way to print all of...
|
by: Neil Kimber |
last post by:
Hi,
I'm using the Cache object to persist some values between pages. I'm
setting the expiration for 2 minutes. I'm actually storing Bitmap streams in
the cache. In this way, one page can draw an image and store it and another
page can be responsible for streaming it to the browser.
This approach works well in that the Bitmap is correctly stored, the
other page can read the data and stream it correctly. Once streamed I do not
want to...
|
by: Krich |
last post by:
I am still new on printdocument object. I have a problem
try to print graphic object. I have one graphics object.
How to print it? I try to print it in PrintPage event
using this syntax
e.Graphics = grhObj
by grhObj is graphics object that already has string, line
or other image in it. It is very difficult to recreate
this object in PrintPage event.
|
by: Mika M |
last post by:
Hi all!
I have made an application for printing simple barcode labels using
PrintDocument object, and it's working fine.
Barcode printer that I use is attached to the computer, and this
computer has drivers installed for this printer, and this printer is
shared for the network.
Question 1:
|
by: Dominator.Legend |
last post by:
Hallow every one, i have a problem using .net user control with the
<OBJECT> tag,
I made a normal user control in C#, then i use the regasm to register
it, also i use the option regfile to generate the *.reg file and then
merge it,
After merging it i open the reg file, which was as follow.
REGEDIT4
| |
by: girishmat |
last post by:
how to embed or open microsoft word file in a page using php script
|
by: pamela fluente |
last post by:
hi,
What is the cleanest and effective way to use the PrintDocument object
to print
directly to a pdf file "myfile.pdf" (with no prompt to the user: just
print to file and make pdf) ?
Does anyone have a simple code snippet? Either VB or C# will be
perfect.
|
by: thirunavukarasukm |
last post by:
Hai....
To print Html page using PrintDialog and Print Document
i am created one windows appication..
the windows application have many pages
in my booking page i have two buttons one btnprint,btnclose
|
by: fastvarun |
last post by:
Can anybody help me how to remove url while print out of a page using javascript window.print() plz help me...........................
|
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...
|
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...
| |
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,...
|
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...
|
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...
|
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...
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |