Jump to content

generating .txt .doc or .pdf


freelance84

Recommended Posts

 

There is a section in my site in which i will need to give the user 3 options:

 

Generate Specific User Text As:

            1.  pdf

            2. .doc

            3. .txt

            4. print in html

 

The 4th option is simple. The other three are completely new to me.

 

I know little bit about fopen, fwrite and fclose, however these are commands that write files to the server. I need to write files to the users computer.

 

Is the best way for this to be:

1. the user clicks .txt

2. the .txt is written to the server

3. the .txt is then downloaded to the users computer by the user

4. the .txt is then deleted from the server

 

All 4 steps to be done with one click from the user.

 

Might there not be traffic problems if lots and lots of users are doing this at the same time?

 

Any pushes in right direction here would be great, there seems to be hundreds of sites saying different solutions

 

 

Link to comment
Share on other sites

I need to write files to the users computer

Impossible.

 

1. the user clicks .txt

2. the .txt is written to the server

3. the .txt is then downloaded to the users computer by the user

4. the .txt is then deleted from the server

This is correct.

 

Might there not be traffic problems if lots and lots of users are doing this at the same time?

No, just make sure you give each file created a unique name so one user cannot overwrite anothers if running at the same time.

 

You can create word documents using fopen(), fwrite(), etc and save the file with a .doc extension, However if you want a properly formatted document you require COM objects (windows servers only).

 

For PDF generation I recommend the following http://www.fpdf.org/

 

Link to comment
Share on other sites

Is there any example code of how to do this?  I am somewhat new to PHP and am still learning.  I want to query a MySQL database and write out the result to a txt file the user can download.

 

1. the user clicks .txt

2. the .txt is written to the server

3. the .txt is then downloaded to the users computer by the user

4. the .txt is then deleted from the server

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.