• Resolved Rafa?

    (@ayek)


    \estatik\classes\class-property-pdf.php (PRO v. 3.11.14)
    line:90
    $this->_tcpdf->stream( 'property'.pdf', array( 'Attachment' => 0 ) );

    Have changed to:
    $this->_tcpdf->stream( 'broker-name--property-id-'.get_the_ID().'.pdf', array( 'Attachment' => 0 ) );

    Instead property.pdf
    i can download broker-name--property-id-1234.pdf

    How to apply this modification safely in my functions.php?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Estatik

    (@estatik)

    Hi,
    You need to extend class Es_Property_Pdf and override output method. Change your pdf name there.
    Then add this code in function.php of your child theme.

    global $es_single_page_instance;
    
    remove_action( 'wp', array( $es_single_page_instance, 'property_single_pdf' ) );
    
    add_action( 'wp', 'my_pdf_output_action' );
    
    function my_pdf_output_action() {
       $post_id = filter_input( INPUT_GET, 'es-pdf', FILTER_VALIDATE_INT );
       global $post;
       if ( $post_id && ( $post = get_post( $post_id ) ) ) {
          if ( $post->post_type == Es_Property::get_post_type_name() ) {
             setup_postdata( $post );
             global $es_property;
    
             $es_property = es_get_property( $post_id );
    
             include( ES_PLUGIN_PATH . ES_DS . 'classes' . ES_DS . 'class-property-pdf.php' );
             $pdf = new My_Extended_Pdf_Class( $post ); // Extended class of Es_Property_PDF
             $pdf->output();
             die;
          }
       }
    }

    My_Extended_Pdf_Class is your extended class

    Hope it will help.

    Thread Starter Rafa?

    (@ayek)

    Thank you are trying to help me.
    It isn’t clear for me, because I’m not a PHP programmer. Could you guide me further, please?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to customize PDF file name’ is closed to new replies.