Hi,
I try to use my own PreviewDialog with a PrinPreviewCont rol, to preview a
document of type MyPrintDocument , and I want to implement the PrintRange
functionnality (print some pages between 2 values).
I noticed that we can specified the PrintRange, FromPage and ToPage
properties of the PrintDocument.P rintSettings object, but, as said in MSDN :
"The FromPage, ToPage and PrintRange can also be set programmaticall y,
though the PrintDocument.P rintPage implementation is the same."
So I tried to do that in my class, inherited from PrintDocument, but I
failed ! In the PrintPage EventHandler, I made a treatment that paint
graphics for the specified pages, but I have blank pages ; I also tried to
specified a virtual printer for the page to ignore, in the QueryPageSettin gs
EventHandler, but it throws an exception...
So, please, how to proceed ?
Thanks in advance. 2 6614
Hi bp,
Can you post some code?
So I tried to do that in my class, inherited from PrintDocument, but I
failed
You don't need to derive from PrintDocument to print a range of pages. If you are deriving a class from PrintDocument for different
reasons then you should treat your document just as you would a PrintDocument.
I also tried to
specified a virtual printer for the page to ignore, in the QueryPageSettin gs
EventHandler, but it throws an exception...
You must post some code for anyone to help you with this problem.
--
Dave Sexton
"bp" <bp@discussions .microsoft.comw rote in message news:76******** *************** ***********@mic rosoft.com...
Hi,
I try to use my own PreviewDialog with a PrinPreviewCont rol, to preview a
document of type MyPrintDocument , and I want to implement the PrintRange
functionnality (print some pages between 2 values).
I noticed that we can specified the PrintRange, FromPage and ToPage
properties of the PrintDocument.P rintSettings object, but, as said in MSDN :
"The FromPage, ToPage and PrintRange can also be set programmaticall y,
though the PrintDocument.P rintPage implementation is the same."
So I tried to do that in my class, inherited from PrintDocument, but I
failed ! In the PrintPage EventHandler, I made a treatment that paint
graphics for the specified pages, but I have blank pages ; I also tried to
specified a virtual printer for the page to ignore, in the QueryPageSettin gs
EventHandler, but it throws an exception...
So, please, how to proceed ?
Thanks in advance.
bp wrote:
Hi,
I try to use my own PreviewDialog with a PrinPreviewCont rol, to preview a
document of type MyPrintDocument , and I want to implement the PrintRange
functionnality (print some pages between 2 values).
I noticed that we can specified the PrintRange, FromPage and ToPage
properties of the PrintDocument.P rintSettings object, but, as said in MSDN :
"The FromPage, ToPage and PrintRange can also be set programmaticall y,
though the PrintDocument.P rintPage implementation is the same."
So I tried to do that in my class, inherited from PrintDocument, but I
failed ! In the PrintPage EventHandler, I made a treatment that paint
graphics for the specified pages, but I have blank pages ; I also tried to
specified a virtual printer for the page to ignore, in the QueryPageSettin gs
EventHandler, but it throws an exception...
So, please, how to proceed ?
I made the same mistake when I started working with PrintDocument: I
thought that there was some magic behind the scenes that would take
care of the "Print page n" and "Print pages from n to m" functionality.
There isn't: you have to do it all yourself.
In your case, what that means is that the first time your PrintPage
event handler is called, you have to check the FromPage setting in the
page settings, and print _that_ page. It's up to _you_ to skip over the
first n - 1 pages on the first call and go directly to page n and print
that.
It's also up to you (as you've probably already guessed) to signal
"nothing more to print" when you've finished rendering page m.
The underlying PrintDocument doesn't understand page numbers, and
(wisely) doesn't assume that pages are simply numbered from 1. (They
may not be: consider a document with table of contents on pages i, ii,
iii, and iv, then the content is numbered 1, 2, 3, .... In that case,
"print 2 to 4" means print (by count) pages 6 to 8.) All that the
underlying framework does is pass you the numbers and let you work out
what to do.
So, on the very first call to PrintPage, you'll be handed a blank
graphics surface and the number FromPage 3, for example. It's up to you
to go through the motions of rendering pages 1 and 2 (without really
doing it) and then draw page 3 on the graphics surface and return. Or,
perhaps, you have some clever trick for knowing what belongs on page 3
without having to ghost-draw pages 1 and 2, in which case just go for
it.
Hope this helps. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jeffry van de Vuurst |
last post by:
Hi,
I have a PrintDocument that I preview in a PrintPreviewControl. Now I
run the app on a pc without any printers installed and when I want to
preview the PrintDocument I get an InvalidPrinterException exception
saying "No Printers Installed".
Is this a bug or behavior by design? Is there anything I can do about
this or should I just...
|
by: Palli Olafs |
last post by:
Hi
Is it possible to save the PrintDocument as file without using a printer?
|
by: Frank Rizzo |
last post by:
Hello,
I have an OCX control on my WinForm (don't ask, i have to use it) and it
generally works well. One of the methods of the OCX prints to an hDC
(device context handle for history buffs). Seeing how everything in
..NET prints to a PrintDocument object, I was wondering how I can
retrieve the hDC of the PrintDocument? Or am I looking...
|
by: Nigel |
last post by:
The Visual Basic .NET Step by Step book has the following code and text:
Imports System.Drawing.Printing
Private Sub PrintText(ByVal sender As Object, ByVal ev As
PrintPageEventArgs)
ev.Graphics.DrawString(TextBox1.Text, New Font("Arial", 11,
FontStyle.Regular), Brushes.Black, 120, 120)
ev.HasMorePages = False
End Sub
|
by: active |
last post by:
Dim mPD As PrintDocument
Dim mPrinternameSaved As PrintDocument
Public WriteOnly Property PrintDocument() As PrintDocument
Set(ByVal value As PrintDocument)
mPD = value
mPrinternameSaved = mPD
I wanted to do something like the above except that I wanted
mPrinternameSaved to be an additional set of data identical to that stored
| |
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: Coen |
last post by:
Hi, can anyone help me with the printrange functionality?
The problem is: whatever I try allways all the pages are print (directly to
the printer or via a preview control).
The VS-Build in help suggests checking the Printdocument.PrintPage event
during printing. And indeed I can check if the current page in the Printpage
event should be...
|
by: Steve |
last post by:
I'm trying real hard to set the printer resolution for a PrintDocument. It
appears that the printer is already set to 300 x 300 dpi, which is JUST what
I want.
But the Margins and PrintableArea properties of the PageSettings in the
Print handler are reporting values that indicate 100 dpi, for example it
reports PaperSize as 850, 1100 (8.5" x...
|
by: kig25 |
last post by:
Hello,
When using the VB.NET PrintDocument class, I seem to be encountering an
issue where the sub pd_PrintPage handles PrintDocument.PrintPage (upon
continuing if HasMorePages = true) will paint the next page on top of
the original page. In a sample data case where the source is long
enough to fill three pages, I end up with four calls to...
|
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...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
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...
|
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...
| |