Commit f1151386 authored by Jean-Baptiste Oellers's avatar Jean-Baptiste Oellers
Browse files

Passage ODT

parent a215f379
Loading
Loading
Loading
Loading
+32 −9
Original line number Diff line number Diff line
@@ -130,15 +130,38 @@ class ConventionModeleEtapeAdministrationController extends AbstractOscarControl
            $documentLocation = $this->getOscarConfigurationService()->getDocumentDropLocation();
            $documentPath = $documentLocation . DIRECTORY_SEPARATOR . $conventionModeleEtape->fichier;

            $templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor($documentPath);
            //$templateProcessor->setValue('name', 'myvar');
            //$templateProcessor->saveAs($documentPath . '2');

            \PhpOffice\PhpWord\Settings::setPdfRendererName(\PhpOffice\PhpWord\Settings::PDF_RENDERER_DOMPDF);
            \PhpOffice\PhpWord\Settings::setPdfRendererPath(__DIR__ . '/../../../../../vendor/dompdf/dompdf');
            $phpWord = \PhpOffice\PhpWord\IOFactory::load($documentPath);
            $pdfWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord , 'PDF');
            $pdfWriter->save($documentPath . '.pdf');


            $reader = new \XMLReader();
            $reader->open('zip://' . $documentPath . "#content.xml");
            $odt_meta = array();
            while ($reader->read()) {
                if ($reader->nodeType == \XMLREADER::ELEMENT) {
                    $elm = $reader->name;
                } else {
                    if ($reader->nodeType == \XMLREADER::END_ELEMENT && $reader->name == 'office:meta') {
                        break;
                    }
                    if (!trim($reader->value)) {
                        continue;
                    }
                    $odt_meta[$elm] = $reader->value;
                }
            }




            
            // $templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor($documentPath);
            // //$templateProcessor->setValue('name', 'myvar');
            // //$templateProcessor->saveAs($documentPath . '2');

            // \PhpOffice\PhpWord\Settings::setPdfRendererName(\PhpOffice\PhpWord\Settings::PDF_RENDERER_DOMPDF);
            // \PhpOffice\PhpWord\Settings::setPdfRendererPath(__DIR__ . '/../../../../../vendor/dompdf/dompdf');
            // $phpWord = \PhpOffice\PhpWord\IOFactory::load($documentPath);
            // $pdfWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord , 'PDF');
            // $pdfWriter->save($documentPath . '.pdf');

        }