Forums

Print automatically

vismay 26 Mar, 2013
Hi,

I've read your clear FAQ about how to add a print button and it works.
But I would like to ask you if its' possible to automatically print after a submit button:

scenario:

user fills a form;
he lands in a page where he can check all entries;
he can submit the form;
from here should print automatically a new formatted custom code (on submit), without land in a new page with print button and the print.

Possible

THanks
Matteo
vismay 27 Mar, 2013
Sob... the last step of my form...help me!!!!!
GreyHead 27 Mar, 2013
Hi Vismay,

I don't know if that is possible :-( Have you found anything that shows how to do it from JavaScript?

Bob
vismay 28 Mar, 2013
Alternative is to submit the form and the guest will receive a mail with the confirmation and the result as attachment, better in .pdf, then he can print it by himself.

Basically with this function:

<?php
$doc =& JFactory::getDocument();
$script = "
function printPage()
{
    var html, css, csss_file, printWin;
    css = \"\";
    css = \"<style type='text/css'>\"+css+\"</style>\";
    css_url = '';
    if ( css_url !== '' ) {
        css_url = \"<link rel='stylesheet' type='text/css' href='\"+css_url+\"' media='print' />\";
    }
    html = '<html><head>'+css+css_url+'</head>'+$(id).innerHTML+'</html>';

    printWin = window.open('', '', 'left=100, top=100, width=900, toolbar=0, scrollbars=0, status=0' );
    printWin.document.write(html);
    printWin.document.close();
    printWin.focus();
    printWin.print();
    printWin.close();
}
var id;
window.addEvent('domready', function() {
    id = 'print_div';
    $('print_button').setStyle('visibility', 'visible');
    $('print_button').addEvent('click', printPage);
});
";
$doc->addScriptDeclaration($script);
?>


I let print this result:

<div id='print_div'>

"HTML/PHP page"

</div>
<input type="button" value="Print" id='print_button' style='visibility: hidden;'></input>



Ho can I attach this html/PHP page to an email? Better in .pdf?

Thanks!!!!!
Matteo
GreyHead 28 Mar, 2013
Hi vismay,

You can create a PDF from your form results, Max has a beta version of a TCPDF action for ChronoForms that will do this. It takes a little work to format the PDF but works OK.

Then I think this FAQ has a method for attaching the file. If not then please ask back here.

Bob
vismay 29 Mar, 2013
Tranks, i've asked Max via contatta form about it.
If I chiose the www to attach the created HTML to the email Renault, how can I save it to the server?

Matteo
GreyHead 29 Mar, 2013
Hi Matteo,

I'm sorry I don't understand your question :-(

Bob
vismay 29 Mar, 2013
sorry, some type error!!!

I've got the tcpdf from max, I mannage to save nad print the pdf, but after this action doesn't go further to email action, it just stop there without submission, even if I put the email action before tcpdf.

Any Idea?

Matteo
GreyHead 30 Mar, 2013
HI Matteo,

Then there is probably an error in the code that you are using to create the PDF. TCPDF can't accept all HTML code, so you may need to build up the PDF piece by piece and check the TCPDF documents.

Bob
This topic is locked and no more replies can be posted.