1

Possible Duplicate:
How to save webpage as a image file using PHP?

i want user to enter few inputs then when he is done click save

all his inputs are sent to a php file that save these inputs and responde with

a new printable page that have a background image,and all inputs are shown on list positioned by css. enter image description here

my question is is it possible to ..

  1. trigger auto print after page showup
  2. save this entier page as single jpeg on server

my small project is using:php-html5-jquery-codeigniter 2

Community
  • 1
  • 1
Zalaboza
  • 8,899
  • 16
  • 77
  • 142

4 Answers4

4

You can generate a JPG of the page server-side using the GDI+ but it would require you placing text, etc, not relying on CSS, and a browser for layout... Failing that, you'd be better off generating a PDF which is designed for this.

As to printing, you can trigger the print dialogue using the following Javascript

windows.print()
Basic
  • 26,321
  • 24
  • 115
  • 201
  • And if user will be using WebKit printing dialog will show up where he can save it to PDF with no problem. – Stan Jan 14 '13 at 17:16
  • There are a number of ways to Print to Pdf on the client - WebKit browsers, PDF Writers for msot OSes, etc... The problem is, you can't just assume, you need to cater for the lowest possible denominator - which means server-side generation – Basic Jan 14 '13 at 17:54
1
  1. Yes. Call window.print() on load.
  2. Yes, but that would be more difficult. You would need to generate your output as an image. PDF would probably be an easier option.
datasage
  • 19,153
  • 2
  • 48
  • 54
1

To auto open the print dialogue:

function printpage() {
    window.print();
}

Or just straight out call window.print();

chrisbradbury
  • 327
  • 1
  • 5
1

You can either muck about with PDF generation, or you can set up print-friendly CSS.

Sammitch
  • 30,782
  • 7
  • 50
  • 77