Re: Print preview in php [message #174251 is a reply to message #174230] |
Sat, 28 May 2011 13:06 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma:
|
Senior Member |
|
|
On 5/27/2011 10:46 PM, Robert Heller wrote:
> 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>
>
Which has nothing to do with PHP - this is javascript.
> 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:
>
Which still won't create a print preview, as he wants.
> <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.
>
>>
>
And still nothing to do with PHP.
Using javascript to serve a different page not only has nothing to do
with PHP, it doesn't answer the user's question.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|