Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

document properties

Status
Not open for further replies.

OhioSteve

MIS
Mar 12, 2002
1,352
US
A. I need to write a javascript that will send a print job to a certain printer, and suppress all of the dialogue boxes.

B. I found a nifty javascript that does almost exactly what I want.

C. When I run the script as written, it dies on this line~
var objPrintParams = doc.getPrintParams();
The err.description is~
'doc' is undefined

D. When I replace "doc." with "document.", it still dies on that line. The err.description is~
object doesn't support this property or method

How can I fix this problem?
 
Here is all of the code fragment:

var objDoc = this;
var objPrintParams = doc.getPrintParams();

// Set so no dialog box is displayed at all to the user during printing
objPrintParams.interacitve =
objPrintParams.constants.interactionLevel.silent;

// Select which printer to print to
objPrintParams.printerName = "Canon Bubble-Jet BJC-6000";

// Print only odd pages
objPrintParams.pageSubset = objPrintParams.subsets.odd;

// Print both content and comments
objPrintParams.printContent =
objPrintParams.constants.printContent.docAndComments;

// Print the PDF using properties just set with printParams object
objDoc.print(objPrintParams);
 
Well, you didn't mention you wanted to printf a PDF.

Try replacing doc with this.

Cheers,
Dian
 
I changed it to "this", but I got the message "object doesn't support this property or method".

Actually, I'm trying to print a normal web page not a pdf. Is that possible? I took the code from a pdf-oriented website, but I assumed that it would work on a regular web page too.
 
It would be possible for me to display the data as a pdf. The content is totally static...the user does not interact with it. But I don't understand WHERE I would put the javascript. I mean, I can't "open" a pdf and add a javascript to it.
 
You can't print without user interaction using javascript. Imagine that I open a web page and it starts printing thousands of sheets without my permission. Crazy.

If you want to print regular HTML, I'd consider using regular print command.

Javascript Print


Javascript Print II

Cheers,
Dian
 
Btw, in the FAQ section of this forum there are a few about printing, they may help you.

Cheers,
Dian
 
Perhaps I am not expressing my question clearly. Let me try again.

Obviously I can view and edit the source code for an html web page that already exists. So clearly it is possible to add a javascript to an existing web page. But I cannot see the source code for a pdf that already exists. A pdf is completely inert, compiled, and unchangeable. That's why this conversation confuses me.
 
I'm the one confused now. What do you want to print? A PDF? A web page?

Cheers,
Dian
 
When I started this thread, I wanted to print a web page. I wanted to print it without showing the print dialogue box, and I wanted to print it to a specific printer. In this thread, I learned from BillyRayPreachersSon that that is not possible. He said I could only use the printParams object with a pdf.

Luckily everything on the web page is static. So I could make the same information into a pdf, then print it.
 
Bad news.

I have learned that two different flavors of javascript exist. One is used in webpages. The other is used when you MAKE a pdf using the full version of Acrobat. The code I had only works in the second scenario.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top