Get results from the main wp_query

It looks like you’re calling preparePDF( $wp_query ) inside your callback, but $wp_query isn’t defined and the global $wp_query shouldn’t be accessible there without global $wp_query.

Try instead preparePDF( $query ) and use wp_reset_postsdata() to restore the global $post object.

Another important thing is that you must run your preparePDF() function after WP_Query has fetched the posts from the database. So don’t use the pre_get_posts hook, use a later hook instead. But that hook depends on what you want to do with the posts. I also don’t understand what you’re preparing with your preparePDF() function.

Remember to use WP_DEBUG on your dev install, to catch any PHP errors, warnings and notices. Check for example the Debugging in WordPress in the Codex.