Exemple #1
0
 public static function generatePdfExample(Factory $pdftk, $sourcePdf, $targetPdf)
 {
     $fields = self::extractFieldsFromPdf($pdftk, $sourcePdf);
     if (!$fields) {
         throw new \RuntimeException("PDF does not have any fields");
     }
     foreach ($fields as $field) {
         $field->setValue($field->getExampleValue());
     }
     $fdf_file = tempnam(sys_get_temp_dir(), 'fdf');
     $writer = new FdfWriter($fields);
     $writer->generate();
     $writer->save($fdf_file);
     $formFiller = $pdftk->fillForm($sourcePdf, $fdf_file, $targetPdf);
     $formFiller->generate();
     unlink($fdf_file);
 }
 /**
  * @dataProvider PdfNames
  */
 public function testEscapePdfNames($input, $escaped)
 {
     $this->assertEquals($escaped, FdfWriter::escapePdfName($input));
 }