8
Contributors
7
Replies
54
Views
3 Years
Discussion Span
Last Post by cereal
0

PHP is a server-side scripting language. If you need to control printing, that's going to be handled client side. For example, you can include a button on your page, or an icon of a printer that lauches the printer controls of the user's PC. What you need to do is display the page accordingly so it's layout is printer friendly. You do that by appying the appropriate styles. You can use the @media rule to set the layout printer friendly.

Edited by JorgeM

0

Hi as JorgeM said you need a js for it to be done...my suggestion is

  1. Full the data from your db and arrange it as you desire
  2. On page load use windows.print() or add a button or image that when click will call the print dialog box.

like

on page load

<html>
<head>

</head>
<body onload="window.print()">

<?php

DATA FROM DB


?>

</body>
</html>

or using an image or button

 <html>
<head>

</head>
<body>

<?php

DATA FROM DB


?>
<img src="printer.png" width="28" height="28" onclick="window.print()" />

<input type="button" value="Print this page" onclick="printpage()">


</body>
</html>
0

i have tried

<input type="button" value="Print this page" onclick="printpage()">

but it shows no output
and when i use

<img src="printer.png" width="28" height="28" onclick="window.print()" />

its open printer diup box, if is good for laser printer/color printer, but it cteate problem for DMP printer i want solution for DMP printer

0

Unless you have defined a printpage() function in JavaScript, that button will not do anything. Your <img> tag uses the right code window.print(), you could change the button to use the same thing:

<input type="button" value="Print this page" onclick="window.print()">

As for problems with a dot-matrix printer, those aren't going to be resolved by anything you can do in the browser. The print dialog opened by window.print() is the browser's print dialog the same as if the user chose to print the page themselves. What problems exactly are you encountering?

-2

Hello sir i am developing a project where i want to print a page/part of the page from web browser without print window using javascript or php. could u please help me how i could do so? if possible then please send me code or process. thank u.

0

here i have a problem..

i want to print a page in php with image, but image is not print..
please help somebuddy..

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.