0

I have a bdc.php file which generate a .PDF file with fpdf.

It is working well when the user click on the link but i would like to force the PDF creation when the page is displayed (even if the link is not clicked)

bdc.php retrieve a value named $rid to fill the PDF according to the database.

The code below works : generate PDF, download, and store it on the server :

<a href="bdc.php?rid=<?php echo $rid ; ?>" download><span><img src="./images/icon-pdf.png"></span></a>

Exec does not work even with forced value or variable :

exec ('php bdc.php rid="2055381354"');
exec ('php bdc.php rid=.$rid.');

The PDF generate well until the $rid is reached and is blank below

Could you please help me to solve this ?

Regards.

2
  • Command line arguments work differently from query parameters. However, that does not really matter here; as your script only saves a pdf to the server, you could simply set the required variable and include the file. Commented Dec 27, 2018 at 17:06
  • stackoverflow.com/questions/11048835/… Commented Dec 27, 2018 at 17:17

2 Answers 2

0

You can add the following code inside your bdc.php file to convert the CLI arguments to the query string

if (!empty($argv[1])) {
  parse_str($argv[1], $_GET);
}

Then bdc.php?rid=123 and exec('php bdc.php rid=123'); both will work fine.

Hope it helps

Sign up to request clarification or add additional context in comments.

Comments

0
exec('php bdc.php rid="'.$rid.'"');

Thank you Naveen, works well.

Best Regards.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.