FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Print preview in php
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Print preview in php [message #174239 is a reply to message #174230] Sat, 28 May 2011 11:33 Go to previous messageGo to previous message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma:
Senior Member
Robert Heller wrote:

> Jerry Stuckle wrote:
>> On 5/27/2011 5:48 PM, Co wrote:
>>> 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?
>>
>> 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,[…]');
> return false;"

You really want to avoid such spaghetti code.

> 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. [complicated
> regeneration of the current resource, probably with lots of hardly
> maintainable ifs in-between]

Or you could much more simply define a stylesheet for print media that does
the necessary adjustments:

<link rel="stylesheet" media="print" href="print.css">


PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f806at$ail$1$8300dec7(at)news(dot)demon(dot)co(dot)uk>
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Storing parsed XML-elements as blobs
Next Topic: PHP Extension Won't Install
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 26 03:33:52 GMT 2024

Total time taken to generate the page: 0.13470 seconds