Thu Apr 17, 2014, 9:22 pm
Showing 1 to 7 of 7 entries.
Mon Nov 7, 2011, 3:49 pm

Hi,

When a user have filled out my form I want them to be able to generate a PDF with the information. I try to do this with FPDF.

I have put all the files on my server, but I can't get it to work from chronoforms (Joomla 1.7 & CF V4). I have created a CF that includes the php-file with some code to generate the pdf. The included PHP-file includes another php-file (the FPDF-file).

What I get when I try to generate the PDF is strange code like this:

%PDF-1.3 3 0 obj <> endobj 4 0 obj <> stream x�}��J�P��}�Y�����\��.\ � T%�fQ����V�eȬ ��a��ax^%�߫����0%��qX�C%AS����W��k�WFf(M��p3L��x ��4�w(����J�A���̼��8�ﰟ��Ϗ���o�A�"�;"��ku�O�b2����2a��V��2�=����2Q<��l�D��]�Z-�G�/ and so on ...

If I put the URL to the php-file in the browser it does generate the PDF, but not when I click on the link from CF.

55
Wed Mar 10, 2010, 3:41 pm
Tue Nov 8, 2011, 12:23 pm

Hi PicoPaco,

That could well be a PDF file - or the contents of it.

Sorry, I have no experience with this though I do believe that it is possible.

Bob


ChronoForms technical support
If you'd like to buy me a coffee, thank you very much

GreyHead
Moderator
35685
Tue May 29, 2007, 6:15 pm
Tue Nov 8, 2011, 6:07 pm

Hi PicoPaco & Bob,
I roughly recall this being a matter of FPDF not utilizing the Joomla framework for handling headers and text output. There is also the issue of preventing the template from being used, as this would obviously destroy the pdf file format by embedding it in a html-page (you could use the format=raw parameter in the submit-URL to tell Joomla to skip the template, but you still need to tell the browser what kind of document you are sending).

I did use FPDF in a CF-project a long time ago, and encountered some similar issues. In the end, I resorted to create a pdf-file on the server filesystem, and adding this file as an attachment to the response email / posting a link on the "thank you" page.

/Fredrik

1020
Sun Feb 8, 2009, 3:12 pm
Wed Nov 9, 2011, 1:01 pm

Hi Fredrik and Bob,

Yes, the problem seems to be that I can't get rid of the <head> and <body> tags. Theres also a hidden input generated by CF. I want the PDF to get the data from the database, do you think its possible to do this without using chronoforms? When the user is finished filling out the form there will be a PDF-button, maybe I could just include a 'token' in the url to the php-file that generate the PDF? Any thoughts about this?

Thanks

Markus

55
Wed Mar 10, 2010, 3:41 pm
Wed Nov 9, 2011, 5:20 pm

Hi Markus,
Well, as I mentioned in my previous post, the simplest (though perhaps not the neatest) solution is to write the pdf document to a file on the server, and provide the user with a link to it on the thank-you page. This would be a "mere matter" of providing a path and filename to the Output() method of the fpdf object, and writing the appropriate html-tag on the thank-you page.

You could of course direct the form submission (form action URL) to a separate php-script that does all the magic, though this means Joomla and ChronoForms never sees the data at all...

/Fredrik

1020
Sun Feb 8, 2009, 3:12 pm
Wed Nov 9, 2011, 10:24 pm

Hi Fredrik,
Thanks for the reply. What I want is to store the data form the cf in the database. When the data is stored I want the users to be able to download the posts in PDF-format. The best would be if the PDF is generated when the user clicks the link so that the server won't be filled up with PDF-documents.

I have succeeded to get out some data to the pdf by doing a db-select in the FPDF-file and refer the cf_uid which is in the url in the link (The PDF-generating thing is outside of Joomla and CF). But it seems like quite much work to get it to look the way I want it to. Isn't it as much work to generate a file to the server?

Thanks
Markus

55
Wed Mar 10, 2010, 3:41 pm
Wed Nov 9, 2011, 11:08 pm

Hi Markus,
Increasing number of files could be a problem (without some cleanup mechanism).

You could use an external php-script, which completely circumveins the issues with Joomla templates - though you will have issues using the Joomla api. This would also make it quite easy for users to check other submissions by testing different cf_uids in the URL link.

With CFv3, there is the custom Extra codes you could use, along with the format=raw option earlier mentioned. This would allow you to run custom code without having the output being damaged by an templates or such. You would also have full access to the Joomla api, as well as the current user session - meaning we could make sure the user can't request any other users's data.
I'm not that familiar with CFv4 to tell if and how you could do the same here.

/Fredrik

1020
Sun Feb 8, 2009, 3:12 pm
Showing 1 to 7 of 7 entries.

Powered by ChronoForums - ChronoEngine.com

ChronoForms Book

The ChronoForms Book, written for ChronoForms v3 contains 350 pages of invaluable ChronoForms How-tos hints and tips.

Note: many of the ideas can be used in ChronoForms v4 but the admin interface is very different and code examples may need to be modified.

SSL

Members Login

 

2CheckOut.com Inc. (Ohio, USA) is an authorized retailer for
goods and services provided by ChronoEngine.com