• Resolved Marchetti Design

    (@afmarchetti)


    Hi the plugin show me this error in the pdf document:

    “Image not found or type unknown”

    the image is added in a custom template, and is generated by php, the system works for a wile and after few months stops and show the error in the pdf version.

    If i switch to document in html version everything works, but i need the image in the pdf. What i can do to solve the problem?

    Many thanks

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    Sorry to hear that. We need a bit more information to be able to help. Could you elaborate on this?

    the image is added in a custom template, and is generated by php

    Is the image a local file (server path), or is it a URL?
    What’s the file format of the image (JPG/PNG/SVG/GIF/?)
    Are you using a specific PHP library to generate the image?

    Basically, any details that would help us to replicate the issue or determine possible sources of the error ??

    Thread Starter Marchetti Design

    (@afmarchetti)

    Hi, thanks for the reply, the image is created with this library:

    https://github.com/davidscotttufts/php-barcode/

    is very popular here the article with some examples:
    https://davidscotttufts.com/2009/03/31/how-to-create-barcodes-in-php/

    The image created is a png files. Basically you pass the string you want transform in the barcode with this sintax:

    <img alt="testing" src="barcode.php?text=testing" />

    barcode.php is the library, i don’t understand why it works in html and not in pdf mode..

    Plugin Contributor Ewout

    (@pomegranate)

    HTML mode is executed inside your browser (making a request to your server via a URL), PDF mode is processed entirely on your server. Not only is the relative context (the location from which the script is called) different, your server also not have permissions to call “external” resources (any URL will need to be fetched & served via your web server rather than directly from a local resource on the server, even if that URL points to the same server!).

    That said, you should always provide the full URL (including https://) when linking to non-local resources (e.g. anything other than full server paths pointing to a specific file), and you will also want to verify whether allow_url_fopen is enabled on your server (you can see this in the Status tab of the PDF invoice settings).

    Thread Starter Marchetti Design

    (@afmarchetti)

    allow_url_fopen is enable, the strange thing is that for some month the pdf with the generated image wordked correctly.

    I set the url of the library use absolute path with this code:

    echo "<img alt='testing' src='". get_stylesheet_directory_uri() ."/woocommerce/barcode-library.php?text=testing'/>"

    I can open a ticket in the hosting service, but i haven’t clear what i have to ask…

    Thread Starter Marchetti Design

    (@afmarchetti)

    Any news on this?

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Hello @afmarchetti,

    Could you try the code you mentioned above with this one:

    echo "<img alt='testing' src='". str_replace( 'https:', 'http:', get_stylesheet_directory_uri() ) ."/woocommerce/barcode-library.php?text=testing'/>"

    Let me know if it works! ??

    Thread Starter Marchetti Design

    (@afmarchetti)

    Hi @yordansoares i had try your code, but unfortunately doesn’t works. What i can do?

    Plugin Contributor alexmigf

    (@alexmigf)

    Hi @afmarchetti

    I did a test locally with @yordansoares code and works fine. Do you have the GD Library installed like indicating in the repository?

    Thread Starter Marchetti Design

    (@afmarchetti)

    Yes, also in my local enviroment the librabry works, on the live site it was working for some months, but two weeks ago the generation only in the pdf version not works anymore. if i have to make tests i’m here, thanks.

    Thread Starter Marchetti Design

    (@afmarchetti)

    Any news on that?? thanks

    Thread Starter Marchetti Design

    (@afmarchetti)

    Any news? maybe the pdf file is generate before the code bar generation is finish?

    Plugin Contributor Ewout

    (@pomegranate)

    @afmarchetti that doesn’t seem likely to me, loading resources server side in PHP is not synchronous like a browser so it will always wait until it is loaded (unless the script times out or something else prevents it from returning the image, but that seems unlikely given the fact that it works for you in HTML).

    The fact that it works on your local environment and that it worked on our own tests with the same library indicates it’s an issue with the server configuration on your live site.

    Since you are using the free plugin and this concerns a customization rather than a core feature, unfortunately we cannot provide in depth debugging of our server environment.

    As an alternative approach you could also look into using other barcode libraries that have the option to return the barcode image as base64 encoded data so that you can include it in the output directly instead of linking to it with src.

    Hope that helps!

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Image not found or type unknown’ is closed to new replies.