Solved

Print a PDF without any user intervention

Posted on 2004-08-23
9
564 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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 

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
 
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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
What is assert.deepEqual? 4 59
Powershell File Sort 8 45
Need help Creating PowerShell Script 5 64
BATCH to EXE Converter 2 67
I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
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.

713 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