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

0 comments:

Post a Comment