Solved

Print a PDF without any user intervention

Posted on 2004-08-23
9
559 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This tutorial will give you a fast look what you can do with WhizBase. I expect you already know how to work with HTML at least, and that you understand the basics of the internet and how the internet works. WhizBase is a server-s…
If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
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…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

920 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

15 Experts available now in Live!

Get 1:1 Help Now