Re: Print preview in php [message #174230 is a reply to message #174228] |
Sat, 28 May 2011 02:46 |
Robert Heller
Messages: 60 Registered: December 2010
Karma:
|
Member |
|
|
At Fri, 27 May 2011 21:24:36 -0400 Jerry Stuckle <jstucklex(at)attglobal(dot)net> wrote:
>
> On 5/27/2011 5:48 PM, Co wrote:
>> Hi All,
>>
>> I was wondering if someone can help me with a code to preview part of
>> a php page
>> and eventually print it.
>> I don't want to print all of the page with images etc, just the data
>> within a certain area of the page.
>>
>> Anyone know if this is possible?
>>
>> Regards
>> Marco
>
> From a web page? Not possible. PHP runs on the server and has nothing
> to do with page layout (that's HTML/CSS). Print preview runs on the
> client and is dependent on client settings, of which PHP has no knowledge.
OTOH, if the web page in question is being served by the PHP code, all
you need to do is create a link, something like this:
<a href="/ServeThePrinterFriendlyPage.php?..." target="_blank"
onclick=" window.open(this.href,'win2','status=no,toolbar=no,scrollbars=yes,titlebar= no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no ');
return false;" rel="nofollow">Print This</a>
And then the ServeThePrinterFriendlyPage.php file would then serve the
page without the special effects that make sense on the screen (eg
images, flash, ads, etc.) but don't on the printer. The
target="_blank" attribute handles the case where JavaScript is not
available and the onclick attribute handles the case where JavaScript
is available. On the page served, you need to include a link like:
<a href="#" onclick="window.print();return false;">Print</a> and
optionally one like <a href="#" onclick="window.close();return
false;">Close</a>. The first is a button to print the page and the
second is a button to close the popup window.
>
--
Robert Heller -- 978-544-6933 / heller(at)deepsoft(dot)com
Deepwoods Software -- http://www.deepsoft.com/
() ascii ribbon campaign -- against html e-mail
/\ www.asciiribbon.org -- against proprietary attachments
|
|
|