Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


Thansk for your reply, this the Php code I'm usign :
<?php
class CreatePdfDoc
{
var $tpl_file_path ; //le chemin de fichier template.rtf
var $tmp_file_path ; //le chemin de fichier temporaire.rtf : qui permet de
recevoir le contenu depuis le template et les valeurs depuis bdd
var $pdf_file_path ; //le chemin de fichier pdf à générer.
var $Name_pdf_file ;   //le nom de de fichier pdf à générer.
var $tpl_file_Content ; //le contenu
 var $baseUrl ;
 static private $_instance = null;
 static public function getInstance()
{
if (!self::$_instance instanceof self) {
self::$_instance = new self();
}
return self::$_instance;
}
 //récupérer le contenu de fichier template
function get_tpl_contenu()
{
$this->tpl_file_Content =  @file_get_contents($this->tpl_file_path);
}
 //On remplace les mots-clés de template dans le contenu , un à un
function affecter_valeur_template($champs,$valeur="")
{
$this->tpl_file_Content =
str_replace($champs,$valeur,$this->tpl_file_Content);
}
 //générer un fichier temporaire de type rtf depuis le contenu déjÃ
 modifier
function genere_tmp_file()
{
file_put_contents($this->tmp_file_path,$this->cleantext());
}
 //conversion de fichier temporaire de type rtf vers pdf
function genere_pdf_file()
{
// générer le fichier temporaire rtf
$this-> genere_tmp_file();
 //lire fichier depuis config
$config = new Zend_Config_Ini ( '../application/config/config.ini',
'general' );
 //exécuter la commande de libreoffice qui permet de convertir un document
en pdf.
exec ('"'.$config->libreOfficePath.'" --headless -convert-to pdf
"'.$this->tmp_file_path.'" -outdir "'.$this->pdf_file_path.'"  2>&1 &
',$out);
 if (!empty($out))
{
echo "le fichier a été générer avec sucés";
}
else
{
echo "la création de fichier n'a pas terminé";
}
chdir($this->baseUrl);
}
//supression de fichier temporaire
function delete_tmp_file()
{
unlink($this->tmp_file_path);
}
 //permet de remplacer les carctère spéciaux dans le contenu avant de
l'imprimer sur le fichier RTF temporaire
function cleantext()
{
//le retour à ligne et le caractère € nécessite ce traitement pur peuvoir
générer un fichier rtf
$ReplaceCarc = array('<br>'=>'\par','€'=>'{\rtlch\fcs1 \af1\afs16
\ltrch\fcs0 \f1\fs16\insrsid280348
\loch\af1\dbch\af31505\hich\f1\\\'80\loch\f1}');

//Remplacer les valeurs dans les  selon les tableaux
$result = strtr($this->tpl_file_Content,$ReplaceCarc);

//Resultat à  retourner
return utf8_decode($result);
}
}
?>


2012/9/7 Jay Lozier <jslozier@gmail.com>

On 09/07/2012 05:51 AM, Mourad Hedfi wrote:
Hello everybody,
I've developped a Php application and I'm using the Writer of LibreOffice
3.5 to convert rtf document to pdf. The command is "libreoffice3.5
--headless -convert-to pdf
/var/www/Caneva/public/files/client/377/factures/1-789452012-0001.rtf
 -outdir /var/www/Caneva/public/files/client/377/factures  2>&1"

The command works fine in the terminal, but when a call it from Php, it
throughts the following error : "terminate called after throwing an
instance of 'com::sun::star::uno::RuntimeException".

I'm on Linux Cent OS 6.0. Doe's anyone have an idea about this problem
and
can help me to resolve it.

Many thank in advance.
Best regards.

Hi,

Please post the php code. Since it works fine in terminal, I would
expect there to be bug in the PHP code.

--
Jay Lozier
jslozier@gmail.com


--
For unsubscribe instructions e-mail to: users+help@global.libreoffice.org
Problems?
http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be
deleted



-- 
For unsubscribe instructions e-mail to: users+help@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.