Showing posts with label print. Show all posts
Showing posts with label print. Show all posts

Saturday, March 31, 2012

Set browser in PrinPreview state on page load

Hi, Can i set the clients browser programmatically to PrintPreview state (File->Print Preview) when the client clicks the button print?

I don't want to use Crystal nor Report Viewer for some reasons

regards

Thanks in advance! More Power!

Hi,

As far as I know, it's impossible because you have to manipulate IE from client. If so, that means you have access to control windows process, then that's very dangerous. What's more, in fact, there are little APIs for us to control IE's function, especially such thing.

HTH


Hey Dfox,

Unfortunately asp.net works server side, so you can't change client side behaviour.

Keep up the good programming!

Thursday, March 22, 2012

set image url programmatically for image control

I have a print page that uses an image control to display an image that is saved in a directory that is dynamically created upon a session start. I have the path readily available for the image control...but I am failing to get the image to display in the image control...

what is the syntax to properly set the url for an image control programmatically in the code behind?

the control is named printImage

thanks in advance

Eric

printImage.src=


printImage.ImageUrl = "your URL";

simple as that.


I am not getting the .src in intellisense for the control - is there a namespace/directive that I am missing?


ekeefauver:

I am not getting the .src in intellisense for the control - is there a namespace/directive that I am missing?

Nope, it's just, that property is called "ImageUrl" and not "src".


doesn't seem to work for me...do I somehow need to refresh the control after setting the URL to the image?

the path to the image is: C:\Documents and Settings\dekeefau\My Documents\Visual Studio 2005\WebSites\CMAT_FINAL\sessions\sd_ewwewtjwy23b5vnrmxm1mffz\print\theimage.bmp

which is stored in a string variable


No, there is no need to refresh the control. Perhaps the path you are using is not valid? Try using Server.MapPath() function with the relative path to the image in question.

Example:

Image is in the /Images subfolder of the application and its name is MyImage.gif

Then the code to display this image would be:

printImage.ImageUrl = Server.MapPath("~/Images/MyImage.gif");

Tuesday, March 13, 2012

Set Print Margin of Web Page

A simple question: I'm trying to set the print margin of a web page automatically so that the user doesn't have to click on File -> PrintPreview -> Page Setup. Anybody know how to do this?
Thanks a lot!As far as I know, you can't do thisdirectly.

In the past I worked on a project where we wanted a report to automatically print "landscape". We had to install a DLL on the client to get this to work, since the printing attributes are set in the client-machine's registry.

From then to now, I don'tthink there has been any script or CSS properties exposed to allow this to be done.

HTH...

Chris

P.S. - one to to try would be to render your data in HTML tables, centered with fixed width's (the smaller the width, the larger the "margin"). Not sure how elegant of a solution that is, but it should work.
Does anyone know if some javascript might do the above? Still looking for a solution. Thanks!
Don't let the title fool you, ...here is a small excerpt from the article (below):


Users can easily change page margins, header and footer settings, and the default Internet Explorer printer through the Internet Explorer user interface. However, there are no methods under Internet Explorer or the WebBrowser control to change these settings programmatically.
HOWTO: Change Print Settings for Internet Explorer and WebBrowser Control Programmatically

Basically, changing printing options DOES involve changing registry settings on the client machine.

Here is one possible solution (it requires a third-party component though, like I described in my previous post):

HTML Printing

HTH...

Chris
Chris,
Thank you for the additional info. I will check it out.
I have been searching for something similar and, like you have not had too much luck. I did find a third party product that lets you have limited control of print setting for free, and more control if you pay...

link:
http://www.meadroid.com/scriptx/indexa.htm

What other options does a developer have for internet base printing? Has anyone had experiences with dynamic acrobat compilers? How about creating MS Snapshot reports dynamically from an asp page?

I can't believe there is nothing else out there.
The Mead control is the one I used in the past...like you said, limited control for free, more for the paid version.

Honestly though, I haven't found anything else that does the job any better (for true browser based printing). Seems if you truly want to control the print job, you need to use some custom control to generate the doc (like PDF of Crystal reports or something).

Chris
regarding using acrobat or crystal to generate a doc ...

do you mean generate a doc on the client-side or the server-side?
You would really most likely want to generate your reports server-side, where you have a better idea of system configuration/power (as well as control over more of the process). You can't count on a user having a fast machine ;-)

HTH...

Chris