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).'";');