Reputation: 45
I can write text in the pdf file with using code at web site link
If user enter the xxx.com/sample.php .. link shows the manipulated pdf file in the php page.
To make a manipulation we need to call PHP page.
If user directly enter the xxx.com/SAMPLE.pdf .. link shows the original pdf file...
How can I write the PDF file, when the user directly call the .pdf extension?
Should I write special code in the httpdocs file ?
For Example; If user call .pdf extension from special directory like directory/SAMPLE.pdf execute the special function to process pdf file.
How do I solve this problem ?
I thank you for your interest in my question.
Upvotes: 2
Views: 234
Reputation: 1620
I'd use htaccess to redirect all requests to "folder/whatever.pdf" to "folder/pdfgenerator.php?file=whatever.pdf".
This way you can do anything you want in PHP, including generating the file before showing it or naming it "whatever.pdf" which you can get by using $_GET["file"] in the example I described.
There is a similar question here: mod_rewrite & .htaccess - redirect request for a file extension to a script
In your case it would be something like:
RewriteEngine On
RewriteRule (.+\.pdf)$ /pdfgenerator.php?file=$1 [NC,L]
Upvotes: 3