Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6982603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:18:35+00:00 2026-05-27T18:18:35+00:00

I have a web application written in PHP with many reports in HTML format.

  • 0

I have a web application written in PHP with many reports in HTML format. Sometimes, I have different reports in one page and each of them have a print button.

One solution I have is to generate that report again using PHP variables in a new page.

But I think there is another way to do it. I can copy all of the report table HTML codes into clipboard, open a new window, paste clipboard data on it and finally print the page contents.
I saw something in http://archive.plugins.jquery.com/project/clipboard, but it seems that this plugin does not work anymore.

Do you have any idea to solve my problem (cross-browser)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T18:18:36+00:00Added an answer on May 27, 2026 at 6:18 pm

    I can copy all of the report table HTML codes into clipboard, open a new window, paste clipboard data on it and finally print the page contents.

    You don’t need the clipboard for this, and even if you could get it to work you shouldn’t use the clipboard for this: the clipboard is there for the user’s convenience, not yours, and overwriting whatever was in it before is not appropriate.

    Fortunately you can open a new window and set its contents without going anywhere near the clipboard:

    function printReport(elementId)
    {
      var elementToPrint = $("#" + elementId),
          printWin = window.open("", "Print", 'left=20,top=20,width=400,height=400');
    
      printWin.document.write(elementToPrint.html());
      printWin.document.close();
      printWin.focus();
      printWin.print();
      printWin.close(); // optionally close the new window immediately
    }
    

    Working demo (tested only in Chrome): http://jsfiddle.net/Vc5yy/

    Note that obviously this is just a bare-bones solution, but it should give you all the pieces you need to complete your own solution. You’ll probably want to apply an appropriate CSS stylesheet, etc. But the main thing is once you’ve opened a second window you can write whatever you want to it and then call the window.print() function.

    Note that you should run the above function from an event handler (like from a button click as shown in my demo) or the browser’s popup blocker probably won’t let it open.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have web application written in java using Eclipse. It has just one servlet
I have a web application written in pure JavaScript (no pre-generated HTML except for
I have a web application written in PHP using MySQL that I would like
I have a web application written in PHP. It uses MySQL for data storage.
I have a web application, written in PHP, based on UTF-8 (both PHP and
I have a web application, written in PHP, where we have a couple of
We have a web application written in PHP that exports MySQL query results to
I have a Master - Slave setup for a web application written in PHP.
I have a ticketing web application written with PHP and MySQL. I need something
The context: I have a web application (e-commerce in few steps) written in php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.