CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • PDF Form on a custom Template
Pages: [1]

Author Topic: PDF Form on a custom Template  (Read 1898 times)

aspagarino

  • I post occasionally
  • **
  • Posts: 89
  • Karma: 10
  • San Diego Joomla
    • California Center for Sustainable Energy
  • CiviCRM version: CiviCRM 4.3
  • CMS version: Drupal 7
PDF Form on a custom Template
February 25, 2010, 06:29:12 pm
I created a custom template for a contribution ThankYou.tpl, it works fine and it display a custom forms created with custom divs and images.

I would like to include a button to create a pdf version of the custom displayed Thank You page.

Is it possible to use FPDF inside the tpl file? I have used FPDF before but just with plain php.

Thanks in advance,

Andres

Andres

Open Source is Green

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: PDF Form on a custom Template
February 25, 2010, 08:43:10 pm
hey andres:

for licensing reasons, we've switched to tcpdf for 3.1.2+

u can use plain php within smarty, check:

http://www.smarty.net/manual/en/language.function.php.php

curious how you plan to generate a pdf file within the template

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

aspagarino

  • I post occasionally
  • **
  • Posts: 89
  • Karma: 10
  • San Diego Joomla
    • California Center for Sustainable Energy
  • CiviCRM version: CiviCRM 4.3
  • CMS version: Drupal 7
Re: PDF Form on a custom Template
February 25, 2010, 09:52:03 pm
On the report pages there are pdf buttons, I was hoping that it was possible to include a similar PDF button inside of the custom ThanYou.tpl template.

All I need is to generate a custom pdf receipt (with logo on the headers and the custom fields) for the contributor.

I guess it can be attached to the automatic confirmation email.

Would you recommend instead to use a hook for the email sent from the contribution form?

Can I generate and attach a custom made pdf using hooks?

Andres




Andres

Open Source is Green

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: PDF Form on a custom Template
February 26, 2010, 02:05:55 am
Hi,

I'd create a new menu entry (or extend the pdf letter so it handles contrib as well as only contacts, haven't looked at the code), so you can have a civicrm/pdfdoc?format=contribthankyou&contrib_id=XXX&contact_id=yy&checksum=cccc

accessible to anyone, but with the checksum being there so you can only see your contrib.

calls different php class based on the format param (eg contribthankyou in contribthankyou.php).
the pdfdoc fetch the contrib and contact details and pdfgenerator->assign them, and pdfgenerator->generate

within generate, you're free to put as many logos and format the way you want.

on the thank you page, you simply have to put the link to civicrm/pdfdoc?format=contribthankyou&contrib_id=XXX&contact_id=yy&checksum=cccc


What do you think ?

-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: PDF Form on a custom Template
February 26, 2010, 07:10:55 am

the way we've generated PDF so far (including reports) us using dom2pdf, which basically requires the few html document and then converts that to a PDF. Hence doing this via a template / hook is a bit hard

With regard to the thank-you page in event/confirmation, its an even bit harder since we blow away the session when we are rendering that page (so we dont have the data any more to go back and recreate the receipt (unless we rebuild it from the database)

there is a task called print pdf receipt for contributions which prints a pdf receipt which basically does a lot of what thank you does.

ahh, attaching the email PDF receipt might be easier. Within the code, u basically render the email as a PDF and then add as an attachment. ping us on irc if u wanna discuss

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

aspagarino

  • I post occasionally
  • **
  • Posts: 89
  • Karma: 10
  • San Diego Joomla
    • California Center for Sustainable Energy
  • CiviCRM version: CiviCRM 4.3
  • CMS version: Drupal 7
Re: PDF Form on a custom Template
February 26, 2010, 09:54:52 am
Xavier... is this available for CiviCRM 3.0 or only 3.1? It sounds like this link would be placed on the user contribution dashboard right?... how can I test this out?

Lobo, since we would like the contributor to get the pdf automatically I would really prefer the pdf attachment option... I will research this a little more since I don't even know how to render an email as a pdf.

Andres





Andres

Open Source is Green

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: PDF Form on a custom Template
February 26, 2010, 10:24:37 am

check:

CRM/Contribute/Form/Task/PDF.php and CRM/Utils/PDF/Utils.php. There are some helper function there. In 3.1 you can implement the

http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+hook+specification#CiviCRMhookspecification-hookcivicrmalterMailParams

and do the attachment in that hook and generate the PDF from the text or html passed in.

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • PDF Form on a custom Template

This forum was archived on 2017-11-26.