Solved

Print a PDF without any user intervention

Posted on 2004-08-23
9
557 Views
Last Modified: 2013-12-25
I have the following requirement :

There is a button say "pressMe", which when clicked should print a PDF file (whose path is known). However, the print operation should not pop-up any window and wait for the user to click on it. Also, if there is any pop-up window, it should close automatically once the PDF document is fully printed.

I am using Javascript. Right now, I am trying to simulate an operation which closes the Print Dialog that comes up before printing.

Please suggest solutions.

0
Comment
Question by:Sumanta
  • 4
  • 4
9 Comments
 
LVL 36

Expert Comment

by:Zyloch
ID: 11872970
Hi

First, I must say that users will probably dislike this fact (that you have disabled the print dialog). Use it only if you dare. You can use ScriptX, check out this link: http://www.experts-exchange.com/Web/Q_21068168.html



Regards,
Zyloch
0
 

Author Comment

by:Sumanta
ID: 11873273
Hi Zyloch,

I applied your solution and it worked.
But I need to customize it to my problem.

I have an array of checkboxes (which point to PDF files). The user selects some of the checkboxes and clicks the "pressMe" button. This should silently print the PDF's onto the printer (in a loop). For this reason, I do not want the print pop-up dialog to come up for each invocation of print.

Currently I am displaying the PDF's in 'iframes' in the same HTML page. These iframes are invisible and hold the PDF documents.
 <iframe name="bugsframe" src="c:\testhtml\bugs.pdf" width="0%">

How do I fire a print on these iframes when "pressMe" button is clicked ? [ more particularly -   how to call stopDialog.DoPrint(false); ]

Thanks in advance for your help.
0
 
LVL 36

Expert Comment

by:Zyloch
ID: 11873664
Because this is pdf, I would recommend you use server side coding, possibly something like this using PHP:

holdpdf.php
================
<?php
$myfile = "about:blank";
if (isset($_REQUEST['myfile'])) {
   $myfile = $_REQUEST['myfile'];
}
?>
<html>
<head>
<script language="javascript" type="text/javascript">
<!--
function printThis() {
  stopDialog.DoPrint(false);
}
// -->
</script>
<body onload="printThis();">
<object id="stopDialog" style="display:none"
classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" viewastext codebase="http://www.meadroid.com/scriptx/ScriptX.cab#Version=6,1,431,8">
</object>
<?php include($myfile); ?>
</body>
</html>


Then, your iframe would be:

<iframe name="bugsframe" src="holdpdf.php?myfile=c:\testhtml\bugs.pdf" width="0%">
0
 

Author Comment

by:Sumanta
ID: 11875787
I understand your point.
But I do not want to print the whole page.

I am interested in printing only the contents of the iframe.
And i cannot call  -   bugsframe.printThis();

So I am still searching for the solution ........
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 36

Expert Comment

by:Zyloch
ID: 11877546
Yes, my above example will load the pdf into a new page to print (of course you need PHP). The other option would be to have an iframe of fixed width and fixed height and print only part of the page.
0
 

Author Comment

by:Sumanta
ID: 11894006
Just to add more comments to my recent trial ......

This is following Zyloch's pointers -
In the site,
http://www.meadroid.com/scriptx/docs/printdoc.htm#clientSideBasic

they have given some examples of basic printing (which does not require hassles of licenses etc).
They have demonstrated iframe printing which works only when there is a HTML file inside that.

However if I put a PDF file inside the iframe, it does not print the content (the PDF file).

I do not want to go through licensing issues as all clients would be required to download and install the advanced features offered by MEADROID:-(

Any workarounds offered are welcome ! :-)
0
 
LVL 36

Accepted Solution

by:
Zyloch earned 125 total points
ID: 11959227
Sorry, I was away. Yes, you need HTML in it, which is the main concern. No matter what, you can't do it unless you put the <object> there.

As to the downloading of Meadroid, they provide to you a free version with limited functions, and you can link to it from within your object tag remotely.
0
 

Author Comment

by:Sumanta
ID: 11963730
Yes, I am aware that Meadroid provides a free version - but that is not good enough to have my PDF printed without the pop-up print dialog.

They, of course, do have a BatchPrintPDF API to print a PDF - but that is licensed !! And so, that solution is not acceptable to me.

Another work around which I initially thought was using the following snippet in a Java code (this also prints silently)-
"C:\\Program Files\\Adobe\\Acrobat 6.0\\Reader\\AcroRd32.exe", "/p", "/h", "PDFfilename".

But I do not know how to run this Java program at the client side from the browser.

I am now looking into writing a Activex control myself .... Yeah, I know that it is a big task to do a small thing :-(
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Search for URL in string php 4 55
powershell script help 5 58
inactive users 13 54
Nmap how to find wich type of socks is this? 4 71
Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now