PHP code example of redocmx / client-php

1. Go to this page and download the library: Download redocmx/client-php 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/ */

    

redocmx / client-php example snippets




  use Redocmx\RedocmxClient;

  # Create a Redoc instance
  $redoc = new RedocmxClient('your_api_key_here');

$cfdi = $redoc->cfdi()->fromFile('./path/to/your/file.xml');

$cfdi = $redoc->cfdi()->fromString('<xml_content_string_here>');

  try {
    # Create the PDF
    $pdf = $cfdi->toPdf();

    echo("Transaction ID: " . $pdf->getTransactionId() . "\n");
    echo("Total Pages: " . $pdf->getTotalPages() . "\n");
    echo("Total Time: " .$pdf->getTotalTimeMs() . "\n");
    print_r($pdf->getMetadata());

    # Save in file system
    file_put_contents('./result.pdf', $pdf->toBuffer());

  } catch (Exception $e) {
    echo "An error occurred during the conversion: " . $e->getMessage();
  }

[
	"style_pdf"=>"John"
]
 
[
    TDB...
]
bash
composer