Skip to content

Latest commit

 

History

History
34 lines (26 loc) · 802 Bytes

how_to_pass_arguments.md

File metadata and controls

34 lines (26 loc) · 802 Bytes

How to pass arguments to the javascript file

In this example, we will use arguments to programmatically set the orientation of the PDF.

First, the configuration should be changed

padam87_rasterize:
    arguments:
        orientation: portrait

Note that the orientation argument has been added, by default it will be set as portrait.

A custom javascript is also necessary, to handle the newly received argument.

// ...
const args = process.argv;
const format = args[2];
const orientation = args[3];
// ...

To change the orientation to landscape, you need to add one more parameter to the rasterizer call.

$this->get(Rasterizer::class)->rasterize(
    $this->renderView('Bundle:Folder:template.pdf.twig')
    [
        'orientation' => 'landscape'
    ]
);