473,659 Members | 2,920 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Printer Friendly page

Hi all ,

I have php page which the data in the page are extracted from MYSQL
database.
The data are retrieved when user click submit button .
In the php page , there is a print button for user to print the php
page.
Presently, i am using javascript window.print() which not an elegant
option.

I tried to use CSS for printer friendly in php page , however i did not
know how to start.
Anyone have any idea how to , please share it with me .

Thanks
- weetat

Aug 7 '06 #1
5 2212
we********@gmai l.com wrote:
Hi all ,

I have php page which the data in the page are extracted from MYSQL
database.
The data are retrieved when user click submit button .
In the php page , there is a print button for user to print the php
page.
Presently, i am using javascript window.print() which not an elegant
option.

I tried to use CSS for printer friendly in php page , however i did not
know how to start.
Anyone have any idea how to , please share it with me .

Thanks
- weetat
Hi Weetat,

I always solve this the simple way:
1) Make a button: "Printer friendly page"
2) If somebody hits that button, simply create a popupwindow in which you
retrieve the data again, and display it with little/no colors, just black
and white.
From there you can call window.print() safely.

Alternatively, you can make a stylesheet for the printer, and tell the
browser to use that (without the popupwindow). That should work too, but I
prefer the first option because the user can see what will be printed
beforehand excactly.

just my 2 cent.

Regards,
Erwin Moller
Aug 7 '06 #2
On 2006-08-07, Erwin Moller wrote:
Alternatively, you can make a stylesheet for the printer, and tell the
browser to use that (without the popupwindow). That should work too,
but I prefer the first option because the user can see what will be
printed beforehand excactly.
Doesn't most browsers nowadays have a print preview function that takes
the CSS into consideration? I'm pretty certain that Firefox did last
time I checked.

--
|\_/| ,(Meow) Jesper H. <xy***********@ xyborx.dk>
(^.^)
`^' Sanity is an illusion
Aug 8 '06 #3
Jesper H. wrote:
On 2006-08-07, Erwin Moller wrote:
Alternatively, you can make a stylesheet for the printer, and tell the
browser to use that (without the popupwindow). That should work too,
but I prefer the first option because the user can see what will be
printed beforehand excactly.

Doesn't most browsers nowadays have a print preview function that takes
the CSS into consideration? I'm pretty certain that Firefox did last
time I checked.

--
|\_/| ,(Meow) Jesper H. <xy***********@ xyborx.dk>
(^.^)
`^' Sanity is an illusion
Yeah, and I don't know how many times I've seen the previews of pages
that wouldn't print right :-)

I have to agree with Erwin. It's far easier to create a separate,
printable version of a page than having to come up with a stylesheet
that works for both screen and printer. And sometimes your printable
version will be structurally different from the screen version. For
on-screen viewing you might break a long article into multiple pages.
For printing you would want to output the whole thing.

Aug 8 '06 #4
Why don't you just use a @media print{} section in your CSS file?

Best regards

we********@gmai l.com wrote:
Hi all ,

I have php page which the data in the page are extracted from MYSQL
database.
The data are retrieved when user click submit button .
In the php page , there is a print button for user to print the php
page.
Presently, i am using javascript window.print() which not an elegant
option.

I tried to use CSS for printer friendly in php page , however i did not
know how to start.
Anyone have any idea how to , please share it with me .

Thanks
- weetat
Aug 8 '06 #5
Erwin Moller wrote:
<snip>
I always solve this the simple way:
1) Make a button: "Printer friendly page"
2) If somebody hits that button, simply create a popupwindow in which you
retrieve the data again, and display it with little/no colors, just black
and white.
From there you can call window.print() safely.

Alternatively, you can make a stylesheet for the printer, and tell the
browser to use that (without the popupwindow). That should work too, but I
prefer the first option because the user can see what will be printed
beforehand excactly.
<snip>

FWIW, my way:
1. print.css set to print media and other style and alternate styles
for screen
2. <a href="currentli nk+?print=1" rel="nofollow"
class="print-link">Printer friendly page"</a>
* rel="nofollow" so that the crawlers won't crawl it (avoid multiple
crawl of same page)
3. Add popup window for the link by hooking "print-link" class using
Behaviour.js (now using modified better version of it and need to
document it)
4. The top global file sees if $_GET['print'] is set, if so, when it
renders styleseet related links, it sets print.css to screen and trims
other styles.

Advantages: Not much coding; easy to plug it to existing pages.

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Aug 13 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1432
by: ST | last post by:
Hi, I'm implementing a printer friendly feature for all the pages on a web site. I'm separating the header, content, and footer into separate ascx files, which are contained in the main file. In the mail file I have a link button which, supposedly, when clicked on, passes the current content page's url and page title to the printer friendly page, which has a placeholder for the content page. I could do this with session variables, but...
1
1578
by: John Klucker | last post by:
Can anyone tell what easiest way to implement 'Printer Friendly' functionality to my .aspx page. Are there any controls available or is there something in the framework? Thanks in Advance!! John
2
1398
by: Ray | last post by:
ASP.NET Newbie ? I have a populated datagrid on my .aspx page, I want to open a second window without all the extra fluff (nav bar, menus, etc) and display a printer friendly version of my datagrid. I'm looking for ideas on how to pass the data to the second page without making a second request back to the database? Passing the data as a dialog argument in a window.ShowModelDialog is really not an option because of the possible data...
2
1361
by: Ron | last post by:
Hello, I am working on a registration application for my companies intranet. The intranet is ASP classic based as of now. Unfortunately I only know ASP.NET. But that was all okay until I decided I wanted to have a 'printer friendly' class roster. In making it printer friendly, I would want to drop the intranet's standard Navigation and title bars. They allow me to do this by refering to a .asp file as .nfa from the link. However this...
2
1275
by: Sandy | last post by:
Hello - I tried to google this, but got back every page on the whole entire web that has printer friendly versions . . . I have a panel containing text from a repeater that also contains text in a multi-line textbox. How do I create a printer friendly version for this? Any help you can give me will be greatly appreciated -- or if you know exactly where to go on the web to obtain this info, please include the link.
1
1308
by: dinoo | last post by:
Can any one help me out? I am looking out to implement printer friendly version of a web page. I do not want the header and footer show up in the print and I do not want to use frames (it is a client decision). I want to avoid writing the code again to make the printer friendly. Is there any way which would allow me to make the developer friendly page without lot of additional duplicate work. Thanks in advance.
2
1903
by: weetat.yeo | last post by:
Hi all , I have a print button in PHP page which using javascript window.print() to print web page. However , when user click "print" , the print preview display that the page cut-off and alignment is out. Read on regarding the matter , and found that is not the issue of PHP . Some users recommend to me to use CSS and HTML to create printer friendly page.
1
1688
by: tbanov | last post by:
Hi, I'm looking to create my own version of a printer-friendly page. Any resources I can find on this subject are extremely specific about what they consider "printer-friendly", and they don't address my issue. It seems to be browser specific, but I want to get rid of whatever extra is printed in the top and bottom margins. Printed from IE, the top contains the page title and page information, while the bottom contains the URL and date....
15
2148
by: Prisoner at War | last post by:
Okay, I'd like to create a print-friendly website, so I've been reading up on how to create print-friendly pages (without duplicating my site, of course, by having separate versions of each page).... Apparently one can use JavaScript or CSS for this.... Using CSS, it seems that the "trick" is to use * media="print" * in the <linktag.... So if I have a hyperlink to a print-friendly page...um, well, what's
1
8528
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7356
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6179
isladogs
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5649
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2752
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1976
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1737
bsmnconsultancy
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.