• Resolved adamgabor

    (@adamgabor)


    Logo and product image not showing. Only show “Red X”. I add the wp-config.php

    define( 'WC_CART_PDF_THUMBNAIL_COMPATIBILITY', true );

    and add functions.php

    "add_filter( 'wc_cart_pdf_mpdf', function( $mpdf ) { $mpdf->curlUserAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36'; return $mpdf; } );"

    • This topic was modified 8 months, 2 weeks ago by adamgabor.

    The page I need help with: [log in to see the link]

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

    (@dkjensen)

    Hello

    Could you add the following to your wp-config.php?

    define( 'WC_CART_PDF_DEBUG', true );

    I would recommend doing this on staging as it will output the PDF as HTML.

    Once you add that snippet, click the Download Cart as PDF button and it will generate the HTML, could you check the URLs in the <img> tags and make sure they are accessible, and/or paste the entire HTML here?

    Thread Starter adamgabor

    (@adamgabor)

    <style>.wc_cart_pdf_template { color: #636363; font-size: 13px; margin: 0; text-indent: 0pt; line-height: normal; margin-collapse: collapse; hyphens: manual; font-kerning: auto; padding: 0; -webkit-text-size-adjust: none !important; width: 100%; } a { color: #5683b3; text-decoration: none; } b, strong, th { font-weight: normal; } p { margin: 1.12em 0; } h1 { font-size: 2em; font-weight: bold; margin: 0.67em 0; page-break-after: avoid; } h2 { font-size: 1.5em; font-weight: bold; margin: 0.75em 0; page-break-after: avoid; } h3 { font-size: 1.17em; font-weight: bold; margin: 0.83em 0; page-break-after: avoid; } h4 { font-weight: bold; margin: 1.12em 0; page-break-after: avoid; } h5 { font-size: 0.83em; font-weight: bold; margin: 1.5em 0; page-break-after: avoid; } h6 { font-size: 0.75em; font-weight: bold; margin: 1.67em 0; page-break-after: avoid; } hr { color: #888888; text-align: center; width: 100%; height: 0.2mm; margin-top: 0.83em; margin-bottom: 0.83em; } pre { margin: 0.83em 0; font-family: monospace; } s, strike, del { text-decoration: line-through; } sub { vertical-align: sub; font-size: 55%; } sup { vertical-align: super; font-size: 55%; } u, ins { text-decoration: underline; } i, cite, q, em, var, address { font-style: italic; } samp, code, kbd, tt { font-family: monospace; } small { font-size: 83%; } big { font-size: 117%; } acronym { font-size: 77%; font-weight: bold; } blockquote { margin-left: 40px; margin-right: 40px; margin-top: 1.12em; margin-bottom: 1.12em; } ul, ol { padding: 0 auto; margin-top: 0.83em; margin-bottom: 0.83em; } dl { margin: 1.67em 0; } dd { padding-left: 40px; } table { color: #636363; margin: 0; border-collapse: separate; border-spacing: 0px; empty-cells: show; line-height: 1.2; font-size: 12px; vertical-align: middle; hyphens: manual; font-kerning: auto; } th { text-align: center; padding: 0.1em; } td { padding: 0.1em; } .shop_table { table-layout: fixed; width: 100%; } .shop_table .product-thumbnail { width: 10%; text-align: right; overflow: hidden; } .shop_table .product-quantity { width: 15%; text-align: right; } .shop_table .product-price, .shop_table .product-subtotal { width: 20%; text-align: right; } .shop_table .product-name { width: 35%; } .shop_table .product-thumbnail img { max-width: 100%; height: auto; } .shop_table td, .shop_table th { vertical-align: top; padding: .5em .5em 1em; } .shop_table dl { margin: 0; padding: .5em 0; } .shop_table dd, .shop_table dt { font-size: 12px; display: inline; margin: 0; padding: 0; } .shop_table dt { font-weight: bold; } .shop_table dd * { display: inline; } .shop_table dd:after { display: block; font-size: 0; content: "\A"; clear: both; height: 0; white-space: pre; } .cart-total-row th, .cart-total-row td { background: #fafafa; } .cart-total-row td { text-align: right; } .woocommerce-remove-coupon { display: none !important; } #template_header_image { text-align: center; padding: 0 0 2em; } #template_header_meta { font-size: 12px; text-align: right; } #template_footer { color: #636363; padding: 2em 0 0; font-size: 12px; text-align: center; } </style><div class="wc_cart_pdf_template"> <table style="width: 100%; "> <tr> <th style="text-align:left; width:60%;"> <div id="template_header_image"> <p style="margin-top: 0; text-align: left;"> https://partner.mbc-marine.com/wp-content/uploads/2024/02/cropped-MBC-logo-1.png <img src="https://partner.mbc-marine.com/wp-content/uploads/2024/02/cropped-MBC-logo-1.png" style="width: 200px;" alt="MBC PARTNER" /> </p> </div> </th> <th style="text-align:left; width:40%;"> <p style="font-size: 16px; font-weight:bold"> Generated indicative offer<br> </p> <p style="font-size: 14px;"> Username: gabor<br> Company: TEST COMPANY<br> Email: [email protected]<br> Phone number:+3611111111 </p> </th> </tr> </table> <div id="template_header_meta"> <p> 0019<br> 2024.07.08. </p> </div> <table class="shop_table shop_table_responsive cart woocommerce-cart-form__contents" cellspacing="0"> <thead> <tr> <th class="product-thumbnail">?</th> <th class="product-name">Product</th> <th class="product-price">Price</th> <th class="product-quantity">Quantity</th> <th class="product-subtotal">Total</th> </tr> </thead> <tbody> <tr class="woocommerce-cart-form__cart-item cart_item"> <td class="product-thumbnail"> <img width="300" height="300" src="https://partner.mbc-marine.com/wp-content/uploads/2024/02/Foto-20.11.23-15-45-29-scaled__1_-removebg-preview-300x300.png" class="attachment-woocommerce_thumbnail size-woocommerce_thumbnail" alt="" width="60" height="auto" decoding="async" srcset="https://partner.mbc-marine.com/wp-content/uploads/2024/02/Foto-20.11.23-15-45-29-scaled__1_-removebg-preview-300x300.png 300w, https://partner.mbc-marine.com/wp-content/uploads/2024/02/Foto-20.11.23-15-45-29-scaled__1_-removebg-preview-100x100.png 100w, https://partner.mbc-marine.com/wp-content/uploads/2024/02/Foto-20.11.23-15-45-29-scaled__1_-removebg-preview-150x150.png 150w" sizes="(max-width: 300px) 100vw, 300px" /><a ><img width="300" height="300" src="https://partner.mbc-marine.com/wp-content/uploads/2024/02/Foto-20.11.23-15-45-29-scaled__1_-removebg-preview-300x300.png" class="attachment-woocommerce_thumbnail size-woocommerce_thumbnail" alt="" width="60" height="auto" decoding="async" srcset="https://partner.mbc-marine.com/wp-content/uploads/2024/02/Foto-20.11.23-15-45-29-scaled__1_-removebg-preview-300x300.png 300w, https://partner.mbc-marine.com/wp-content/uploads/2024/02/Foto-20.11.23-15-45-29-scaled__1_-removebg-preview-100x100.png 100w, https://partner.mbc-marine.com/wp-content/uploads/2024/02/Foto-20.11.23-15-45-29-scaled__1_-removebg-preview-150x150.png 150w" sizes="(max-width: 300px) 100vw, 300px" /></a> </td> <td class="product-name" data-title="Product"> <a >ESC 13.000 BTU marine a/c unit with Wi-Fi smart display</a><dl class="variation"> <dt class="variation-StockStatus">Stock Status:</dt> <dd class="variation-StockStatus"><p class="stock in-stock s_in_stock_color woo-custom-stock-status woocss_shortcode">Available in stock</p> </dd> </dl> </td> <td class="product-price" data-title="Price"> <span class="woocommerce-Price-amount amount"><bdi>3400,00?<span class="woocommerce-Price-currencySymbol">€</span></bdi></span> </td> <td class="product-quantity" data-title="Quantity"> 1 </td> <td class="product-subtotal" data-title="Total"> <span class="woocommerce-Price-amount amount"><bdi>3400,00?<span class="woocommerce-Price-currencySymbol">€</span></bdi></span> </td> </tr> <tr class="cart-subtotal cart-total-row"> <th class="row-subtotal" colspan="4" style="text-align: right;">Subtotal</th> <td class="row-subtotal" data-title="Subtotal"><span class="woocommerce-Price-amount amount"><bdi>3400,00?<span class="woocommerce-Price-currencySymbol">€</span></bdi></span></td> </tr> <tr class="order-total cart-total-row"> <th class="row-subtotal" colspan="4" style="text-align: right;">Total</th> <td class="row-subtotal" data-title="Total"><strong><span class="woocommerce-Price-amount amount"><bdi>3400,00?<span class="woocommerce-Price-currencySymbol">€</span></bdi></span></strong> </td> </tr> </tbody> </table> </div>

    I have added the code. I’ve checked this once before, but found everything to be in order. I’ll paste the code just in case.

    Thread Starter adamgabor

    (@adamgabor)

    It works in a developer-ready environment. Is it possible that the images are not showing due to some server error ?

    Plugin Author David Jensen

    (@dkjensen)

    Possibly, is the site behind a basic auth by chance?

    I have seen different cURL installations require certain configurations, you could also try:

    add_filter(
    'wc_cart_pdf_mpdf',
    function ( $mpdf ) {
    $mpdf->curlUserAgent = '';

    return $mpdf;
    },
    50
    );

    Thread Starter adamgabor

    (@adamgabor)

    Unfortunately, I do not know about this. I tried the code but it still doesn’t work. I wonder if the pdf generation needs a php plugin which is missing here ? I read on another forum that the .png file type can cause this when generating PHP PDF. I have tried with .jpg but that is not the problem.

    Plugin Author David Jensen

    (@dkjensen)

    The plugin uses the mPDF library, which is included in the plugin. It does require the PHP GD library which should be installed otherwise you would see an error in the WP Admin regarding the need to install this. Could you send the HTML produced after adding this?

    define( 'WC_CART_PDF_DEBUG', true );

    Plugin Author David Jensen

    (@dkjensen)

    Disregard, I see it above.

    Plugin Author David Jensen

    (@dkjensen)

    Could you try adding the following to your functions.php file and removing this from your wp-config.php file?

    Remove:

    define( 'WC_CART_PDF_DEBUG', true );

    Add to child theme functions.php file:

    add_filter( 'wc_cart_pdf_mpdf_args', function( $args ) {
    $args['tempDir'] = get_temp_dir();

    return $args;
    } );

    add_filter( 'wc_cart_pdf_mpdf', function( $mpdf ) {
    $mpdf->curlAllowUnsafeSslRequests = true;
    $mpdf->showImageErrors = true;

    return $mpdf;
    } );

    This will output image errors on the PDF, can you paste the image errors here if still present?

    Thread Starter adamgabor

    (@adamgabor)

    I made the requested changes and this PHP error comes up:

    [Mon Jul 08 18:56:48.211266 2024] [php:error] [pid 131714] [client 10.88.75.11:56600] PHP Fatal error: ?Uncaught Mpdf\\MpdfException: Cannot write to an undeclared property Mpdf\\Mpdf::$curlAllowUnsafeSslReque in /var/www/partner.mbc-marine.com/wp-content/plugins/wc-cart-pdf/vendor/mpdf/mpdf/src/Strict.php:44\nStack trace:\n#0 /var/www/partner.mbc-marine.com/wp-content/themes/hello-theme-child-master/functions.php(133): Mpdf\\Mpdf->__set()\n#1 /var/www/partner.mbc-marine.com/wp-includes/class-wp-hook.php(324): {closure}()\n#2 /var/www/partner.mbc-marine.com/wp-includes/plugin.php(205): WP_Hook->apply_filters()\n#3 /var/www/partner.mbc-marine.com/wp-content/plugins/wc-cart-pdf/wc-cart-pdf.php(207): apply_filters()\n#4 /var/www/partner.mbc-marine.com/wp-includes/class-wp-hook.php(324): wc_cart_pdf_process_download()\n#5 /var/www/partner.mbc-marine.com/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()\n#6 /var/www/partner.mbc-marine.com/wp-includes/plugin.php(517): WP_Hook->do_action()\n#7 /var/www/partner.mbc-marine.com/wp-includes/template-loader.php(13): do_action()\n#8 /var/www/partner.mbc-marine.com/wp-blog-header.php(19): require_once('...')\n#9 /var/www/partner.mbc-marine.com/index.php(17): require('...')\n#10 {main}\n ?thrown in /var/www/partner.mbc-marine.com/wp-content/plugins/wc-cart-pdf/vendor/mpdf/mpdf/src/Strict.php on line 44, referer: https://partner.mbc-marine.com/index.php/cart/

    Plugin Author David Jensen

    (@dkjensen)

    Try removing this line:

    $mpdf->curlAllowUnsafeSslRequests = true;

    Thread Starter adamgabor

    (@adamgabor)


    Okay.
    I have a new error code
    [Wed Jul 10 08:57:50.079008 2024] [php:error] [pid 138465] [client 10.88.75.11:53778] PHP Fatal error: ?Uncaught Mpdf\\MpdfImageException: Could not find image file (https://partner.mbc-marine.com/wp-content/uploads/2024/07/logo-j.jpg) in /var/www/partner.mbc-marine.com/wp-content/plugins/wc-cart-pdf/vendor/mpdf/mpdf/src/Image/ImageProcessor.php:589\nStack trace:\n#0 /var/www/partner.mbc-marine.com/wp-content/plugins/wc-cart-pdf/vendor/mpdf/mpdf/src/Image/ImageProcessor.php(211): Mpdf\\Image\\ImageProcessor->imageError()\n#1 /var/www/partner.mbc-marine.com/wp-content/plugins/wc-cart-pdf/vendor/mpdf/mpdf/src/Tag/Img.php(276): Mpdf\\Image\\ImageProcessor->getImage()\n#2 /var/www/partner.mbc-marine.com/wp-content/plugins/wc-cart-pdf/vendor/mpdf/mpdf/src/Tag.php(240): Mpdf\\Tag\\Img->open()\n#3 /var/www/partner.mbc-marine.com/wp-content/plugins/wc-cart-pdf/vendor/mpdf/mpdf/src/Mpdf.php(13850): Mpdf\\Tag->OpenTag()\n#4 /var/www/partner.mbc-marine.com/wp-content/plugins/wc-cart-pdf/wc-cart-pdf.php(210): Mpdf\\Mpdf->WriteHTML()\n#5 /var/www/partner.mbc-marine.com/wp-includes/class-wp-hook.php(324): wc_cart_pdf_process_download()\n#6 /var/www/partner.mbc-marine.com/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()\n#7 /var/www/partner.mbc-marine.com/wp-includes/plugin.php(517): WP_Hook->do_action()\n#8 /var/www/partner.mbc-marine.com/wp-includes/template-loader.php(13): do_action()\n#9 /var/www/partner.mbc-marine.com/wp-blog-header.php(19): require_once('...')\n#10 /var/www/partner.mbc-marine.com/index.php(17): require('...')\n#11 {main}\n ?thrown in /var/www/partner.mbc-marine.com/wp-content/plugins/wc-cart-pdf/vendor/mpdf/mpdf/src/Image/ImageProcessor.php on line 589, referer: https://partner.mbc-marine.com/index.php/cart/

    I do not understand. It can’t find the image at the given URL, but if I copy the link into the URL, the image comes up.

    Plugin Author CloudCatch

    (@cloudcatch)

    Could you try adding the following snippet to your child theme functions.php file?

    /**
    * Replace image URLs with local paths in the cart PDF.
    *
    * @param string $content The cart PDF content.
    * @return string
    */
    add_filter( 'wc_cart_pdf_content', function( $content ) {
    $wp_upload_dir = wp_upload_dir();

    $content = str_replace( $wp_upload_dir['baseurl'], $wp_upload_dir['basedir'], $content );

    return $content;
    } );

    Thread Starter adamgabor

    (@adamgabor)

    @cloudcatch You are the best ! ?? This solution solved the problem.

    Plugin Author CloudCatch

    (@cloudcatch)

    @adamgabor Nice! I believe this answer is related to the issue you were having.

    You should be able to remove previous code added to the wp-config.php file and child theme functions.php file and just keep that newest snippet that worked.

    ecros

    (@ecros)

    Following now: After updating to Woocommerce Version 9.2.1 yesterday, my old code:

    add_filter( 'wc_cart_pdf_mpdf', function( $mpdf ) {
    $mpdf->curlUserAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36';

    return $mpdf;
    } );

    no longer works. I tried updating to the new code above that worked for @adamgabor and no luck.

    All the error shows is: “There has been a critical error on this website.”

    I need help fixing this.

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Image not show the pdf’ is closed to new replies.