Jump to content

Need to print data from php to printer which is connected to same wifi


Recommended Posts

Hi guys,

I have issue with connecting my printer 
Here is a scenario,
I have a file called text.php from this php file i need to print output to printer which is connected to same network.
Can u please me

Link to comment
Share on other sites

The ability to print from a website is a local operating system capability, built into the browser.  There is nothing special that PHP can do to help or hinder the process.

Javascript can be used to invoke the built-in browser support for printing, but again, printing will always require the user to take action.

For example, here is a simple button inside an anchor tag with some javascript.

<a href="#" media="all" onclick="window.print();return false;"><button type="button">Print</button></a>

 

You can use media queries in your css to style a page for printing by adding a style section like this:

@media print {
    /* styles here */
}

Typically people will hide things like menus, footers, nav, sidebars etc.  You also might want to set a margin around the content, since typically printers have that constraint,  so you might have something like this:

@media print {
    header, footer {
        display: none;
    }
}

Here is a pretty good sitepoint article that goes into much more detail.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.