0

I'm confronted in integrating a pdf to my project with some css. But there it comes that I need to actually add an image.

I saw that there is KnpSnappyBundle available, but my css actually works without it as I can add colors and everything. My only question is how can I add an image without using any bundle ?

I tried with a twig link in the html like this

<img class="logo" src="{{ asset('images/logo.png') }}">

I tried with an absolute path like this

<img class="logo" src="{{ asset('images/logo.png', absolute = true) }}">

I tried to add it in the css too:

.logo {
        background: url('images/logo.png');
        background-size: cover;
        height: 100px;
        width: 100px;
    }

the pdf opens but there is no logo.

So does anyone have an idea on how to do it?

chicken burger
  • 774
  • 2
  • 12
  • 32
  • you might need to check this before wasting too much time on it http://stackoverflow.com/questions/1833222/adding-external-images-to-pdf-using-itext and https://forums.adobe.com/thread/1337846 – sakhunzai Apr 12 '17 at 10:32
  • Now the question is do you want to generate pdf with embeded images , if yes you have domain naming issue – sakhunzai Apr 12 '17 at 10:33
  • @sakhunzai hi, hm so there is no way i could do that without a bundle? seems that im in the wrong way right? – chicken burger Apr 12 '17 at 11:34
  • its obvious you need `KnpSnappyBundle` to generate a pdf – sakhunzai Apr 13 '17 at 05:54

1 Answers1

0

The usual problem with Snappy package which internally uses wkhtmltopdf tool, is domain name referencing. You should convert all your relative resource paths to absolute paths , and it will work for you. You should look at this or this to convert all css/image links

Community
  • 1
  • 1
sakhunzai
  • 13,900
  • 23
  • 98
  • 159
  • thanks for the help. I do not need anything on links, or maybe should I? I wanted to just display the company logo, but seems that it is really hard to do that. + i'm not using any bundle for that – chicken burger Apr 12 '17 at 12:08
  • Would you mind adding detail on how you are generating a pdf ? – sakhunzai Apr 13 '17 at 05:56