Solved

browser print dialog i need the return values ie page range selected

Posted on 2011-02-11
13
420 Views
Last Modified: 2012-05-11
I have a simple asp.net page with some text and images, several pages long. When the user clicks the print button (window.print()) or some similar script for printing the standard system print dialog box appears, they choose the printer name , and page range (ie pages 3-5)

how can my code get back the page range they chose to print to their printer?
compatible first with IE 8 / Windows.

thanks
josh
0
Comment
Question by:joshmiller
  • 7
  • 4
  • 2
13 Comments
 
LVL 7

Accepted Solution

by:
dxdinh earned 500 total points
ID: 34875502
You can not do that - that's security violation - unless you write an activeX control then you can access the information from the printer dialog ....
0
 

Author Comment

by:joshmiller
ID: 34876040
I thought so, what about accessing Adobe Flash player action scripts to use the print dialog in there? would that have possibilities to get information back?
0
 
LVL 7

Expert Comment

by:dxdinh
ID: 34876172
I guess you can do that by ask the user the page range first and build frame to include with those pages ....
0
 

Author Comment

by:joshmiller
ID: 34876219
my current solution does that, but then the user still has to see a print dialog after the needed pages are shown, in order to choose a possible printer name, and that second dialog still has a page-range selection, so two prompts to obtain information which is really in one prompt, that is what im trying to figure a way around
0
 
LVL 7

Expert Comment

by:dxdinh
ID: 34876316
I guess - it's a little disadvantage - but either you have to build activeX control as I mention, or java applet control
0
 
LVL 29

Expert Comment

by:Badotz
ID: 34878025
Why do you need to know this?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:joshmiller
ID: 34879449
in this situation the user pays a fee per page that they choose to print, they often only need to print a certain range.
0
 
LVL 29

Expert Comment

by:Badotz
ID: 34879562
hmmm...short of you printing the pages, say, to a file, and then serving them to the client, I'm not sure there is a foolproof way to do this.
0
 

Author Comment

by:joshmiller
ID: 34883351
sounds like activex is going have to be it.  thanks
0
 
LVL 7

Expert Comment

by:dxdinh
ID: 34885668
I would consider java applet since you can reach more browsers vs activeX
0
 

Author Comment

by:joshmiller
ID: 34945387
turns out, you can figure out what the user selected for page range, by how many times the _PrintPage Event fires.  So even if you set e.HasMorePages = True on the first time the event fires, it will not come around again if they user only chose to print the first page.  This is vastly different than standard .NET framework printing dialogs which will print 100 pages even if the user only chose 1 page because the _printpage event can cycle as much as the code allows for.  The standard framework dialog and printDocument features allow you to see what page range the user wants and then completely ignore it.  In Silverlight your _PrintPage event will fire however many times the user chose pages for and the code cannot interfere.
0
 

Author Comment

by:joshmiller
ID: 34945508
that last post was quite confusing, here is an example...

user clicks print
user choose 1-2 in silverlight print dialog
_PrintPage event will fire a maximum of two times even if e.HasMorePages = True after second page
_PrintPage event will fire exactly once e.HasMorePages = False on the first page event by code
so code can shorten the pages to less than what the user asks for, but it cannot go extra pages beyond what the user asks for.  sometimes e.HasMorePages affects printing, sometimes it is ignored, depending on how it relates to the user range.  
This is true for System.Windows.Printing
but different than System.Drawing.Printing
0
 

Author Comment

by:joshmiller
ID: 34946215
I found EndPrint to be usefull for the PrintedPageCount property:

if you have a 7 page document
user prints, and selected page range 6-7
YourPrintDocObject.PrintPage event will fire 7 times
only 2 pages will come out of the users printer
during EndPrint event YourPrintDocObject.PrintedPageCount = 2

how do you know if they chose 5-6 or 6-7? I don’t know the answer to that.

I’m still experimenting with this, please let me know if this is inaccurate.

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how add a full-size background image to a webpage using CSS3. Create a new HTML document with an internal stylesheet.: In CSS, define the html element to have a background image. Use a high resolution image.: In t…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

937 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now