?
Solved

Print a PDF without any user intervention

Posted on 2004-08-23
9
Medium Priority
?
580 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 

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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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 seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Suggested Courses

777 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