473,405 Members | 2,373 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

How to print a pdf document through java script

Hello,

I have a web page which needs to print a pdf file when the javascript
is called.

I have the java script as

function printPDF(PrintString)
{
var status = 0;
var AccroApp;
var p;
var a;

try
{
AccroApp = new
ActiveXObject('AcroExch.App');

p = new ActiveXObject('AcroExch.PDDoc');

a = new ActiveXObject('AcroExch.AvDoc');

if (PrintString !='')
{
var Str = new String();
Str=PrintString;
p.Open(PrintString);
a = p.OpenAVDoc(p.GetFileName);
i = p.GetNumPages;
a.PrintPagesSilent(0,i,0,0,0);
a.Close(0);
p.Close;
AcroApp.Exit;
}
catch (e)
{

if (e.number != 0)
{
alert("Unable to Print - " + e.description);

}
}
But it throws an exception "Automation server cannot create object". I
have Acrobat 7.0 full version installed in my system. It will of agreat
help for me if anyone can tell me, how to solve this issue.

Thanks & Regards,
Pavan

Apr 24 '06 #1
1 1920
you will have to set the browser trust level to full for the website.

-- bruce (sqlwork.com)

<pa*************@gmail.com> wrote in message
news:11**********************@v46g2000cwv.googlegr oups.com...
Hello,

I have a web page which needs to print a pdf file when the javascript
is called.

I have the java script as

function printPDF(PrintString)
{
var status = 0;
var AccroApp;
var p;
var a;

try
{
AccroApp = new
ActiveXObject('AcroExch.App');

p = new ActiveXObject('AcroExch.PDDoc');

a = new ActiveXObject('AcroExch.AvDoc');

if (PrintString !='')
{
var Str = new String();
Str=PrintString;
p.Open(PrintString);
a = p.OpenAVDoc(p.GetFileName);
i = p.GetNumPages;
a.PrintPagesSilent(0,i,0,0,0);
a.Close(0);
p.Close;
AcroApp.Exit;
}
catch (e)
{

if (e.number != 0)
{
alert("Unable to Print - " + e.description);

}
}
But it throws an exception "Automation server cannot create object". I
have Acrobat 7.0 full version installed in my system. It will of agreat
help for me if anyone can tell me, how to solve this issue.

Thanks & Regards,
Pavan

Apr 24 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Mike Daniel | last post by:
I am attempting to use document.write(pageVar) that displays a new html page within a pop-up window and the popup is failing. Also note that pageVar is a complete HTML page containing other java...
2
by: dan | last post by:
This works in mozilla but I can't figure out why this won't work in IE. Say I have this html <html> header goes here header goes here
3
by: Michele Locati | last post by:
Hi to everybody I've a little problem that I can't solve. An hour of Google search didn't help. I should set dinamically via JavaScript the height of an object when I print the HTML page. ...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
2
by: Yuriy | last post by:
Hello! I need to print PDF Document by clicking a button on .aspx page. The PDF should be printed on client printer without displaing it on the window. I tried Process namespace but it doesn't...
0
by: Paco Ferre | last post by:
Hello, I founded some examples of WebControl printing in internet and tryed to have them working for a DataGrid, something not very complicated. I have a page, Page1.aspx with a DataGrid...
6
by: CSharpguy | last post by:
In my gridview I have 2 -3 template fields which are hyperlinks. I allow the user to print this grid. When the grid prints it also prints the links, how can I take the user to a print preview page...
0
by: agarwalsunitadhn | last post by:
hi.. How will i use print and print preview option. I have to print only a part of a page. for that i declare in a div and give that a id and then using java function to print that portion but my...
3
by: rajkumarpb | last post by:
Hi friends, I am new to this forum...But not for programming...I want a Print CSS File to be added in my page..OK.... Here is the page and i want you friends to help me create the CSS File...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.