Mpdf, отображающий одну букву на странице - PullRequest
0 голосов
/ 11 апреля 2020

Я адаптирую этот пример, чтобы создать плагин для Кирби, и я, кажется, заставляю его работать для создания текущего URL и создания PDF.

Так что в основном www.website.com/makepdf?url=http.website.com / page возвращает pdf, но делает одну букву на странице (более тысячи страниц!).

какие-нибудь эксперты в Mpdf, которые могли бы дать подсказку?

это код, которым я являюсь используя попытку:

<?php
@include_once __DIR__ . '/vendor/autoload.php';
Kirby::plugin('getkirby/pluginkit', [
    'routes' => [
        [
            'pattern' => 'en/makepdf',
            'action' => function () {


                $url = urldecode($_REQUEST['url']);
                if (count($_POST) > 0) {

                    $ch = curl_init($url);
                    curl_setopt($ch, CURLOPT_HEADER, 0);
                    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1 );

                    foreach($_POST as $name => $post) {
                        $formvars = array($name => $post . " \n");
                    }

                    curl_setopt($ch, CURLOPT_POSTFIELDS, $formvars);
                    $html = curl_exec($ch);
                    curl_close($ch);

                } elseif (ini_get('allow_url_fopen')) {
                    $html = file_get_contents($url);

                } else {
                    $ch = curl_init($url);
                    curl_setopt($ch, CURLOPT_HEADER, 0);
                    curl_setopt ( $ch , CURLOPT_RETURNTRANSFER , 1 );
                    $html = curl_exec($ch);
                    curl_close($ch);
                }

                $mpdf = new \Mpdf\Mpdf(['debug' => true]);

                $mpdf->useSubstitutions = true; // optional - just as an example
                $mpdf->SetHeader($url . "\n\n" . 'Page {PAGENO}');  // optional - just as an example
                $mpdf->CSSselectMedia='mdpf'; // assuming you used this in the document header
//                $mpdf->CSSselectMedia='global'; // assuming you used this in the document header
//                $mpdf->CSSselectMedia='style'; // assuming you used this in the document header
                $mpdf->setBasePath($url);
                $mpdf->WriteHTML($html);
                $mpdf->Output();


            }
        ]
    ]
]);




...