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


Groups > comp.lang.php > #1885

Re: Print preview in php

From Robert Heller <heller@deepsoft.com>
Organization Deepwoods Software
Subject Re: Print preview in php
References <fb8ba0bb-310a-4470-b63d-3f9d353468c8@gu8g2000vbb.googlegroups.com> <irpism$jhp$1@dont-email.me>
Newsgroups comp.lang.php
Message-ID <xJidnWeLWcSY_33QnZ2dnUVZ_gOdnZ2d@posted.localnet> (permalink)
Date 2011-05-27 21:46 -0500

Show all headers | View raw


At Fri, 27 May 2011 21:24:36 -0400 Jerry Stuckle <jstucklex@attglobal.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@deepsoft.com
Deepwoods Software        -- http://www.deepsoft.com/
()  ascii ribbon campaign -- against html e-mail
/\  www.asciiribbon.org   -- against proprietary attachments


                                              

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