Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-03-2010, 07:49 PM   PM User | #1
smaftei
New to the CF scene

 
Join Date: Nov 2010
Posts: 1
Thanks: 1
Thanked 0 Times in 0 Posts
smaftei is an unknown quantity at this point
Question how to use LPR command in javascript

I am trying to use the LPR command inside a javascript to print a PDF file directly to the printer. Want just a simple webpage with a button which will print test.pdf when clicked.

lpr -S xxx.xxx.xxx.xxx -P print -o l C:\Users\xxxxxx\Desktop\test.pdf

I know very little when it comes to javascript. If you know of a better way to use the lpr command, please let me know.
smaftei is offline   Reply With Quote
Old 11-03-2010, 07:54 PM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,044
Thanks: 197
Thanked 2,412 Times in 2,390 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
lpr is a command-line command and is not valid Javascript syntax.

If you embed the pdf in your webpage and reference the object id, you should be able to do it.

e.g. in your HTML:

Code:
<object id = "examplePDF" type="application/pdf" data="example.pdf" width="500" height="500">
in your javascript:

Code:
<script>
var pdf = document.getElementById("examplePDF");
pdf.print():
</script>

Another way:-

Code:
<iframe src="document.pdf" id="PDFtoPrint"></iframe>
<input type="button" value="Print" onclick="document.getElementById('PDFtoPrint').focus(); document.getElementById('PDFtoPrint').contentWindow.print();">
All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

Last edited by Philip M; 11-03-2010 at 08:09 PM..
Philip M is offline   Reply With Quote
Users who have thanked Philip M for this post:
smaftei (11-04-2010)
Reply

Bookmarks

Tags
dos, linux, lpr

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:08 AM.


Advertisement
Log in to turn off these ads.