Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Landscape Option Not Working #74

Open
zpottie opened this issue Jul 19, 2024 · 0 comments
Open

Landscape Option Not Working #74

zpottie opened this issue Jul 19, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@zpottie
Copy link

zpottie commented Jul 19, 2024

Hi there,

Thanks for this library - just switched to it from wkhtmltopdf, so please forgive me if this is due to my own ignorance.

It seems like the landscape option is not quite working? Or I'm missing setting something?

I've made sure I got all the dependencies installed on the server. Here's what I've done:

// Our input is HTML.
$input = new StringInput();
$input->setHtml($twigHtml);

// Initialise converter and set output as raw PDF content
$converter = new Converter($input, new StringOutput());

// Set page options.
$converter->setOptions([
    'format' => 'A5',
    'margin' => [
        'top' => '1.5cm',
        'right' => '1.5cm',
        'bottom' => '1.5cm',
        'left' => '1.5cm',
    ],
    'landscape' => true
]);

// Return the raw PDF content.
return $converter->convert()->get();

I had to end up setting the preferCSSPageSize option to true and add the below to the @page at-rule in the CSS.

@page {
    size: A5 landscape;
}

Thanks again,
Zander

@spiritix spiritix added the bug Something isn't working label Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants