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).'";');
<a href="[~34~]&contentType=pdf&docid=[*id*]" target="_blank">DOWNLOAD PDF</a>
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>
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
<?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;
}
?>Array
(
[q] => pdfgenerator.html
)
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