CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> Tips & Solutions

 Want Even More Control Over Printing? Headers and Footers and Margins, Oh My!

Print topic Send  topic

Author Message
JimmyCrackedCorn

Posts: 583
Posted: 06/11/2007, 1:23 AM

OK. So I'm still in report-writing mode! After I figured out how to get the page breaks working http://forums.yessoftware.com/posts.php?post_id=88156 I found I was stuck with the user's browser page settings for printing. Or was I? :-)

Now before I even start I want to make it clear that this technique may not always be the best way to go. There are lots of folks out there who will freak out at the very thought of you taking control of the user's web browser settings. They will tell you this is the domain of the user and you have no right messing with it. And sometimes they are correct. But I'll leave it to you to figure out when to use this and when not to! "With great power comes great responsibility" (feeling tingley yet?)

Oh, and this only works on Internet Explorer so don't count on it for other browsers.

Finally, I am in no way associated with MeadCo nor do I know much of anything about them so use this at your own risk! With that out of the way...

So, my situation is this,

- internal web application for private organization
- all of the users have IE7 (or can be required to use it)
- they expect the web application to work as much like a desktop app as possible

Many of the reports we are providing need to be printed in landscape format and they need custom headers, footers and margin settings. I searched high and low for some way to do this using CSS, Javascript, or whatever. Just when I was ready to give up I found an activeX component that does the trick!

It is called ScriptX and it is provided by a UK company called MeadCo. It is available in an advanced version and a basic version. The basic version is FREE and includes all of the functionality I needed! http://www.meadroid.com/scriptx/freedep.asp

It works like this...

- download the component's CAB file from here http://www.meadroid.com/scriptx/aRcHive/ScriptX.zip

- upload the smsx.cab file to your web server to the same folder as the print page (or in a folder of your choosing)

- add the following code below your body tag
<object id=factory style="display:none"
classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"
codebase="smsx.cab#Version=6,3,435,20">
</object>

- add the following code to your Client side OnLoad event
if (!factory.object) {
return
} else {
factory.printing.header = "Header Goes Here"
factory.printing.footer = "Footer Goes Here"
factory.printing.leftMargin = .75
factory.printing.rightMargin = .75
factory.printing.topMargin = 1.5
factory.printing.bottomMargin = 1
factory.printing.portrait = false
}

That's it! Change the OnLoad code to suit your needs for header, footer, margins and page orientation.

Now when an IE (4,5,5.5,6,7) user goes to your print page they will get an alert asking if they wish to install the plugin. If they say yes then headers, footers, margins and page orientation are set automatically when they print the page. And, afterwords all their previous default settings are restored.


It was just what I needed! Your mileage may vary. :-D
_________________
Walter Kempees...you are dearly missed.
View profile  Send private message
marcwolf


Posts: 361
Posted: 07/15/2007, 10:49 PM

There is another possibility

User word to create a templeand save that as a MHT file. tne you can edit the internals of the MHT files and save it as DOC. When you import it back into Word you will find that you document spans pages very nicely.

Hope this helps

Dave
_________________
' Coding Coding Coding
Keep Those Keyboards Coding.
Raw Code!!!!!!!
View profile  Send private message
marcwolf


Posts: 361
Posted: 07/15/2007, 10:49 PM

There is another possibility

User word to create a templeand save that as a MHT file. tne you can edit the internals of the MHT files and save it as DOC. When you import it back into Word you will find that you document spans pages very nicely.

Hope this helps

Dave
_________________
' Coding Coding Coding
Keep Those Keyboards Coding.
Raw Code!!!!!!!
View profile  Send private message
JimmyCrackedCorn

Posts: 583
Posted: 07/16/2007, 12:35 AM

interesting idea but what I needed was direct printing from the browser without using external programs like Word or Excel.

the solution I describe above essentially just adds the browser printing control that a desktop application would have (or at least near enough to satisfy our needs) to any or all pages within your application.

As an aside, I also hate the way Word puts so much junk into pages it creates. To print "This is a test" Dreamweaver creates 10 lines of HTML while Word creates over 50!
_________________
Walter Kempees...you are dearly missed.
View profile  Send private message
Damian Hupfeld
Posted: 07/17/2007, 3:13 AM

And notepad creates 1....

"JimmyCrackedCorn" <JimmyCrackedCorn@forum.codecharge> wrote in message
news:25469b1fbd785fb@news.codecharge.com...
> interesting idea but what I needed was direct printing from the browser
> without
> using external programs like Word or Excel.
>
> the solution I describe above essentially just adds the browser printing
> control that a desktop application would have (or at least near enough to
> satisfy our needs) to any or all pages within your application.
>
> As an aside, I also hate the way Word puts so much junk into pages it
> creates.
> To print "This is a test" Dreamweaver creates 10 lines of HTML while Word
> creates over 50!
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.yessoftware.com/
>

JimmyCrackedCorn

Posts: 583
Posted: 07/17/2007, 11:46 AM

Quote Damian Hupfeld:
And notepad creates 1....
You missed my point. In this simple example Word inserts 40 lines of its own unnecessary markup. Dreamweaver does not. Even in your imagined 1-line Notepad file you'd need approximately 10 separate HTML statements which most people would choose to place on separate lines!
_________________
Walter Kempees...you are dearly missed.
View profile  Send private message
Damian Hupfeld
Posted: 07/17/2007, 7:29 PM

Actually you can just create a file like ->
index.html----
This is a test
----
And it will display correctly.

Word is very inefficient but it is also very exact. It writes so many excess
lines of code because it wants to display the text exactly as you have
written it. Dreamweaver and most other editors will not specify fonts if you
dont, wont specify margins if you dont, etc but Word does all that which
does create bloated HTML.
I dont know anyone that would use WORD as a HTML editor but it is a darm
good word processor....

Damian


"JimmyCrackedCorn" <JimmyCrackedCorn@forum.codecharge> wrote in message
news:25469d0ea25bf18@news.codecharge.com...
>
Quote Damian Hupfeld:
> And notepad creates 1....
>
> You missed my point. In this simple example Word inserts 40 lines of its
> own
> unnecessary markup. Dreamweaver does not. Even in your imagined 1-line
> Notepad
> file you'd need approximately 10 separate HTML statements which most
> people
> would choose to place on separate lines!
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

JimmyCrackedCorn

Posts: 583
Posted: 07/17/2007, 7:59 PM

I agree with you about Word...I've used it for years as a word processor and I wouldn't typically use it to produce HTML! But it is interesting to me that Word can be used to import/export; I'm sure I'll find a use for that someday in my web apps (just like the export to Excel feature that CCS provides).

Just to get back on point though, my tip in the first post of this thread is about how to control the page orientation, margins, headers and footers when printing from Internet Explorer! No Word import/export steps required! :)
_________________
Walter Kempees...you are dearly missed.
View profile  Send private message
Damian Hupfeld
Posted: 07/17/2007, 8:47 PM

And it is a very nice tip too. I have saved it for future reference.

"JimmyCrackedCorn" <JimmyCrackedCorn@forum.codecharge> wrote in message
news:25469d822d067e8@news.codecharge.com...
>I agree with you about Word...I've used it for years as a word processor
>and I
> wouldn't typically use it to produce HTML! But it is interesting to me
> that Word
> can be used to import/export; I'm sure I'll find a use for that someday in
> my
> web apps (just like the export to Excel feature that CCS provides).
>
> Just to get back on point though, my tip in the first post of this thread
> is
> about how to control the margins, headers and footers when printing from
> Internet Explorer! No Word required! :)
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

datadoit.com
Posted: 07/18/2007, 7:58 AM

Why not Firefox?
JimmyCrackedCorn

Posts: 583
Posted: 07/18/2007, 12:23 PM

Quote datadoit.com:
Why not Firefox?

It requires ActiveX support and according to Mozilla.org (regarding Firefox) "There is no support for VBScript and ActiveX".

So we do NOT use this on public sites but it has been a godsend for some internal and intranet projects we are working on.
_________________
Walter Kempees...you are dearly missed.
View profile  Send private message
Benjamin Krajmalnik
Posted: 07/18/2007, 1:16 PM

And you think DreamWeaver does not bloat html?
Have I got news for you :)
If you want to compare, compare like products.
I will take Microsoft Expression Web over Dreamweaver any time.

Benjamin Krajmalnik
Posted: 07/18/2007, 1:22 PM

Have you tried to see what happens with Firefox?
Maybe it just ignores it.
If not, you can encapsulate the code so it will only run in IE.
It is simple:

In the html template
<!--[if IE ]>
your code goes here
<![endif]-->
<![if !ie ]>
Alternate code if you want an alternate presentation
<![endif]>

JimmyCrackedCorn

Posts: 583
Posted: 07/18/2007, 2:02 PM

Quote Benjamin Krajmalnik:
And you think DreamWeaver does not bloat html?
Have I got news for you :)
If you want to compare, compare like products.
I will take Microsoft Expression Web over Dreamweaver any time.



