print a report with php

Discussion in 'PHP' started by 3.5supersonic, Nov 11, 2010.

  1. #1
    Hi

    Im looking for a way to add a print option to php script which generate a report.

    any idea for a way to do this?


    Thanks
     
    3.5supersonic, Nov 11, 2010 IP
  2. max2010

    max2010 Greenhorn

    Messages:
    81
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #2
    hm I would help you but you should explain a bit more what you need... which kind of report and from where the data come?
     
    max2010, Nov 11, 2010 IP
  3. dihuta

    dihuta Active Member

    Messages:
    47
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    93
    #3
    You should export to PDF file then open it and using javascript to open Print Dialog.
    Print directly from browser is not a good idea (quality, url, header, background remove,...)
     
    dihuta, Nov 11, 2010 IP
  4. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #4
    use javascript for this, generate your report onto a separate page

    <a href="javascript:window.print();">print</a>

    or you can export first your report (docx, csv, xls, pdf, etc...)

    use php header() for that
     
    bartolay13, Nov 11, 2010 IP
  5. dihuta

    dihuta Active Member

    Messages:
    47
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    93
    #5
    Except chrome, all browser will include it's url+title to printed page. This will make your print look ugly.
    Almost site which I see, use PDF for printing.
     
    dihuta, Nov 15, 2010 IP
  6. vaidikkp

    vaidikkp Peon

    Messages:
    72
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    its simple. create a link like this:
    <a href="javascript:print()">Print this document</a>
     
    vaidikkp, Nov 15, 2010 IP