A
A
alexiusgrey2022-03-04 15:12:46
PHP
alexiusgrey, 2022-03-04 15:12:46

After the transfer from my client to the host, the picture in pdf is no longer displayed, what could be the problem?

On my website, a pdf file is attached in letters, and there is a picture-signature in it.
I did it with dompdf, and on my hosting everything worked and works safely.
No plug-ins, plug-ins did not fit what I needed - a long explanation - SIMPLY NO, I made the document myself, connected it without a composer. everything worked.

add_filter( 'woocommerce_email_attachments', 'attach_terms_conditions_pdf_to_email', 10, 3);

function attach_terms_conditions_pdf_to_email ( $attachments , $id, $object ) {
    $your_pdf_path = get_template_directory() . '/pdf-test.pdf';
    $attachments[] = $your_pdf_path;
    return $attachments;
}

require_once get_template_directory() . '/assets/dompdf/autoload.inc.php';
 use Dompdf\Dompdf;
 $dompdf = new Dompdf();
 ob_start();
require(get_template_directory().'/pdf-test.php');
 $content_pdf = ob_get_clean();
 $dompdf->loadHtml( $content_pdf);
 // (Optional) Setup the paper size and orientation
 $dompdf->setPaper('A3', 'portarait');
 // Render the HTML as PDF
 $dompdf->render();
 // Output the generated PDF to Browser 
$output = $dompdf->output();
file_put_contents(get_template_directory() . '/pdf-test.pdf', $output);
?>


As transferred to the client's host, the picture in the letter is not displayed.
$dompdf->set_option('isRemoteEnabled', TRUE);
does not help, I changed the paths to both absolute and relative ones, too.
On my hosting, the picture inside php, which is converted to pdf - in pdf-test.php, is written like this
<img style="width: 65%;float:right;" src="<?php echo get_template_directory_uri(); ?>/signature.png" />

and successfully displayed.
Why is everything displayed on one host and not on another? And how can I fix this if isRemoteEnabled' doesn't help?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Anton Shamanov, 2022-03-04
@SilenceOfWinter

get_template_directory_uri() returns relative url? does the client have a directory with the signature.png file that this link corresponds to?

A
Adamos, 2022-03-04
@Adamos

Obviously, it's worth checking what the new hosting givesget_template_directory_uri()
. For example, whether it points to the old hosting at all.

I
Immortal_pony, 2022-03-04
@Immortal_pony

Encode the image in base64 and put it in src - then you won't have to mess with any files.

A
alexiusgrey, 2022-03-04
@alexiusgrey

Understood and everything was very golobalno. There were no required modules on the host. I had to connect to VPS. Very, very frozen. Now it seems to be working

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question