question about modification to PDF Plugin

15 posts by 5 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: March 7, 2011   (RSS)

By Toledoh - March 6, 2011 - edited: March 6, 2011

OK Guys,

I'm finally getting into gear and trying to do this... if it's too much, let me know and I'll send it through to consulting...

I've got the PDF plugin installed.

I've got this in the intial code;

// PDF VIA EMAIL
createPDF_fromOutput('attachment', 'example.pdf');

sendMessage(array(
'from' => "tim@forrest.id.au",
'to' => "tim@toledoh.com.au",
'subject' => "test pdf",
'text' => "Text message content",
'attachments' => 'example.pdf'
)
));


and I have this in the body;
<form id='tellafriend_form' method="post" action="">
<input type="hidden" name="submit" value="1" />
<label for="from">Your Email: </label>
<input class="std_input" type="text" id="from" name="from"
size="40" maxlength="35" value="" />

<label for="name">Your Name: </label>
<input class="std_input" type="text" id="name" name="name"
size="40" maxlength="35" value="" />

<label for="to">To: </label>
<input class="std_input" type="text" id="to" name="to"
size="40" maxlength="35" />

<label for="subject">Subject: </label>
<input class="std_input" type="text" id="subject"
name="subject" size="40" value="Blake Machinery Group: <?php echo $productsRecord['type:label'] ?>" />

<label for="message">Message: </label>
<textarea id="message" name="message" readonly="readonly"
rows="18" cols="40">Check out the <?php echo $productsRecord['type:label'] ?> <?php echo $productsRecord['sub_type:label'] ?>
</textarea>

<input type="submit" name="submit" class="form_but"
value="Submit"/>
</form>


Any ideas on where I should focus my attention? I need to replace the email adresses in the first bit to replicate whta is submitted in the form, and then actually send the form... and attach the PDF... so basically i've done nothing :)
Cheers,

Tim (toledoh.com.au)

Re: [Toledoh] question about modification to PDF Plugin

By Jason - March 7, 2011

Hi Tim,

A good place to start is to first get the form sending emails without the attachment. for example:

sendMessage(array(
'from' => @$_REQUEST['from'],
'to' => @$_REQUEST['to'],
'subject' => @$_REQUEST['subject'],
'text' => @$_REQUEST['message'],

)
));


Once you get this working, then try attaching the PDF. Here's a post that gives an example of sending a CSV file as an attachment:
http://www.interactivetools.com/forum/gforum.cgi?post=85097#85097

Hope this helps get you started.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] question about modification to PDF Plugin

By Toledoh - March 7, 2011

Hey Jason,

I'm so dang close, but yet so far. The code below works in that it takes the form data, sends the email and attaches the pdf - however, after clicking submit the browser trys to "Display" and the PDF that comes via email has errors (not properly decoded)...

(BTW: I changed "from, to, subject, message" to "a,b,c,d" because one of those fields is a reserved field or some such thing and was giving me errors)

// PDF VIA EMAIL
$pdf = '';
$url = "http://www.google.com/";
$data = createPDF_fromUrl($url);
createPDF_display('attachment', $data, 'example.pdf');


sendMessage(array(
'from' => @$_REQUEST['a'],
'to' => @$_REQUEST['b'],
'subject' => @$_REQUEST['c'],
'text' => @$_REQUEST['d'],
'attachments' => array(
'example.pdf' => $pdf
)
));

Cheers,

Tim (toledoh.com.au)

Re: [Toledoh] question about modification to PDF Plugin

By Dave - March 7, 2011

Hi Tim,

Try these changes:

// PDF VIA EMAIL
$pdf = '';
$url = "http://www.google.com/";
$data = createPDF_fromUrl($url);
//createPDF_display('attachment', $data, 'example.pdf');


sendMessage(array(
'from' => @$_REQUEST['a'],
'to' => @$_REQUEST['b'],
'subject' => @$_REQUEST['c'],
'text' => @$_REQUEST['d'],
'attachments' => array(
'example.pdf' => $data,
)
));


Let me know if that works for you.
Dave Edis - Senior Developer
interactivetools.com