Question

I recently got a new printer (specifically a HP Photosmart C6380 if that helps) that allows me to send text to port 9100 to print. Telnetting into it and typing text to print works fine, but I'm wondering if I could make a webpage using HTML and Javascript that can send text directly to it.

I'm currently using the code from the article Cross Site Printing (pdf), but the downside is that when it prints out it shows the entire POST request and not just the text.

So my question for you is am I able to send just the content of the POST request or strip the unneeded characters using only HTML and Javascript?

Note: The reason why it's limited to HTML and Javascript is because I'm hoping that I can use this on an iPhone or iPod Touch.

Edit: It appears that there's no way to get rid of the HTTP headers, so now my question is can I craft a custom POST request that will minimize on what is sent in the header? For example, can I not send the user agent since the printer doesn't care what the user agent is?

Was it helpful?

Solution

No, there's no way to get rid of the HTTP headers in client-side JavaScript. For that, you need to set up a server-side script which will then make the actual connection to the printer port.

Edit: The server-side script won't send a HTTP request to your printer: It should open a new socket and thus can fully controle what gets sent!

OTHER TIPS

You can HTTP-Request from within JS, so you always have an HTTP-Header, regardless of the port to which you are sending. So the answer is: no.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top