This topic is locked

Save pdf file based on print page on server after adding a record

9/11/2020 4:40:20 AM
PHPRunner General questions
K
kausi author

I'm trying to save pdf based on print page on server after adding a record. Probabaly it can be somehow used PDF api but havent figured it out yet. To make things more tricky record is added on pop up page. How to accomplish this?

Admin 9/11/2020

Yes, PDF API should be able to help here.
The main issue is that PDFs are generated in Javascript code in the browser and we need to send PDF file to the server. PDF API has a function for this:

https://xlinesoft.com/phprunner/docs/ajax_addpdf.htm
I would suggest doing so by adding an extra button to the Add page where you can use this function. Another option is to use beforeSave event:

https://xlinesoft.com/phprunner/docs/how_to_ask_for_confirmation_before_saving_record.htm
If you use beforeSave event your PDF file may not be saved yet if you need to use it in events like BeforeAdd or AfterAdd. If you just need to save it on the server - it will work just fine.

K
kausi author 9/14/2020



Yes, PDF API should be able to help here.
The main issue is that PDFs are generated in Javascript code in the browser and we need to send PDF file to the server. PDF API has a function for this:

https://xlinesoft.com/phprunner/docs/ajax_addpdf.htm
I would suggest doing so by adding an extra button to the Add page where you can use this function. Another option is to use beforeSave event:

https://xlinesoft.com/phprunner/docs/how_to_ask_for_confirmation_before_saving_record.htm
If you use beforeSave event your PDF file may not be saved yet if you need to use it in events like BeforeAdd or AfterAdd. If you just need to save it on the server - it will work just fine.


Thanks for the answer but the problem is that I cannot use PDF API as there is no key to for view page before save available. Or is the aftersave event available to use and somehow to get the key value?

Admin 9/14/2020

You don't need the key column value if you export the current page.

K
kausi author 9/14/2020



You don't need the key column value if you export the current page.


I undrestood that PDF API only supporting view and print page. I'm on the add page (pop up). And I would also need to print he key column. I see that it is somehow accomplished on Invoice template.

So is possible with PDF API?

Admin 9/14/2020

In the Invoice template user is redirected to the View page after the invoice is created. This would be the best option for you as well. In this scenario, you can just use the View page Javascript OnLoad event to generate PDF and save it on the server.