oh please. can we start a new thread for our religious/tools wars? this was supposed to be a tip on how to solve a problem. sheeesh!
_________________
Walter Kempees...you are dearly missed.
View profile  Send private message
JimmyCrackedCorn

Posts: 583
Posted: 07/18/2007, 2:05 PM

Quote Benjamin Krajmalnik:
Have you tried to see what happens with Firefox?
Maybe it just ignores it.
If not, you can encapsulate the code so it will only run in IE.
It is simple:

In the html template
<!--[if IE ]>
your code goes here
<![endif]-->
<![if !ie ]>
Alternate code if you want an alternate presentation
<![endif]>



tried it in Firefox. it does not work; just ignores it. no ActiveX support there.
_________________
Walter Kempees...you are dearly missed.
View profile  Send private message
Benjamin Krajmalnik
Posted: 07/19/2007, 12:04 AM

Apologize if I offended you.
You were comparing code bloat of a word processor to that of an html layout
tool.
While I prefer Expression Web over dreamweaver, I actually prefer notepad
(or notepad++) over both :)
The reason I mentioned ExpressionWeb is because from what I have seen so
far, its rendering engine is the most standards compliant I have yet to see.
I believe it is better than DreamWeaver's wysiwig.
Now, if MS would only use that rendering engine instead of the crappy IE7
one, I would be a very happy camper. IE 8? <vbg>

Your tip on how to solve the problem is great. Have you checked it with
graphics images or flash components? Does it paginate properly in those
cases?
Due to the lack of absolute control, I am generating server side PDF's using
fpdf. For graphs, I am using jpGraph.
Using CURL, we can generate the graphs sequentially via a graph generation
script and it works great.

JimmyCrackedCorn

Posts: 583
Posted: 07/22/2007, 11:43 PM

Quote Benjamin Krajmalnik:
Apologize if I offended you.
You were comparing code bloat of a word processor to that of an html layout
tool.
While I prefer Expression Web over dreamweaver, I actually prefer notepad
(or notepad++) over both :)
The reason I mentioned ExpressionWeb is because from what I have seen so
far, its rendering engine is the most standards compliant I have yet to see.
I believe it is better than DreamWeaver's wysiwig.
Now, if MS would only use that rendering engine instead of the crappy IE7
one, I would be a very happy camper. IE 8? <vbg>

Your tip on how to solve the problem is great. Have you checked it with
graphics images or flash components? Does it paginate properly in those
cases?
Due to the lack of absolute control, I am generating server side PDF's using
fpdf. For graphs, I am using jpGraph.
Using CURL, we can generate the graphs sequentially via a graph generation
script and it works great.




no problem. I just know how quickly these discussions jump the track!

I have been curious about Microsoft's new web tools but generally my experience with MS has been,

-version 1...move along, nothing to see here
-version 2...good idea, not there yet
-version 3...competitors need to prepare their exit strategy!

of course, sometimes they never get it right (FrontPage) but usually by version 3, if they are really interested, they own the niche and their product is pretty good.

the new web products may be the exception but they'll be at least to version 2 before I give them a serious look! :)
_________________
Walter Kempees...you are dearly missed.
View profile  Send private message
aceqbaceq

Posts: 1
Posted: 04/09/2008, 8:57 AM

i succesfully solved this problem for myself.
i have printer named 3120.
go about:config
enter keyword "edge"
then i change this values so :

print.printer_CUPS/3120.print_edge_bottom=60

print.printer_CUPS/3120.print_edge_left=40

print.printer_CUPS/3120.print_edge_right=40

print.printer_CUPS/3120.print_edge_top=40


by the way sucha variables as

print.print_edge_bottom
print.print_edge_left
print.print_edge_right
print.print_edge_top

DOES NOTHING.

then i go to file-page options-fileds and headers-

top=0.8 inch
bottom=0.8 inch
left=0.5 inch
right=0.5 inch

and my paper size is set as "letter (8,5x11 inch)", though i print on A4. but unfortunately firefox do not print properly on paper A4 when it is on A4. that is paradox for me.

that is all. :)

and i don not understand. why so long ( now we have firefox 2.0.0.13) firefox have such basic stupid mistake.

by the way if firefox have
top=0.9 or top=0.7 then it printed page only about 25% of its content.

and that is not all.

if top position of page intersect position of header, then top part of page destroy header. and in this case header did not print.
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright 2003-2004 by UltraApps.com  and YesSoftware, Inc.