0

I have been using barryvdh/laravel-dompdf for pdf generation. My problem is that I want to use different background images on different pages which I can't. One background image is displayed on all the pages.

<div id="watermark"><img src="{{ public_path('pdf-backgrounds/'. $settings->pdf_background_image) }}" height="100%" width="100%"></div>

Is there any solution to this?

Zain Farooq
  • 2,956
  • 3
  • 20
  • 42

1 Answers1

1

You can create a new <body> tag to represent each new page, is not the best way but was the only way that I got when using barryvdh/laravel-dompdf.

  • Hi,, Thank you very much for answering. Can you please elaborate more where to add that body tag when you have the dynamic data and you actually don't know that where the page is gonna end. – Zain Farooq Nov 07 '21 at 11:50
  • Hi, in my case I had to build a PDF with more than 40 pages and those pages where split by a few sections, every section was a `body` tag. I recommend you split in sections too and this may help you. otherwise you can do a `foreach` to create a lot of `body` tags and distribute your content. Sorry for not help you with a direct answer, but domPDF have not a good documentation. – Luis Manoel Nov 07 '21 at 16:22
  • The problem is that I don't know where is my page is going to end. Did you create multiple tables too? – Zain Farooq Nov 08 '21 at 05:19
  • I am running a table and the problem is if I add a `body` tag inside the table it disturbs the whole structure – Zain Farooq Nov 08 '21 at 07:03