I need a way to dynamicly generate a pdf from the currently opened coldfusion document. But I don't have an idea how to handle this because I didn't find a way i.e. to pass the current (html) text to a function which generates the pdf by using the cfdocument tag.

This will look for the presence of a URL parameter named "showAsPDF". When it is defined and set to "true", then this code will take over and run the same request internally, routed through a call to cfdocument. The response will then be output as a PDF document.