Précédent   Forum des professionnels en informatique > PHP > Bibliothèques et frameworks > symfony
symfony Forum d'entraide sur le framework PHP symfony. Avant de poster : cours symfony et FAQ symfony
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 06/07/2011, 10h19   #1
Invité de passage
 
Inscription : mars 2011
Messages : 60
Détails du profil
Informations forums :
Inscription : mars 2011
Messages : 60
Points : 1
Points : 1
Par défaut Comment afficher un pdf à partir des données

Bonjour,
Je veux exporter mes données dans un fichier pdf.Mon probléme est que l'erreur suivante s'affiche toujours:500 | Internal Server Error | JpGraphExceptionL
Empty input data array specified for plot. Must have at least one data point.
.
Ma fonction pour l'affichage de pdf est la suivante:
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
public function executeExportPdf(sfWebRequest $request)
	{
		$url=sfConfig::get('sf_upload_dir');
		$this->executeGraphICSImage($request);
		$this->executeLineImage($request);
		$this->executeGraphEHSImage($request);
		$this->executeGraphIIEFImage($request);
		$this->executeGraphIPSSImage($request);
 
		require_once sfConfig::get('sf_lib_dir').'/fpdf/fpdf.php';
		$patient = $this->getUser()->getAttribute('patient');
 
 
		  $this->pdf=new FPDF();
		  $this->pdf->AddPage();
		  $this->pdf->SetFont('Arial','B',12);
		  $this->pdf->SetDrawColor(30, 136, 236);
		  $this->pdf->Cell(0,10,'IPP : '.utf8_decode($patient->getIpp()).'    Nom : '.utf8_decode($patient->getName()).'    Prenom : '.utf8_decode($patient->getFirstname()).'    Date de naissance : '.utf8_decode(date('d-m-Y', strtotime($patient->getDateOfBirth()))),1,1,'C');
		  $this->pdf->Cell(80,2,'',0,1);
		  $this->pdf->Cell(40,8,'Biopsie',1,1);
		  foreach ($patient->getBiopsies() as $biopsie)
		  {
		    $biopsie_total_droite = $biopsie->getBaseD() + $biopsie->getMoyenD() + $biopsie->getApexD();
		    $biopsie_total_gauche = $biopsie->getBaseG() + $biopsie->getMoyenG() + $biopsie->getApexG();
 
		    $this->pdf->SetFont('Arial','B',11);
		    $this->pdf->Cell(50,6,date('d-m-Y', strtotime($biopsie->getDate())),0,1);
		    $this->pdf->SetFont('Arial','',10);
		    $this->pdf->Cell(60,5,'Score de gleason : '.$biopsie->getScoreGlobal(),0);
		    $this->pdf->Cell(60,5,'Grade de gleason : '.$biopsie->getScorePremier(),0,1);
		    $this->pdf->Cell(60,5,'% de biopsies positives : '.$biopsie->getRapportBP(),0);
		    $this->pdf->Cell(60,5,'% de longueur de biopsies positives : '.$biopsie->getRapportLT(),0,1);
		    $this->pdf->Cell(60,5,'Nombre de biopsies positives : '.$biopsie->getBiopsiePositive().' dont '.$biopsie_total_droite.' a droite et '.$biopsie_total_gauche.' a gauche',0,1);
 
		  }
		  $this->pdf->SetFont('Arial','B',12);
		  $this->pdf->Cell(80,5,'',0,1);
		  $this->pdf->Cell(40,8,'Pre-op',1,1);
		  foreach ($patient->getProstateRecaps() as $preop)
		  {
		    $this->pdf->SetFont('Arial','B',11);
		    $this->pdf->Cell(25,6,date('d-m-Y', strtotime($preop->getDate())),0);
		    $this->pdf->SetFont('Arial','',10);
		    $this->pdf->Cell(25,5,'PSA : '.$preop->getPsa(),0);
		    $this->pdf->Cell(25,5,'Stade T : '.$preop->getStadeT(),0);
		    $this->pdf->Cell(25,5,'Stade N : '.$preop->getStadeN(),0);
		    $this->pdf->Cell(25,5,'Stade M : '.$preop->getStadeM(),0);
		    if ($preop->getClassificationAmico() == 0)
		    {
		      $this->pdf->Cell(30,5,'Amico : Faible risque',0);
		    }
		    elseif ($preop->getClassificationAmico() == 1)
		    {
		      $this->pdf->Cell(30,5,'Amico : Risque intermediaire',0);
		    }
		    elseif ($preop->getClassificationAmico() == 2)
		    {
		      $this->pdf->Cell(30,5,'Amico : Haut risque',0);
		    }
		  }
		  $this->pdf->SetFont('Arial','B',12);
		  $this->pdf->Cell(0,10,'',0,1);
		  $this->pdf->Cell(40,8,'Traitements',1,1);
		  foreach ($patient->getTraitementFiches() as $traitement)
		  {
		    $this->pdf->SetFont('Arial','B',11);
		    $this->pdf->Cell(25,6,date('d-m-Y', strtotime($traitement->getDate())),0);
		    $this->pdf->SetFont('Arial','',10);
		    $this->pdf->Cell(25,5,utf8_decode($traitement->getTraitement()),0,1);
		  }
 
		  $this->pdf->SetFont('Arial','B',12);
		  //$pdf->Cell(0,6,'',0,1);
		  $this->pdf->Cell(0,5,'',0,1);
		  $this->pdf->Cell(40,8,'Anapath',1,1);
		  foreach ($patient->getAnapaths() as $anapath)
		  {
		    $this->pdf->SetFont('Arial','B',11);
		    $this->pdf->Cell(25,6,date('d-m-Y', strtotime($anapath->getDate())),0);
		    $this->pdf->SetFont('Arial','',10);
		    $this->pdf->Cell(30,5,'Stade pT : '.$anapath->getStadepT(),0);
                    $this->pdf->Cell(30,5,'Stade pN : '.$anapath->getStadepN(),0);
		    $this->pdf->Cell(40,5,'Score Gleason : '.$anapath->getGleason(),0);
		    $this->pdf->Cell(40,5,'Grade Gleason : '.$anapath->getGleasonMax(),0,1);
		  }
 
		  $this->pdf->SetFont('Arial','B',12);
		  //$pdf->Cell(0,6,'',0,1);
		  $this->pdf->Cell(0,5,'',0,1);
		  $this->pdf->Cell(40,8,'Suivi',1,1);
		  foreach ($patient->getSuivis() as $suivi)
		  {
		    $this->pdf->SetFont('Arial','B',11);
		    $this->pdf->Cell(25,6,date('d-m-Y', strtotime($suivi->getDate())),0);
		    $this->pdf->SetFont('Arial','',10);
		    if ($suivi->getRecidive() == 0)
		    {
		      $this->pdf->Cell(50,5,utf8_decode('1ere récidive'),0,1);
		    }
		    if ($suivi->getRemission() == 0)
		    {
		      $this->pdf->Cell(50,5,utf8_decode('Rémission sans TTT'),0,1);
		    }
		    elseif ($suivi->getRemission() == 1)
		    {
		      $this->pdf->Cell(50,5,utf8_decode('Rémission avec TTT complémentaire'),0,1);
		    }
		    elseif ($suivi->getRemission() == 2)
		    {
		      $this->pdf->Cell(50,5,utf8_decode('Aucune rémission'),0,1);
		    }
		    elseif ($suivi->getRemission() == 3)
		    {
		      $this->pdf->Cell(50,5,utf8_decode('Rémission douteuse'),0,1);
		    }
		    if ($suivi->getTraitementComps()->count() > 0)
		    {
		      $this->pdf->Cell(50,5,utf8_decode('Traitements complémentaires : '),0);
 
		      foreach ($suivi->getTraitementComps() as $test)
		      {
		        $this->pdf->Cell(30,5,utf8_decode($test),0);
		      }
 
		    }
		    $this->pdf->Cell(0,6,'',0,1);
		    if ($suivi->getMetastase() == 0)
		    {
		      $this->pdf->Cell(50,6,'Metastases : '.date('d-m-Y', strtotime($suivi->getDateMeta())),0,1);
		      $this->pdf->Cell(20,5,'Type : ',0);
		    if ($suivi->getOs() == 1)
		    {
		      $this->pdf->Cell(20,5,'OS',0);
		    }
		    if ($suivi->getGamma() == 1)
		    {
		      $this->pdf->Cell(20,5,'Gamma',0);
		    }
		    if ($suivi->getAutre() == 1)
		    {
		      $this->pdf->Cell(20,5,$suivi->getAutreComm(),0);
		    }
 
		    }
		    $this->pdf->Cell(0,6,'',0,1);
		  }
		  $this->pdf->SetFont('Arial','B',12);
		  $this->pdf->Cell(0,6,'',0,1);
		  $this->pdf->Cell(0,5,'',0,1);
 
		  if($patient->getDateOfDeath() <> NULL )
		  {
		    $this->pdf->Cell(40,8,utf8_decode('Décès'),1,1);
		    $this->pdf->Cell(60,6,utf8_decode('Patient décédé le '.date('d-m-Y', strtotime($patient->getDateOfDeath()))),0);
		    if($patient->getCauseOfDeath() == 0 )
		    {
		      $this->pdf->Cell(20,5,utf8_decode(', le décès est lié à la pathologie'),0);
		    }
		  }
 
                $this->pdf->AddPage();
                $this->pdf->SetFont('Arial','B',12);//définition de la police
                $this->pdf->Cell(0,5,'',0,1);
		$this->pdf->Cell(40,8,'Graphiques',1,1);
                $this->pdf->Image($url.'/Graph/PSA.png',10,40,50,50);
		$this->pdf->Image($url.'/Graph/ICS.png',60,40,50,50);
		$this->pdf->Image($url.'/Graph/EHS.png',10,110,50,50);
		$this->pdf->Image($url.'/Graph/IIEF.png',60,110,50,50);
		$this->pdf->Image($url.'/Graph/IPSS.png',10,170,50,50);
		$this->pdf->Ln(50);//Saut de ligne
 
		$this->pdf->Output();
                $this->setTemplate('pdf');
Pourriez vous m'aider pour afficher les données dans un fichier pdf?
farhaenis est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/07/2011, 10h36   #2
Membre chevronné
 
Avatar de Herode
 
Développeur Web
Inscription : mars 2005
Messages : 769
Détails du profil
Informations personnelles :
Localisation : France, Savoie (Rhône Alpes)

Informations professionnelles :
Activité : Développeur Web

Informations forums :
Inscription : mars 2005
Messages : 769
Points : 788
Points : 788
C'est une question sur JpGraph, pas une question sur symfony. Tu auras plus facilement des réponses dans le sous-forum dédié.
Herode est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/07/2011, 11h13   #3
Invité de passage
 
Inscription : mars 2011
Messages : 60
Détails du profil
Informations forums :
Inscription : mars 2011
Messages : 60
Points : 1
Points : 1
Pourriez vous me donner l'url du forum correspondant?
farhaenis est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/07/2011, 11h36   #4
Membre chevronné
 
Avatar de Herode
 
Développeur Web
Inscription : mars 2005
Messages : 769
Détails du profil
Informations personnelles :
Localisation : France, Savoie (Rhône Alpes)

Informations professionnelles :
Activité : Développeur Web

Informations forums :
Inscription : mars 2005
Messages : 769
Points : 788
Points : 788
Celui là m'a l'air lié à la bibliothèque qui te pose problème :
http://www.developpez.net/forums/f10...mages/jpgraph/
Herode est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 08/07/2011, 16h04   #5
Membre éclairé
 
Inscription : août 2007
Messages : 360
Détails du profil
Informations forums :
Inscription : août 2007
Messages : 360
Points : 334
Points : 334
Bonjour,

Pourquoi utiliser un plugin, alors que tu pourrais développer toi même ton propre code ?

Regardes du coté d'un très bon tutoriel :

http://jc-cornic.developpez.com/tuto.../pdf/index.php

Dans le cas contraire, penses au tag [Résolu]...

Cordialement,

Mathieu
mathieu44800 est déconnecté   Envoyer un message privé Réponse avec citation 02
Vieux 09/07/2011, 22h40   #6
Modérateur
 
Avatar de Michel Rotta
 
Homme Michel Rotta
Responsable d'exploitation informatique
Inscription : septembre 2005
Messages : 4 913
Détails du profil
Informations personnelles :
Nom : Homme Michel Rotta
Âge : 49
Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

Informations professionnelles :
Activité : Responsable d'exploitation informatique
Secteur : Distribution

Informations forums :
Inscription : septembre 2005
Messages : 4 913
Points : 7 505
Points : 7 505
Pour ne pas réinventer la roue...

Il y a une bibliothèque qui semble très prometteuse dompdf si tu n'es pas trop avancé dans ton projet, c'est peut-être une solution. Je n'ai pas testé directement, mais les résultats vu sont prometteurs.
__________________
Si tu donnes un poisson à un homme, il mangera un jour. Si tu lui apprends à pêcher, il mangera toujours (Lao Tseu).
  • Pensez à valoriser les réponses pertinantes, cliquez sur le bouton vert +1 pour indiquer votre accord avec la solution proposée.
  • Pensez à utiliser la balise [code] pour afficher du code, elle est cachée sous le bouton [#] dans l'éditeur.
  • Une discussion est terminée ? Alors le bouton est votre ami !
Michel Rotta est déconnecté   Envoyer un message privé Réponse avec citation 10
Vieux 11/07/2011, 11h09   #7
Membre actif
 
Homme Fabrice Agnello
Développeur informatique
Inscription : octobre 2010
Messages : 76
Détails du profil
Informations personnelles :
Nom : Homme Fabrice Agnello
Âge : 39
Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

Informations professionnelles :
Activité : Développeur informatique
Secteur : Industrie

Informations forums :
Inscription : octobre 2010
Messages : 76
Points : 161
Points : 161
Citation:
Envoyé par Michel Rotta Voir le message
Pour ne pas réinventer la roue...

Il y a une bibliothèque qui semble très prometteuse dompdf si tu n'es pas trop avancé dans ton projet, c'est peut-être une solution. Je n'ai pas testé directement, mais les résultats vu sont prometteurs.
+1.

D'ailleurs, pour SF 1.4, j'ai fait un POC portant sur l'intégration de dompdf dans les formats de réponse de symfony et cela fonctionne plutôt bien. Pour ça, il faut ajouter une classe gérant les réponses de type "pdf" (dans le POC, cette classe a été ajoutée dans le répertoire lib, mais ça peut faire l'objet d'un plugin).

classe :
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/**
 * sepWebResponse class.
 *
 * This class manages web reponses. It supports cookies and headers management.
 * It allows to render PDF files directly from HTML source and still renders the
 * regular formats used by symfony
 *
 * @package    sep
 * @subpackage response
 * @author     Fabrice AGNELLO <fabrice.agnello@gmail.com>
 */
class sepWebResponse extends sfWebResponse
{
  /**
   * Transformation method from HTML to PDF
   * @param string $content the HTML content
   * @return string the PDF document
   */
  private function transformHtmlToPdf($content)
  {
    //  we use the DOMPDF library
    require_once(realpath(dirname(__FILE__)).'/vendor/digitaljunkies/dompdf/dompdf_config.inc.php');
 
    // let's transform to pdf...
    $dompdf = new DOMPDF();
    $dompdf->load_html($content);
    $dompdf->render();
    return $dompdf->output();
  }
 
  /**
   * @see sfWebResponse::sendContent
   */
  public function sendContent()
  {
    $event = $this->dispatcher->filter(new sfEvent($this, 'response.filter_content'), $this->getContent());
    $content = $event->getReturnValue();
 
    if ($this->options['logging'])
    {
      $this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Send content (%s o)', strlen($content)))));
    }
 
    // which content is asked by user ? If it is PDF, the go to the transform method
    $request = sfContext::getInstance()->getRequest();
    if($request->getRequestFormat() == 'pdf')
      $content = $this->transformHtmlToPdf($content);
 
    // render to the browser
    echo $content;
  }
}
?>
l'utilisation est assez naïve, sans gestion d'erreur, mais c'était juste un POC, donc...

Ensuite, il suffit d'ajouter ce gestionnaire de réponse dans le fichier factories.yml :
Code :
1
2
3
4
all:
  ...
  response:
    class: sepWebResponse
puis dans le routing, on peut alors spécifier le format de sortie :
par exemple =>
Code :
1
2
3
4
document_view:
  url:   /document/view/id.:sf_format
  param: {module: document, action: view, sf_format: [pdf, html] }
...
de là, dans les vues rattachées à l'action executeView du module documentActions, on aura deux fichiers :
- viewSuccess.php
- viewSuccess.pdf.php


dont le viewSuccess.pdf.php est la vue HTML qui sera transformée en PDF.

Ca marchait plutôt bien, et ça permet de rester dans le cadre classique de Symfony.

Reste que cette bibliothèque DOMPDF est assez jeune et que l'utilisation naïve que j'en ai fait dans l'exemple ne convient pas pour toutes les présentations.

Bon, c'est HS par rapport à la question de l'OP, mais c'était pour rebondir sur le couple Symfony/DOMPDF.
Agnello Fabrice est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 03h21.


 
 
 
 
Partenaires

Hébergement Web