• I’m searched mPDF for ways to open the pdf to a new tab and cannot find it. Is it possible? BTW, awesome plugin!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author David Jensen

    (@dkjensen)

    You can use this code to open instead of save

    function child_theme_wc_cart_pdf_destination( $dest ) {
        if ( class_exists( '\Mpdf\Output\Destination' ) ) {
            $dest = \Mpdf\Output\Destination::INLINE;
        }
    
        return $dest;
    }
    add_filter( 'wc_cart_pdf_destination', 'child_theme_wc_cart_pdf_destination' );
    Thread Starter ronr1999

    (@ronr1999)

    Sorry that’s not the question. I have it set to INLINE but it does not open in a new tab… like target=”_blank”.

    Plugin Author David Jensen

    (@dkjensen)

    Did you change the button that triggers the PDF? By default it does open in new tab. Here is the code that renders the button which includes target=”_blank”

    
    function wc_cart_pdf_button() {
    	if ( ! is_cart() || WC()->cart->is_empty() ) {
    		return;
    	}
    
    	?>
    
    	<a href="<?php echo esc_url( wp_nonce_url( add_query_arg( array( 'cart-pdf' => '1' ), wc_get_cart_url() ), 'cart-pdf' ) ); ?>" class="cart-pdf-button button" target="_blank">
    		<?php esc_html_e( get_option( 'wc_cart_pdf_button_label', __( 'Download Cart as PDF', 'wc-cart-pdf' ) ) ); ?>
    	</a>
    
    	<?php
    }
    add_action( 'woocommerce_proceed_to_checkout', 'wc_cart_pdf_button', 21 );
    
    Thread Starter ronr1999

    (@ronr1999)

    Ah… that works for my application. Thanks for the help!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Open PDF in new TAB’ is closed to new replies.