We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4172
    • 5,888 Posts
    try:
    <a href="[~479~]?contentType=pdf&docid=[*id*]"><img class="pdf" src="[(site_url)]assets/templates/newdentalstudio/images/pdf.jpg" width="30" height="30" /></a>
      -------------------------------

      you can buy me a beer, if you like MIGX

      http://webcmsolutions.de/migx.html

      Thanks!
    • Last Of The Romans Reply #52, 14 years ago
      Quote from: Bruno17 at Apr 30, 2010, 09:40 AM

      try:
      <a href="[~479~]?contentType=pdf&docid=[*id*]"><img class="pdf" src="[(site_url)]assets/templates/newdentalstudio/images/pdf.jpg" width="30" height="30" /></a>

      wow, i have something new....
      now i get Adobe Error...see:
        palma non sine pulvere
        • 4172
        • 5,888 Posts
        now you have to remove this line in your snippet:

        return '<pre>'.print_r($_GET,true).'</pre>';
          -------------------------------

          you can buy me a beer, if you like MIGX

          http://webcmsolutions.de/migx.html

          Thanks!
        • Last Of The Romans Reply #54, 14 years ago
          Quote from: Bruno17 at Apr 30, 2010, 09:52 AM

          now you have to remove this line in your snippet:

          return '<pre>'.print_r($_GET,true).'</pre>';


          yes, now work perfect....BUT i have last request, now i get:
          ?????? ? ???????? ?? ????????????
          ???????????? ?? ??????
          ???????????? ?? ??????? ? ????????????? ?? ???? ???-????? ????????? ?????????? ?????????? ? ? ???????? ??
          ????? ????????????? ? ????? ??????? ?? ??????. ????? ????????? ?????? ?? ???????
          

          link: http://www.dental-bg.com/pdfgenerator.html?contentType=pdf&docid=70

          i check everywhere and everywhere is UTF8 see img.
          Can you (last time, promise) HELP me to get correct Cyrillic

          Thanks
            palma non sine pulvere
            • 4172
            • 5,888 Posts
              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
            • Last Of The Romans Reply #56, 14 years ago
              Quote from: Bruno17 at Apr 30, 2010, 11:18 AM

              perhaps here’s also some info for you:

              http://sourceforge.net/projects/tcpdf/forums/forum/435311/topic/3527236/index/page/1

              Hallelujah,

              arialunicid0

              that is the Font
                palma non sine pulvere
                • 31381
                • 31 Posts
                Hi,

                I tried to run that on my installation too - doesn’t work propperly.
                The PlugIn don’t work at all, it seems - and I’m not able to get contents of the document that should become a PDF - but I can write text directly to the $output in the Snippet.

                I will try it again tomorrow - but I have a suggestion:

                Wouldn’t it be possible to put all together in a plugin?

                So if someone calls [~[*id*]~]?type=pdf (or something) the PDF will be generated.

                The PlugIn has to check for that GET parameter (like the one used her), put the contentType to PDF and send the content of [*content*], [*pagetitle*] etc. to the tcpdf-script. The output of the tcpdf-script will the replace the original content of the ressource.

                -> no need of an additional template, ressource and snippet - only one plugin that will easily be installed.

                Would that be possible?!

                please excuse my poor English...
                  • 19369
                  • 1,098 Posts
                  If you have a problem try to post here the code
                    • 31381
                    • 31 Posts
                    ok, i try

                    lets start with:
                    I use MODx 1.0.3
                    my PDF document is 441

                    I have chosen to put the [!tcpd!] in blank template - the PDF document (441) is empty.

                    I don’t use the "contentType" Plugin any more, because Evolution has the option to select contentType PDF on each Document.

                    The Snippet is:
                    <?php
                    //collect here your output in $output, use $modx->runsnippet or what else for generating your html-output.
                    
                    $docid = $_REQUEST['docid'];
                    
                    $table = $modx->getFullTableName("site_content");
                    $pagetitle = $modx->db->getValue( $modx->db->select("longtitle", $table, 'id='.$docid,"",""));
                    $longtitle = $modx->db->getValue( $modx->db->select("longtitle", $table, 'id='.$docid,"",""));
                    $introtext = $modx->db->getValue( $modx->db->select("introtext", $table, 'id='.$docid,"",""));
                    $content = $modx->db->getValue( $modx->db->select("content", $table, 'id='.$docid,"",""));
                    
                    $output = '<h1>'.$pagetitle.'</h1><h2>'.$longtitle.'</h2>'.$content; 
                    
                    $basePath = $modx->config['base_path'];
                    $pluginpath = $basePath.'assets/classes/tcpdf/';
                    
                    if ($_GET['contentType']=='pdf'){
                    include $pluginpath.'examples/myexample.php';
                    }
                    else{
                    	return $output;
                    }
                    ?>




                    myexample.php is:

                    <?php
                    //============================================================+
                    // File name   : example_001.php
                    // Begin       : 2008-03-04
                    // Last Update : 2009-03-18
                    // 
                    // Description : Example 001 for TCPDF class
                    //               Default Header and Footer
                    // 
                    // Author: Nicola Asuni
                    // 
                    // (c) Copyright:
                    //               Nicola Asuni
                    //               Tecnick.com s.r.l.
                    //               Via Della Pace, 11
                    //               09044 Quartucciu (CA)
                    //               ITALY
                    //               www.tecnick.com
                    //               [email protected]
                    //============================================================+
                    
                    /**
                     * Creates an example PDF TEST document using TCPDF
                     * @package com.tecnick.tcpdf
                     * @abstract TCPDF - Example: Default Header and Footer
                     * @author Nicola Asuni
                     * @copyright 2004-2009 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - [email protected]
                     * @link http://tcpdf.org
                     * @license http://www.gnu.org/copyleft/lesser.html LGPL
                     * @since 2008-03-04
                     */
                    //(dirname( __FILE__ )."/../../rennergebnis/includes/getdatas.php");
                    require_once(dirname( __FILE__ ).'/../config/lang/ger.php');
                    require_once(dirname( __FILE__ ).'/../tcpdf.php');
                    
                    // create new PDF document
                    //$pdf = new BLOCKPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); 
                    
                    $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); 
                    
                    // set document information
                    $pdf->SetCreator(PDF_CREATOR);
                    $pdf->SetAuthor('Nicola Asuni');
                    $pdf->SetTitle('TCPDF Example 001');
                    $pdf->SetSubject('TCPDF Tutorial');
                    $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
                    
                    // set default header data
                    $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
                    
                    // set header and footer fonts
                    $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
                    $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
                    
                    // set default monospaced font
                    $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
                    
                    
                    //set margins
                    $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
                    $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
                    $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
                    
                    //set auto page breaks
                    $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
                    
                    //set image scale factor
                    $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); 
                    
                    //set some language-dependent strings
                    $pdf->setLanguageArray($l); 
                    
                    $pdf->SetFont('helvetica', '', 9); 
                    
                    
                    // add a page
                    $pdf->AddPage();
                    
                    
                    $pdf->writeHTML($output);
                    
                    // ---------------------------------------------------------
                    
                    //Close and output PDF document 
                    $pdf->Output('myexample.pdf', 'I');
                    if(isset($_GET['savepdf'])){
                    $pdf->Output($modx->config['base_path']."assets/files/pdfdownloads/".$_GET['savepdf'].".pdf", "F"); 	
                    }
                    
                    
                    //============================================================+
                    // END OF FILE                                                 
                    //============================================================+
                    ?>



                    this do work:

                    • creating PDFs if $output gets plain text (changed the snippets to get this happen)
                    • without correct docid it creates an empty PDF

                    this don’t work:

                    • getting content, title and so on in the PDF

                    this would be perfect:

                    • don’t need an extra template and document and run the hole thing by placing an chunk in a document.
                    • have a snippet with individual text (should be easily made with $text=`download as PDF` or something - i think I will try this after everything works)


                    • a plugin to auto-create new PDFs of a document after saving a document so that they will be saved in a folder and won’t be create each time someone would like ti download

                    thank you for help
                      • 31381
                      • 31 Posts
                      any ideas?