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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print a PDF file 1

Status
Not open for further replies.

Jean01

Technical User
May 6, 2001
15
US
Hello,
Is it possible to always print a pdf file instead of printing the html file when using internet explorer?

I have pdf files that I would like the users to print instead of the actual web page.

Thanks
 
By default when the PDF opens up they can print from there, a small toolbar appears on the top of the browser with options like save, print, etc...

Forget the Nobel Peace prize, I just want to take over the world!! [hammer]
 
GUJUm0deL, This is precisely what I would like to avoid...I am trying to force the pdf file to print in the background whenever the user selects either File/print, the print button in the toolbar or a printer icon in the web page.

Jean01
 
huh, when a pdf opens and they print it then they are printing the pdf file!

unless im not understanding your question which if that is the case then you need to spell it out a bit clearer!

prssing print on a pdf file ---> results in a pdf file being printed

[Hammer]
Nike Failed Slogans -- "Just Don't Do It!"
 
Can you be more accurate about the problem?? Typicaly when the PDF is clicked, Acrobat reads the file and opens it in the browser, and from there you click the print icon on the acrobat toolbar and the pdf is printed...


Forget the Nobel Peace prize, I just want to take over the world!! [hammer]
 
nice smiley guju

[Hammer]
Nike Failed Slogans -- "Just Don't Do It!"
 
GUJUm0deL,
The problem is this: I am putting together an instructions CD for some device. The user will navigate through the pages at will but in the event that they require a printout of a particuliar procedure (ie;tables, flowcharts steps), the formatting of the printed page gets messed up if printed from Internet Explorer.
That where the pdf files come into action because I made certain that the pdf files would print exactly as they should (paper size and orientation, page break etc.)

As much as it is possible and for all the above reasons, I want IE to always print the pdf file instead of the html version; the user may select File/Print from IE menu, the Print button in IE toolbar and I have added a printer icon on the page that should initiate the print process.

By going through the FAQs and Forums, this should work:
<head>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
<meta name=&quot;GENERATOR&quot; content=&quot;Microsoft FrontPage 3.0&quot;>
<link rel=&quot;alternate&quot; media=&quot;print&quot; href=&quot;document_name.pdf&quot;>
<script language=&quot;Javascript&quot;>
<!--
function printpdf() {
browserVersion = parseInt ( navigator.appVersion)
if (browserVersion >= 4) window.print ()
}

// -->
</script>

<title>Title</title>
</head>

I have put an image on the page that looks like a printer and that should initiate the printing process.

The code behind the image looks like this:
href=&quot;javascript:printpdf ()&quot;><img src=&quot;../images/Pics/printr01.gif&quot;
alt=&quot;Print Adobe Acrobat version of this page&quot; style=&quot;border: medium none&quot; WIDTH=&quot;33&quot;
HEIGHT=&quot;29&quot;>

The only things that gets printed are the IE headers (containing the title of the html page + page numbering)and footers (containing the actual path of the PDF file + date), not the actual PDF file. Both HTML and PDF files are located in the same directory and the PDF file prints fine if I right-click on it and select &quot;print&quot; from the source directory.

Thanks for your interrest!

Jean01
 
Hmm, I see your problem and from my P.O.V. there's only one solution: when the user clicks the pdf link on the html page, open the PDF in a new browser window, strip the new browser window of its toolbar that way only the acrobat toolbar appears and the user has to click that print icon to print...
Not sure if this is the way you'd want to do it, I can also suggest posting this topic question the Acrobat forum here, maybe one of the guru's there has a simpler solution: forum223

Forget the Nobel Peace prize, I just want to take over the world!! [hammer]
 
BTW, if you want the code for the new window et al. just ask and i'll provide it...

Forget the Nobel Peace prize, I just want to take over the world!! [hammer]
 
GUJUm0deL,
Thanks for the advice, I might just do that. I would appreciate if you can provide the code you had i mind.

Thank you!
 
Jean01, here you go:
<html>
<head>

<script>
function openwindow(file, name) {
var page1 = window.open(file,name,&quot;toolbar=no,location=no,directories=no,status=no,menubar=no,height=450,width=450, scrollbars=no,resizable=no&quot;);
}
</script>
</head>

<body bgcolor=&quot;#FFFFFF&quot; text=&quot;#000000&quot;>

<a href=&quot;javascript:eek:penwindow('<a href=&quot;javascript:eek:penwindow('<a href=&quot;javascript:eek:penwindow('</body>
</html>


The code in teal opens the new window with no toolbar so the user has no access to the browser Print function, they can only print via the acrobat toolbar...
The code in green opens the new window in a specified width and height, play around with this to get the desired height and width...if all the new window's have a different window height and width, then do this:


function openwindow(file,name,prefs) {
var page1 = window.open(file,name,prefs);
}


And anywhere you want to call the function, do this:

<a href=&quot;javascript:eek:penwindow(' 'toolbar=no,location=no,directories=no,status=no,menubar=no,height=450,width=450, scrollbars=no,resizable=no')&quot;>View</a><br>
<a href=&quot;javascript:eek:penwindow(' 'toolbar=no,location=no,directories=no,status=no,menubar=no,height=450,width=450, scrollbars=no,resizable=no')&quot;>View</a><br>
<a href=&quot;javascript:eek:penwindow(' 'toolbar=no,location=no,directories=no,status=no,menubar=no,height=450,width=450, scrollbars=no,resizable=no')&quot;>View</a><br>


Change the red to any height and width that you need...if you need anymore help, just ask...

Forget the Nobel Peace prize, I just want to take over the world!! [hammer]
 
Sorry made a slight mistake (its monday morning, yuck), its the menubar that displays the File, Edit menu options, not the toolbar...



*gets up and gets coffee*

Forget the Nobel Peace prize, I just want to take over the world!! [hammer]
 
I took me a while but I found a file that I downloaded long time ago. It's a PDF file that once I opened goes directly to the printer.
Here's the trick. You have to create the pdf file with Acrobat full Version not the Reader.
You can use the HTML code supplied before on previous postings to open the page and load the PDF. From that point on let this trick take care of the printing.

In Acrobat go to Document> Set Page Action > On Page Open > Add Action and Select Javascript from the list presented.
Once you open the edit window paste this code

this.print(false, 1, 3,true)

My document has 3 pages I guess the 1-3 is just to define what pages you want to print.
The first parameter deals with the Print Dialog box ( wich by the way you don't even see when opening the PDF file).
The Last parameter I couldn't figure out. Try to look for Javascript Reference for PDF documents.


Hope that helps a little bit or at least gives you a new idea.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top