1

We are creating a PDF document after a user submitted a web form. Problem is: when the user submits english characters, they are displayed properly. However after he submits Hebrew words, the PDF is generated with gibberish symbols. Here is the code of the PHP class that generates the PDF file:

class PdfForm {
/*
* Path to raw PDF form
* @var string
*/
private $pdfurl;
/*
* Form data
* @var array
*/
private $data;
/*
* Path to filled PDF form
* @var string
*/
private $output;
/*
* Flag for flattening the file
* @var string
*/
private $flatten;

/**
 * Class Conctructor
 *
 * @param string $pdfurl
 * @param array $data
 */
public function __construct( $pdfurl, $data ) {
    $this->pdfurl = $pdfurl;
    $this->data   = $data;
}

/**
 * Generate a filled PDF file
 *
 */
private function generate() {
    $fdf          = $this->makeFdf( $this->data );
    $this->output = $this->tmpfile();
    exec( "pdftk {$this->pdfurl} fill_form {$fdf} output {$this->output}{$this->flatten}" );
    unlink( $fdf );
}
STF
  • 1,485
  • 3
  • 19
  • 36
Daniel Gontar
  • 147
  • 1
  • 9

0 Answers0