WordPress.org

Forums

WP Post to PDF
[resolved] WP Post to PDF and Custom Fields (5 posts)

  1. wordpresschef
    Member
    Posted 2 years ago #

    Hi,

    I'm usign your plugin and I'd like to know how to display in pdf the content of a series of custom fields (I'm using Types&Views to generate them).

    Also, is there a way to customize the informations and the content displayed in the generated pdf?

    Thank you.

    Dimitri

    http://wordpress.org/extend/plugins/wp-post-to-pdf/

  2. Neerav Dobaria
    Member
    Plugin Author

    Posted 2 years ago #

    You need to dig into code to do that, the file you should check is 'wp-post-to-pdf.php' in WP Post to PDF plugin directory.

  3. Johan van der Wijk
    Member
    Posted 2 years ago #

    @Dimitri Did you manage to display the custom field values in the PDF?

  4. Sadi
    Member
    Posted 2 years ago #

    I defined 2 filters in my theme's functions.php

    //PDF - GENERATION FILTERS
    
    function wp_post_to_pdf_content_prepend($content, $post_id){
        $post = get_post($post_id);
        $new_content = ....;
    
        // -- FOR TYPES & VIEWS
        // $new_content = types_render_field('price', array()); //get price custom field for $post
    
        return $new_content . $content;
    }
    
    function wp_post_to_pdf_content_append($content, $post_id){
        $post = get_post($post_id);
        $new_content = ...
    
        return $content . $new_content;
    }
    
    add_filter( 'wp_post_to_pdf_content_prepend', 'wp_post_to_pdf_content_prepend', 10, 2);
    add_filter( 'wp_post_to_pdf_content_append', 'wp_post_to_pdf_content_append', 10, 2);

    I added following code in generate_pdf_file($id, $forceDownload = false) function of wp-post-to-pdf.php file before calling of $pdf->SetCreator

    $post->post_content = apply_filters('wp_post_to_pdf_content_prepend', $post->post_content, $post->ID);
    
    $post->post_content = apply_filters('wp_post_to_pdf_content_append', $post->post_content, $post->ID);

    Let me know if it works for you or any better way you know.

    Thanks

  5. jennybeaumont
    Member
    Posted 1 year ago #

    Am interested in this too. I'm also using Types, and although I'm able to add custom fields to wp-post-to-pdf.php, whenever I need to use the call types_render_field, my PDF is fine, but I'm no longer able to edit Posts - returns a blank screen and changes aren't saved.

    Thoughts and/or ideas ?
    best,
    -jennyb

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic