vishal-mote
vishal-mote

Reputation: 482

laravel :- unable to set different size for different pages for single pdf

I am trying to set big height and width for the first page and the smaller size for other pages.

I am using Thujohn\Pdf\PdfFacade library in laravel.

below is my code.

<html>
<head>
<style>
            <?php
                $pageWt = $drawing_width + 200; //very large size
                $pageHt = $drawing_height + 200;//very large size
            ?>
            @page { size: <?= $pageWt ?>px <?= $pageHt ?>px; }
            @page rotate { size: 400px 500px; }
            .pgbrk {
                page : rotate;
                font-size: 70px;
                page-break-before: always;
            }
        </style>
</head>
<body>
<img src="<?= URL::to('drawings/getDrawing?filepath=' . $filepath) ?>">
            <div class="pgbrk">
  some data
            </div>
<img src="<?= URL::to('drawings/getDrawing?filepath=' . $filepath) ?>">
            <div class="pgbrk">
  some data
            </div>
<img src="<?= URL::to('drawings/getDrawing?filepath=' . $filepath) ?>">
            <div class="pgbrk">
  some data
            </div>
<img src="<?= URL::to('drawings/getDrawing?filepath=' . $filepath) ?>">
            <div class="pgbrk">
  some data
            </div>
</body>
</html>

But above code sets same size for all pages.

I am expecting different sizes for pdf pages.

Do am I missing something. Please help.

Upvotes: 1

Views: 1575

Answers (1)

BrianS
BrianS

Reputation: 13914

dompdf does not yet support named pages. To achieve this with dompdf you would have to generate each page separately then combine them using another tool such as FPDI (see this answer, pdftk, or one of the many other options.

There are also some efforts to build support for merging PDFs using dompdf (e.g. this fork).

Upvotes: 2

Related Questions