i would like to print a php page on a paper. I want the page to be printed exactly like what is on the screen. The page has textbox, table, buttons and etc. Is it possible? Can someone please show me how to code?
Announcement
Collapse
No announcement yet.
print out php page in paper
Collapse
X
-
I'm confused, can't you just open it in a browser and print?
Otherwise, if your on linux you could try...
Code:$> /path/to/php myPhpFile.php | lpr
Comment
-
Another possibility would be that you want the page to be printed on the user's printer.
Like a button on the page called 'Print'?
This is not something that is possible using PHP, since you are wanting to perform client-side actions. As a result, you need to use something like JavaScript or VBScript.
This is something that is not quite that easy since they can be browser dependent -- especially printing. The main reason is security. For example, imagine visiting a website that prints an infinite number of pages (using an inifinite loop possibly) on your printer. Believe it or not, there are some sick people out there that would try to take advantage of this security hole online. As a result, IE and Netscape, among others, have disallowed the ability for certain actions.
I think you can print but it will probably just bring up the print dialog box. Unfortunately, this is the best that can be done.
For information about these client-side techniques, I've included the following links:
Of course you have to keep in mind that you have Windows, Mac, and Linux users, among others.
Hope that helps,
Sadiq.
Comment
-
-
Re: print out php page in paper
Originally posted by hosefo81
i would like to print a php page on a paper. I want the page to be printed exactly like what is on the screen. The page has textbox, table, buttons and etc. Is it possible? Can someone please show me how to code?
The Server - where the PHP Code is executed - has no idea how the HTML Code looks in the different Clients.
The only way is to generate a PDF and print that - if there is any printer available for the server. If you print HTML or PHP Files you'll get the code of those files and not the Browser-appeareance.
Comment
Comment