/    Sign up×
Community /Pin to ProfileBookmark

I have to make a button that prints a text file. How do I do that?

to post a comment
PHP

11 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJun 23.2005 — Not with PHP. You need to do something on the client side (probably JavaScript).
Copy linkTweet thisAlerts:
@gebezisauthorJun 23.2005 — That's what I thought at first and posted there but no one answers it for quite a long time.....
Copy linkTweet thisAlerts:
@gebezisauthorJul 07.2005 — I still didn't get the solution.

I think that I need a server side language because the .doc file is on the server, actually the person who clicks on the button has to print a file located on the server. JavaScript cannot do this...
Copy linkTweet thisAlerts:
@theuedimasterJul 07.2005 — Why dont' you have them just download the file and print it themselves? Making the users printer print something is giving a little too much power to online script. I would make something displayable in the browser in "printable form" as many sites do, and then have them print it out.
Copy linkTweet thisAlerts:
@gebezisauthorJul 07.2005 — The project I'm working on is a previosly made course in Java and I have to remake it in HTML, PHP and so on but without any Java. I have to make it exactly the same as it is in Java. Till now I've never had problems remaking it and this is the first time and I RELLY have to make it the same - there is a button on the page which prints a .doc file made of a couple of pages (not only text but tables and forms).

Java obviously can do this, but I can't use it....
Copy linkTweet thisAlerts:
@beginnerzJul 08.2005 — [/code]

<script language="javascript">

function print(){

print();

}

</script>


---------------------------


<input name="Print" type="button" onclick = "print()" value="Print" style="width: 50px;">

[/code]
Copy linkTweet thisAlerts:
@gebezisauthorJul 08.2005 — this will print the current page, I have to print a file located on the server...
Copy linkTweet thisAlerts:
@CompGeek01Jul 08.2005 — You'll have to call a server side script to to it. You can't just let a random person write to your server, that I know of easily.

Option1) Onclick you change the location, send the user to the script which redirects them to where they were.

Option2) Request the script while not leaving the page...http://jibbering.com/2002/4/httprequest.html
Copy linkTweet thisAlerts:
@NogDogJul 08.2005 — Question: is the objective to print the file from the user's PC, or to print it from the server to a network printer (i.e.: this is a local application for a LAN)? If the latter, you would just use one of PHP's methods of accessing the server's shell commands ( http://us2.php.net/manual/en/ref.exec.php ). If the former, all I can think of is a link to a PHP page that include()s the text file to be printed, and then has a javascript function triggered by an onload() call to do a window.print().
Copy linkTweet thisAlerts:
@bathurst_guyJul 08.2005 — I just want to clarify something. A server side script means that it is processed on the server then sent to the client and executed. A client side script means that it is processed and executed on the clients computer. Client side scripts can access files on the server if need be, just because it's client side doesn't mean that it can only access the client and vise-versa.

I'm not sure if this works, I don't have a printer on this computer so I can't test it. But give it a try an let me know (got me curious now) ?
[code=html]<a href="javascript:print('details.html');">Print the details</a>[/code]
Copy linkTweet thisAlerts:
@bathurst_guyJul 08.2005 — Maybe one of these other ways will help you out.

http://www.irt.org/script/print.htm
×

Success!

Help @gebezis spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.14,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...