Generated PDF dilemma

Generated PDF dilemma

nessinitsnessinits Posts: 86Questions: 27Answers: 0

Hi all,

I have a dilemma concerning generated PDF's. I use a table called am_documents and a table called am_files for storing my data concerning uploaded files. This works just like the examples on this site show.

My application does also generate PDF's and I am building the functionality to store these generated .pdf documents in the same directory as the uploaded files. In fact the data I want to store is also the same.

The function to generate PDF doesn't let me upload the document, but it is generated directly in the directory used. Can I reuse the PHP code for storing the data in the database, so I don't have to maintain two different functions? Of should I solve this different than the upload function, which means I have to take care of the 'default' functionality in my .php processing functions.

How would you solve this dilemma? If you need more info, please let me know.

Kind regards,
nessinits

Answers

  • allanallan Posts: 63,471Questions: 1Answers: 10,467 Site admin

    Can I reuse the PHP code for storing the data in the database

    What PHP are you currently using? Are you using Editor's upload, or something else? Can you show me that code?

    Thanks,
    Allan

  • nessinitsnessinits Posts: 86Questions: 27Answers: 0

    Allan,

    The PDF is generated with FPDF. It has a specific function in it to save the generated document on the server. I'll send you some code.

  • allanallan Posts: 63,471Questions: 1Answers: 10,467 Site admin

    Is the PDF being generated when it is requested by a URL? If so, you could use file_get_contents() and request the PDF generation URL and it will generate the file just as if the URL were requested by a browser.

    Allan

  • nessinitsnessinits Posts: 86Questions: 27Answers: 0

    The comment with file_get_contents() will get me in the right direction, probably.

    Thanks Allan. ;-)

This discussion has been closed.