Print page without opening it.

IS there a way to print a webpage without opening it?  Lets say I'm on a page: www.MYSITE.com/report.php and that page is very stylized (CSS) and I have an option on that page to "Print Page"  BUT, I have another version of that page; www.MYSITE.com/report_print_version.php and this page has been formatted to print out.

I DON'T want to open this page, I want to print it from www.MYSITE.com/report.php.

Is that possible? Any clues?
LVL 8
rgranlundAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave BaldwinFixer of ProblemsCommented:
The only file that I know of that you can print without 'opening' it is a plain text file going to a plain text printer (which you probably haven't seen in 10 years anyway).  Everything else, HTML, PDF, 'doc', 'xls' must be opened by the program that can format it properly.  In the case of PHP, you can't even generate the page without opening it in PHP.  Until you open it and run the PHP, the 'printable' version doesn't even exist.
0
rgranlundAuthor Commented:
@Dave

I'm using a JQuery Plugin and the following:
        <script>
            $(document).ready(function() {
                $('span.print').printPage();
            });
        </script>

<span class="print">PRINT</span>

Open in new window


Is there a way to print a containing DIV instead of the entire page?
0
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
you may be able to do it with ajax and jquery:

http://www.boduch.ca/2011/10/printing-dynamic-content-with-jquery.html
http://www.position-absolute.com/articles/printing-web-pages-a-new-jquery-printing-plugin/
http://projects.erikzaadi.com/jQueryPlugins/jQuery.printElement/

the last one, you should be able to load the data into a variable (or hidden div) via ajax, and then use the printElement() call.

HTH
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dave BaldwinFixer of ProblemsCommented:
Is there a way to print a containing DIV instead of the entire page?
There might be but that's not your original question.  And in the case of the DIV, it still has to be on the page in the browser to print it with the correct formatting.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.