Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #1894

Re: Print preview in php

Message-Id <16543329.4csPzL39Zc@PointedEars.de>
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Organization PointedEars Software (PES)
Date 2011-05-28 13:33 +0200
Subject Re: Print preview in php
Newsgroups comp.lang.php
References <fb8ba0bb-310a-4470-b63d-3f9d353468c8@gu8g2000vbb.googlegroups.com> <irpism$jhp$1@dont-email.me> <xJidnWeLWcSY_33QnZ2dnUVZ_gOdnZ2d@posted.localnet>
Followup-To comp.lang.php

Followups directed to: comp.lang.php

Show all headers | View raw


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@news.demon.co.uk>

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Print preview in php Co <vonclausowitz@gmail.com> - 2011-05-27 14:48 -0700
  Re: Print preview in php The Natural Philosopher <tnp@invalid.invalid> - 2011-05-28 01:33 +0100
  Re: Print preview in php Jerry Stuckle <jstucklex@attglobal.net> - 2011-05-27 21:24 -0400
    Re: Print preview in php Robert Heller <heller@deepsoft.com> - 2011-05-27 21:46 -0500
      Re: Print preview in php Co <vonclausowitz@gmail.com> - 2011-05-28 02:05 -0700
        Re: Print preview in php Robert Heller <heller@deepsoft.com> - 2011-05-28 08:12 -0500
          Re: Print preview in php Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-05-28 17:30 +0200
      Re: Print preview in php Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-05-28 13:33 +0200
        Re: Print preview in php Co <vonclausowitz@gmail.com> - 2011-05-28 05:04 -0700
          Re: Print preview in php TK <tknospa@wejuggle2.com> - 2011-05-28 07:22 -0500
            Re: Print preview in php dougatmilmacdotcom@example.com (Doug Miller) - 2011-05-28 14:14 +0000
            Re: Print preview in php Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-05-28 17:27 +0200
              Re: Print preview in php TK <tknospa@wejuggle2.com> - 2011-05-28 12:20 -0500
                Re: Print preview in php Jerry Stuckle <jstucklex@attglobal.net> - 2011-05-28 14:07 -0400
                Re: Print preview in php Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-05-28 20:27 +0200
                Re: Print preview in php TK <tknospa@wejuggle2.com> - 2011-05-28 15:18 -0500
              Re: Print preview in php TK <tknospa@wejuggle2.com> - 2011-05-30 07:32 -0500
                Re: Print preview in php Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-05-30 18:58 +0200
                Re: Print preview in php TK <tknospa@wejuggle2.com> - 2011-05-31 07:34 -0500
                Re: Print preview in php Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-05-31 15:08 +0200
      Re: Print preview in php Jerry Stuckle <jstucklex@attglobal.net> - 2011-05-28 09:06 -0400

csiph-web