Posted by jonlar on December 9, 2012 at 11:05pm
Hi,
I'm working on a site that is supporting centers that sell a service with a guaranty. A guaranty certificate will be sold through the store I'm setting up, but I've not found a module that fits my needs.
When purchasing this certificate, the service center must supply a name and a serial number to the be printed on the certificate. The certificate must also contain the name of the center buying it/supplying the service. This then has to be delivered as an electronic download (pdf) that can be printed out at the location and given to the client.
I would be glad to hear any suggestions on modules or ways to get this implemented.
rgrds Jon
Comments
Solution?
I have a similar application where I need to produce a serialized PDF certificate for users. Did you ever find a solution/recipe for this?
Did something similar
Hey guys,
I recently developed a solution similar to this. This was a site that sells "recommendation letters". When the user purchases a dynamic PDF is generated with specific content from the users profile (this can pretty easily be retrofitted for a serial number), graphics are merged in, and the PDF is emailed to the customer.
I accomplished this by leveraging the FPDF module / library (https://www.drupal.org/project/fpdf) and a custom form. The meat of the solution revolves around leveraging the FPDF API to create the PDF.
The code is pretty application specific but could probably be generalized into a formal commerce component.
Let me know if you have any other questions.
Thanks
Nick
Your code for FPDF
Hi Nick,
Did you mod the module or write your own? Can you share?
Thx
I wrote my own module to
I wrote my own module to handle this. Basically just a form. In the submit handler I have something like this:
//create a new PDF with FPDF
$pdf=new FPDF();
$pdf->AddPage();
$pdf->Image($_SERVER['DOCUMENT_ROOT']."/sites/default/files/pdf/header.png",5,4,205);
$pdf->SetFont('Times','',11);
$pdf->SetXY(15,50);
$pdf->SetMargins(15,15,15);
$pdf->Write(4,$l_sAddress);
$pdf->SetFont('Times','',11);
$pdf->SetX(15);
$pdf->SetMargins(15,15,15);
$pdf->Write(4,$l_sBody);
//premium are actually signed, standard are not.
if($form_state['values']['type'] == "premium"){
$pdf->SetY($pdf->GetY()+20);
$pdf->Write(4,$l_sSigned);
} else {
$pdf->Image($_SERVER['DOCUMENT_ROOT']."/sites/default/files/pdf/owner_sig.png",$pdf->GetX(),$pdf->GetY(),61,20);
$pdf->SetY($pdf->GetY()+20);
$pdf->Write(4,$l_sSigned);
}
$pdf_generated = $pdf->Output("test","S");
$l_filename = $user->uid."".date("YmdGhis").".pdf";
$l_sTempFileName = $_SERVER['DOCUMENT_ROOT']."/sites/default/files/rec_letters/". $l_filename;
$l_xTempFile = fopen($l_sTempFileName, "w");
fwrite($l_xTempFile, $pdf_generated);
fclose($l_xTempFile);
$file_content = file_get_contents($l_sTempFileName);
$attachment = array(
'filecontent' => $file_content,
'filename' => "Recommendation_Letter.pdf",
'filemime' => 'application/pdf',
'filepath' => $l_sTempFileName,
);
$params = array(
'body' => $l_sEmailHtml,
'subject' => "Your Recommendation Letter",
'attachment' => $attachment,
);
//see if we are premium
if($form_state['values']['type'] == "premium") {
//process premium transaction.
myfeature_commerce_process_premium($form_state, $params, $u);
return;
}
else {
drupal_mail('my_messages', 'generic_message', $u->mail->value(), language_default(), $params, "info@mydomain.org", TRUE);
}
Hope that helps. Really just an implementation of FPDF. The myfeature_commerce_process_premium function takes CC values and processes a Commerce payment.
Thanks.
Nick
views_pdf and views_pdf_mimemail
Anyone of you ever tried views_pdf and views_pdf_mimemail?