We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • Last Of The Romans Reply #41, 14 years ago
    Quote from: microcipcip at Apr 29, 2010, 01:59 AM

    Thanks so much Bruno, now it works!

    Here is my snippet and the link if somebody needs it

    The Snippet
    <?php
    //collect here your output in $output, use $modx->runsnippet or what else for generating your html-output.
    
    $doc['content']='<p>no docid was given to generate pdf-content</p>';
    if (isset($_GET['docid'])){
    $id=$modx->db->escape($_GET['docid']);
    $doc = $modx->getPageInfo($id,1,'content'); 
    $title = $modx->getPageInfo($id,1,'longtitle'); 
    
    }
    $output = "<h1>".$title['longtitle']."</h1><br/>".$doc['content']; 
    
    $basePath = $modx->config['base_path'];
    $pluginpath = $basePath.'assets/classes/tcpdf/';
    
    if ($_GET['contentType']=='pdf'){
    include $pluginpath.'examples/myexample.php';
    }
    else{
    	return $output;
    }
    ?>
    


    The Link:
    <a href="[~34~]&contentType=pdf&docid=[*id*]" target="_blank">DOWNLOAD PDF</a>

    (34 is the resource with the [!tcpdf!] call)

    I have noticed that when I save the PDF in the computer the PDF name is always the URL alias of page ID 34.
    I think that line 5918 in tcpdf.php is responsible for this. I will post here the solution if I find one.
    header('Content-Disposition: attachment; filename="'.basename($name).'";');




    no docid was given to generate pdf-content

    my modx is: 0.9.6.2
    PHP Version 5.1.6
    mysql: 5.0.77
      palma non sine pulvere
      • 4172
      • 5,888 Posts
      you need a link like that on your source-page:

      <a href="[~34~]&contentType=pdf&docid=[*id*]" target="_blank">DOWNLOAD PDF</a> 

        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
      • Last Of The Romans Reply #43, 14 years ago
        Quote from: Bruno17 at Apr 29, 2010, 08:06 AM

        you need a link like that on your source-page:

        <a href="[~34~]&contentType=pdf&docid=[*id*]" target="_blank">DOWNLOAD PDF</a> 



        <a href="[~479~]&contentType=pdf&docid=[*id*]"><img class="pdf" src="[(site_url)]assets/templates/newdentalstudio/images/pdf.jpg" width="30" height="30" /></a>
          palma non sine pulvere
          • 19369
          • 1,098 Posts
          Where is your link? In a chunk?
          <a href="[~479~]&contentType=pdf&docid=[*id*]"><img class="pdf" src="[(site_url)]assets/templates/newdentalstudio/images/pdf.jpg" width="30" height="30" /></a>


          I have it directly in the template and it is working fine. I have MODx 1.3 though
          • Last Of The Romans Reply #45, 14 years ago
            Quote from: microcipcip at Apr 29, 2010, 02:55 PM

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


            I have it directly in the template and it is working fine. I have MODx 1.3 though

            i try twice:
            in chunk and in template....no results

            in attachment see status bar of my browser
              palma non sine pulvere
              • 19369
              • 1,098 Posts
              I guess that the PDF converter is not compatible with MODx v0.9
                • 4172
                • 5,888 Posts
                what do you get with this code in your snippet?

                <?php
                //collect here your output in $output, use $modx->runsnippet or what else for generating your html-output.
                
                return '<pre>'.print_r($_GET,true).'</pre>';
                
                $doc['content']='<p>no docid was given to generate pdf-content</p>';
                if (isset($_GET['docid'])){
                $id=$modx->db->escape($_GET['docid']);
                $doc = $modx->getPageInfo($id,1,'content'); 
                $title = $modx->getPageInfo($id,1,'longtitle'); 
                
                }
                $output = "<h1>".$title['longtitle']."</h1><br/>".$doc['content']; 
                
                $basePath = $modx->config['base_path'];
                $pluginpath = $basePath.'assets/classes/tcpdf/';
                
                if ($_GET['contentType']=='pdf'){
                include $pluginpath.'examples/myexample.php';
                }
                else{
                	return $output;
                }
                ?>
                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!
                • Last Of The Romans Reply #48, 14 years ago
                  Hello Bruno,

                  when i use your code i get:

                  Array
                  (
                      [q] => pdfgenerator.html
                  )
                  


                    palma non sine pulvere
                    • 4172
                    • 5,888 Posts
                    may be it has todo with your rewrite-rules?
                      -------------------------------

                      you can buy me a beer, if you like MIGX

                      http://webcmsolutions.de/migx.html

                      Thanks!
                    • Last Of The Romans Reply #50, 14 years ago
                      Quote from: Bruno17 at Apr 30, 2010, 08:42 AM

                      may be it has todo with your rewrite-rules?
                      # For full documentation and other suggested options, please see
                      # http://svn.modxcms.com/docs/display/MODx096/Friendly+URL+Solutions
                      # including for unexpected logouts in multi-server/cloud environments
                      
                      Options +FollowSymLinks 
                      RewriteEngine on 
                      RewriteCond %{HTTP_HOST} ^dental-bg.com [NC] 
                      RewriteRule ^(.*)$ http://www.dental-bg.com/$1 [L,R=301]
                      
                      
                      Options +FollowSymlinks
                      RewriteEngine On
                      RewriteBase /
                      
                      # Fix Apache internal dummy connections from breaking [(site_url)] cache
                      RewriteCond %{HTTP_USER_AGENT} ^.*internal\ dummy\ connection.*$ [NC]
                      RewriteRule .* - [F,L]
                      
                      # Rewrite domain.com -> www.domain.com -- used with SEO Strict URLs plugin
                      #RewriteCond %{HTTP_HOST} .
                      #RewriteCond %{HTTP_HOST} !^example\.com [NC]
                      #RewriteRule (.*) http://example.com/$1 [R=301,L]
                      
                      # Exclude /assets and /manager directories from rewrite rules
                      RewriteRule ^(manager|assets) - [L]
                      
                      # For Friendly URLs
                      RewriteCond %{REQUEST_FILENAME} !-f
                      RewriteCond %{REQUEST_FILENAME} !-d
                      RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
                      
                      # Reduce server overhead by enabling output compression if supported.
                      #php_flag zlib.output_compression On
                      #php_value zlib.output_compression_level 5
                      



                      that is my .htaccess
                        palma non sine pulvere