Précédent   Forum des professionnels en informatique > PHP > Bibliothèques et frameworks > PDF > FPDF
FPDF Forum d'entraide pour la bibliothèque FPDF permettant de générer des documents PDF en PHP. Avant de poster -> tutoriels FPDF
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 07/09/2006, 17h53   #1
Membre confirmé
 
Inscription : mars 2003
Messages : 674
Détails du profil
Informations forums :
Inscription : mars 2003
Messages : 674
Points : 242
Points : 242
Par défaut [FPDF] ouvrir un fichier PDF

Bonjour.

Tout est dans le titre!!
J'ai un fichier au format PDF et je cherche à l'ouvrir mais ça marche pas
Code :
1
2
3
4
 
<li><a href="index.php?page=sept06">&nbsp;&nbsp;Septembre 2006</a></li>
......
case 'sept06': include ('newsletter/NL0906.pdf');break;
J'ai un message Parse error mais je vois pas pourquoi
philippef est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 07/09/2006, 20h29   #2
Membre chevronné
 
Avatar de Elwyn
 
Homme
Ingénieur systèmes et réseaux
Inscription : juillet 2006
Messages : 836
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations professionnelles :
Activité : Ingénieur systèmes et réseaux

Informations forums :
Inscription : juillet 2006
Messages : 836
Points : 712
Points : 712
T'as le droit d'inclure un pdf ? Fais un lien ...

Code :
1
2
3
4
 
case sept06:
echo '<a href="newsletter/NL0906.pdf">Lien</a>';
break;
__________________
Dire Straits, Bob Dylan, Led Zeppelin, the Who, Pink Floyd, AC/DC, Guns & Roses, the Doors, ...
Elwyn est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 07/09/2006, 20h38   #3
Membre éprouvé
 
Homme
Inscription : mai 2006
Messages : 694
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 31
Localisation : Belgique

Informations forums :
Inscription : mai 2006
Messages : 694
Points : 417
Points : 417
Effectivement include ne peut ouvrir que des scripts php!

Regarde du côté des fonctions pdf --> http://be.php.net/manual/fr/ref.pdf.php

webrider
webrider est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 07/09/2006, 20h40   #4
Membre éprouvé
 
Homme
Inscription : mai 2006
Messages : 694
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 31
Localisation : Belgique

Informations forums :
Inscription : mai 2006
Messages : 694
Points : 417
Points : 417
Voilà la fonction exacte que tu dois utiliser : PDF_open_pdi()

@++

webrider
webrider est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 08/09/2006, 10h09   #5
Membre confirmé
 
Inscription : mars 2003
Messages : 674
Détails du profil
Informations forums :
Inscription : mars 2003
Messages : 674
Points : 242
Points : 242
Merci pour votre aide
philippef est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 17/10/2010, 23h33   #6
Invité de passage
 
Inscription : octobre 2010
Messages : 1
Détails du profil
Informations forums :
Inscription : octobre 2010
Messages : 1
Points : 1
Points : 1
Voici ce que j'ai trouvé après plusieurs jours de recherche. En fait, je crois qu'il n'y a pas de moyen direct de lire un fichier pdf sur internet en php. J'ai commencé par trouvé PDFLib TET (Text Extraction Toolkit), qui extrait un fichier pdf en texte. Malheureusement, il ne peut pas lire des fichiers directement du web. Donc, on charge d'abord le contenu du fichier pdf web dans un fichier virtuel, ensuite on peut lire ce fichier virtuel pdf, et finalement on l'extrait pour obtenir un fichier texte.

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
<?php 
 
//1-download fichier à http://www.pdflib.com/download/tet/ (version windows xp 32 bits, TET-4.0p2-MSWin32.msi) 
//2-installer sur un ordi, pas obliger d'être le serveur 
//3-aller C:\Program Files (x86)\PDFlib\TET 4.0p2 32-bit\bind\php, il y a les versions de php 
//4-prendre libtet_php.dll dans le bon répertoire représentant la version de php installé 
//5-mettre ce fichier dans le répertoire de php\ext et modifier php.ini pour mettre extension=libtet_php.dll 
// il doit y avoir une section TET lorsqu'on fait php phpinfo();  
 
 
// ***   $Id: extractor.php,v 1.11 2010/07/21 19:58:35 rjs Exp $ Simple PDF text extractor based on PDFlib TET   *** 
$globaloptlist = "searchpath={../data ../../data ../../../resource/cmap}"; //global option list 
$docoptlist = "";       // document-specific option list 
$pageoptlist = "granularity=page";     // page-specific option list 
$separator = "\n";    // separator to emit after each chunk of text. This depends on the application's needs; for granularity=word a space character may be useful 
 
$pageno = 0; 
 
try { 
 
    $tet = new TET(); 
 
//mettre ici les infos nécessaire 
$filepdf = file_get_contents('http://www.irs.gov/pub/irs-pdf/fw4.pdf'); //adresse web du fichier PDF 
$pvf_filename = "/pvf/virt.pdf";     //nom du fichier virtuel, peux laisser tel quel 
$tet->create_pvf($pvf_filename, $filepdf,"" );    //ici c'est la création dufichier virtuel, donc pas touche 
$infilename = $pvf_filename; 
$outfilename = "fichier.txt";      //nom du fichier de sortie 
 
 
    if (!$outfp = fopen("$outfilename", "wb" )) { 
 die("Couldn't open output file '" . $outfilename . "'\n" ); 
    } 
 
 
    $tet->set_option($globaloptlist); 
 
    $doc = $tet->open_document($infilename, $docoptlist); 
 
    if ($doc == -1) { 
 die("Error ". $tet->get_errnum() . " in " . $tet->get_apiname() 
     . "(): " . $tet->get_errmsg() . "\n" ); 
    } 
 
    /* get number of pages in the document */ 
    $n_pages = $tet->pcos_get_number($doc, "length:pages" ); 
 
    /* loop over pages in the document */ 
    for ($pageno = 1; $pageno <= $n_pages; ++$pageno) { 
 
 $page = $tet->open_page($doc, $pageno, $pageoptlist); 
 
 if ($page == -1) { 
     print("Error ". $tet->get_errnum() ." in ". $tet->get_apiname() 
  . "(): " . $tet->get_errmsg() . "\n" ); 
     next;                        /* try next page */ 
 } 
 
 /* Retrieve all text fragments; This is actually not required 
  * for granularity=page, but must be used for other granularities. 
  */ 
 while (($text = $tet->get_text($page)) != "" ) { 
 
     fwrite($outfp, $text);  /* print the retrieved text */ 
 
     /* print a separator between chunks of text */ 
     fwrite($outfp, $separator); 
 } 
 
 
 if ($tet->get_errnum() != 0) { 
     print("Error ". $tet->get_errnum() . " in " .  
      $tet->get_apiname() . "(): on page $pageno"  
      . $tet->get_errmsg() . "\n" ); 
 } 
 
 $tet->close_page($page); 
    } 
 
    fclose($outfp); 
 
    $tet->close_document($doc); 
} 
catch (TETException $e) { 
    if ($pageno == 0) { 
 die("TET exception occurred in extractor sample:\n" . 
     "[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " . 
     $e->get_errmsg() . "\n" ); 
    } else { 
 die("TET exception occurred in extractor sample:\n" . 
     "[" . $e->get_errnum() . "] " . $e->get_apiname() . 
     "on page $pageno: " .  $e->get_errmsg() . "\n" ); 
    } 
} 
catch (Exception $e) { 
    die($e); 
} 
 
$tet = 0; 
 
?>
waldo955 est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 16h34.


 
 
 
 
Partenaires

Hébergement Web