Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // pon esto en el template que desees o en tu archivo .js
- <script type="text/javascript">
- $().ready(function() {
- $('#pdf').click(function() {
- var f = document.createElement('form');
- f.style.display = 'none';
- this.parentNode.appendChild(f);
- f.method = 'post';
- f.action = '<?php echo url_for('asociado/Pdf')?>';
- var m = document.createElement('input');
- m.setAttribute('type', 'hidden');
- m.setAttribute('name', 'html');
- m.setAttribute('value', $('#job').html());
- f.appendChild(m);
- f.submit();
- return false;
- });
- });
- </script>
- // ubica esto en el html de tu template
- <div class="pdf">
- <a id="pdf" href="#">PDF</a>
- </div>
- // este método se agrega a la clase action
- /**
- * Esta acción se encarga de la creación de el PDF
- */
- public function executePdf(sfWebRequest $request)
- {
- $html = $request->getPostParameter('html');
- $mpdf = new mPDF('es_ES','Letter','','',32,25,27,25,16,13);
- $mpdf->useOnlyCoreFonts = true;
- // load a stylesheet
- $stylesheet = file_get_contents(sfConfig::get('sf_web_dir').'/css/mypdf.css');
- $mpdf->WriteHTML($stylesheet,1); // el parámetro le dice que sólo es css y no contenido html
- $mpdf->WriteHTML($html,2);
- $mpdf->Output('mpdf.pdf','D');
- throw new sfStopException();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement