PHP code example of petecoop / odt

1. Go to this page and download the library: Download petecoop/odt library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

petecoop / odt example snippets


use Petecoop\ODT\Facades\ODT;

ODT::open(resource_path("file.odt"))
    ->render([
        "some" => "arguments",
    ]);

use Petecoop\ODT\ODT;

ODT::make()
    ->open(__DIR__ . "/templates/file.odt")
    ->render([
        "some" => "arguments",
    ]);

$pdf = ODT::open(resource_path("file.odt"))
    ->render([
        "some" => "arguments",
    ])
    ->pdf();

ODT::officeBinary('/path/to/soffice')
    ->open(resource_path("file.odt"));

// if using ODT::make()
ODT::make('/path/to/soffice')
    ->open(__DIR__ . "/templates/file.odt");

$pdf = ODT::gotenberg('http://localhost:3000')
    ->open(resource_path("file.odt"))
    ->render([
        "some" => "arguments",
    ])
    ->pdf();

$odt = ODT::open(resource_path("file.odt"))
    ->render([
        "some" => "arguments",
    ]);

// Save ODT file
$odt->save(storage_path("file.odt"));

// Convert to PDF and save
$pdf = $odt->pdf()->save(storage_path("file.pdf"));

// Return as download response in a Laravel Controller
return $pdf;
blade
@rowforeach($users as $user)
{{ $user->name }}