automatic PDF invoice with FPDF in PHP (creating Plugin)

You need to load WordPress before using wp functions, use this just after the <?php tag:
require( '<<DIR>>/wp-load.php' );

where <<DIR>> is the path to the main wordpress folder (in your case something like ../../../, add double dots as needed to navigate up the plugins and wp-content hierarchy

NOTE: direct linking outside you control zone (i.e. you plugin directory) is not the best thing to do, as it might break in the future. What can you do is write the code in the plugin file(s), wrap it in a function and hook it to a wordpress action (like an ajax form action, see here )