Who knows, how read file.docx like antiword for file.doc in php ? This I used antiword for file.doc and set text in DB
$em = $this->getDoctrine()->getManager();
$request = $this->get('request');
$developer = $em->getRepository('ProfileBundle:Developer')->findOneById($id);
if (! $developer) {
throw $this->createNotFoundException('Unable to find a profile.');
}
$cv = $developer->getCvDirUri();
if($cv && file_exists($cv)) {
unlink($cv);
}
$form = $this->createForm(new DeveloperDirCvType(), array());
if ($request->isMethod('POST')) {
$form->bind($request);
if ($form->isValid()) {
$data = $form->getData();
$uploader = $this->get('artel.profile.file_uploader');
$path = $uploader->uploadFile($data['photo']);
$developer->setCvDirUri($path['url']);
$content = shell_exec('/usr/bin/antiword '.'chmod o+r /var/www/aog-profile/web/'.$path['url']);
if ($data['photo']->getClientMimeType() == 'application/vnd.openxmlformats-officedocument.wordprocessingml.document') {
$content_txt = exec('/usr/bin/abiword --to=html '.'/var/www/aog-profile/web/'.$path['url']);
}
elseif ($data['photo']->getClientMimeType() == 'application/pdf') {
$parser = new \Smalot\PdfParser\Parser();
$pdf = $parser->parseFile('/var/www/aog-profile/web/'.$path['url']);
$content = $pdf->getText();
}
else{
$content = shell_exec('/usr/bin/antiword -m UTF-8.txt '.'chmod o+r /var/www/aog-profile/web/'.$path['url']);
}
$url = sprintf(
'%s%s',
$this->container->getParameter('acme_storage.amazon_s3.base_url'),
$this->getPhotoUploader()->uploadFromUrl($path['url'])
);
$developer->setTextCv($content);
$developer->setCvUri($url);
$em->flush();
If file.doc I used antiword and setTextCv($content) and I have text in DB and I upload in amazon, BUT
If this file docx I upload docx file in /upload/Cv/file.docx and create file.html. Then I need setTextCv('text in file html') or if you know another method ? And I dont know how its do it right. Any idea?