Can't attach PDF created with PHP form plugin to email plugin

mvr10

New Member
I have created a PDF with the PHP form plugin and I know where it's stored,
PHP:
$pdf->Output($_SERVER['DOCUMENT_ROOT'] . '{tablename___elementname}.pdf', 'F');
but when I try to send it through the email plugin ("attachment eval. function"),
PHP:
$file[] = 'http://mywebsite.com/{tablename___elementname}.pdf';
  return $file;
I don't receive it — only the content of the email per se (what I have written on "message text":
HTML:
<p style="text-align: center;"><span style="font-size: 18pt;"><strong>Title</strong></span></p>
<p style="text-align: center;"><span style="font-size: 18pt;"><strong>Subtitle</strong></span></p>
<p style="text-align: right;">{mysql_date}</p>
<p> </p>
<p>Body text</p>
<p><span style="text-decoration: underline;"><strong>Placeholder:</strong></span>: {tablename___elementname}</p>
<p> </p>
). It may be caused by the email plugin, because it sends the email right away and PDF it's not created yet, but I'm a newbie speculating, so... (I don't know what's really happening :).)

Thanks in advance.

PD: PDF only gives numeric characters on placeholders, like it's using the raw version ({tablename___elementname_raw}) of it automatically, and I can't change it.
PD2: as always, I'm gonna attach the PHP I've used, in case you need it.




PHP:
require_once('libraries/tcpdf/tcpdf.php');

$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
  $pdf->SetAuthor('Author');
  $pdf->SetTitle('Title with placeholder {tablename___elementname}');
  $pdf->SetSubject('Subject');
  $pdf->SetHeaderData(PDF_HEADER_TITLE.' Header Title', PDF_HEADER_STRING, array(0,64,255), array(0,64,128));
  $pdf->setFooterData(array(0,64,0), array(0,64,128));
  $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
  $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
  $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
  $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
  $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
  $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
  $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
  $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
  $pdf->setFontSubsetting(true);
  $pdf->SetFont('helvetica', '', 12, '', true);
  $pdf->AddPage();
$html = <<<EOD
  <p style="text-align: center;"><span style="font-size: 18pt;"><strong>Body text</strong></span></p>
<p><span style="text-decoration: underline;"><strong>Placeholder</strong></span>: {tablename___elementname}</p>
<p><span style="text-decoration: underline;"><strong>Apellidos</strong></span>: {autorizacion_dispositivo___apellidos}</p>
<p><span style="text-decoration: underline;"><strong>Dispositivos</strong></span>: {autorizacion_dispositivo_7_repeat___dispositivo}</p>
<p><span style="text-decoration: underline;"><strong>Signature</strong></span>: <img src="http://www.mywebsite.com/index.php?option=com_fabrik\&amp;task=plugin.pluginAjax\&amp;plugin=digsig\&amp;method=ajax_signature_to_image\&amp;format=raw\&amp;element_id=35\&amp;formid=5\&amp;rowid={elementname___tablename}\&amp;repeatcount=0" alt="" width="400" height="250" /></p>
<p> </p>
EOD;
$pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);
$pdf->Output($_SERVER['DOCUMENT_ROOT'] . '{tablename___elementname}.pdf', 'F');
 
Last edited:
Does it attach an already existing PDF?
if yes:
Does it attach if you are creating ( and attaching) a PDF with a hardcoded name?
Is the PDF created with the placeholder name as expected?

Gesendet von meinem SM-G930F mit Tapatalk
 
Hello Troester,
Thanks for answering.
First of all, my idea was to create a PDF of a form, store it on my website and attach it to email through both PHP form and email plugins.
As for the first question, yes: it attaches an already existing PDF. As for the second one, no, I receive the next error:
TCPDF ERROR: Unable to create output file (and then here it shows me the full path I've chosen to save the PDF).
The code I use in order to do this is the following:
PHP:
$filename = "{tablename_7_repeat___elementname}.pdf";
$filelocation = "http://www.mywebsite.com/authorizations";
$fileNL = $filelocation. "/" . $filename;
$pdf->Output($fileNL, 'F');
And as for the last question, as I said, the code kind of uses the raw version of the placeholder, or the row ID, I don't know (in fact, I use the same placeholder on the "message content" of the email plugin and I have no problem, the text I want to use appears as expected), so if the PDF name I want is "authorization_john.pdf" it shows "authorization_2.pdf" (and the same happens with placeholders in the PDF).

I look forward to your reply.
 
Last edited:
For the 2nd question:
Did you try to create (and attach) a hardcoded filename like abc.pdf (without Fabrik placeholder)?
Is such a file a) created? b) attached?
 
Well, I've changed the code and this error appears, as soon as I try going into the page:
TCPDF ERROR: Unable to create output file: http://www.mywebsite.com/authorizations/abc_001.pdf
PHP code runs after the end of the form (getEndContent). The only way that works it's letting the program saving the file into wherever it wants (with "$_SERVER['DOCUMENT_ROOT']"), and yet I can't attach it. What do I do?

Thanks
 
Last edited:
This is no Fabrik stuff.
But I think to write a file you can't use a URL but you must use a path, something like
JPATH_ROOT . 'your_dir' . 'your-filename'
 
Note that I'm planning to add this as a built in feature for PDF's in the email plugin, so you can specify an upload element on the form, and the email plugin will save a copy of the form's PDF in the folder that upload element points at, and insert the new PDF's file path in the upload element's data.

But I can't guarrantee when this will be done.

-- hugh
 
I have 3 or 4 people who want this, so it's high on my list. Unfortunately, so far I don't have anyone who wants it badly enough to fund the work, so my paying work is higher on the list. But I hope I'll have so "spare" time soon, maybe this week or next week, to get it done.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top