Download pdf using php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nithinkk
Forum Commoner
Posts: 55
Joined: Sat Nov 28, 2009 7:57 am

Download pdf using php

Post by nithinkk »

I got a set of newspaper websites which allows me to download epaper on-line. Is it possible to download them using php scrip to a particular folder at 12pm everyday.


Example websites :

http://epaper.mathrubhumi.com/index.php ... /index.asp
gooney0
Forum Commoner
Posts: 56
Joined: Fri Jan 21, 2011 1:40 pm
Location: Reston, VA

Re: Download pdf using php

Post by gooney0 »

Sure. You could go about this many ways:

1) Use cron and commandline php

2) Use cron and wget don't use php at all. This is easier I think.

3) Use regular PHP and have something visit the web script at midnight.

In PHP you can use fopen, fread, and fwrite to handle the HTML and PDFs.

From your example it looks like you'll need to:

fopen the URL
parse out the link(s) to the pdf

fopen the PDF url
fwrite the PDF to a file
nithinkk
Forum Commoner
Posts: 55
Joined: Sat Nov 28, 2009 7:57 am

Re: Download pdf using php

Post by nithinkk »

Thanks ! i did it with Cron job + Bash script
Post Reply