Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> wygenerowany PDF, zapis
misiek172
post
Post #1





Grupa: Zarejestrowani
Postów: 656
Pomógł: 3
Dołączył: 26.10.2005
Skąd: Częstochowa

Ostrzeżenie: (0%)
-----


Witam.

Wygenerowałem PDFa dzieki bibliotece FPDF i chcialbym go oprocz wyswietlenia zapisac na serwerze, jak to zrobic?

Pozdrawiam, Lukasz.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
bim2
post
Post #2





Grupa: Zarejestrowani
Postów: 1 873
Pomógł: 152
Dołączył: 9.04.2006
Skąd: Berlin

Ostrzeżenie: (0%)
-----


http://www.google.com/search?q=fpdf+save&a...lient=firefox-a

Pierwszy wynik.

Ups, przepraszam ja nie doczytałem.
  1. <?php
  2. function Output($name='',$dest='')
  3. {
  4. //Output PDF to some destination
  5. //Finish document if necessary
  6. if($this->state<3)
  7. $this->Close();
  8. //Normalize parameters
  9. if(is_bool($dest))
  10. $dest=$dest ? 'D' : 'F';
  11. $dest=strtoupper($dest);
  12. if($dest=='')
  13. {
  14. if($name=='')
  15. {
  16. $name='doc.pdf';
  17. $dest='I';
  18. }
  19. else
  20. $dest='F';
  21. }
  22. switch($dest)
  23. {
  24. case 'I':
  25. //Send to standard output
  26. $this->Error('Some data has already been output, can't send PDF file');
  27. if(php_sapi_name()!='cli')
  28. {
  29. //We send to a browser
  30. header('Content-Type: application/pdf');
  31. $this->Error('Some data has already been output to browser, can't send PDF file');
  32. header('Content-Length: '.strlen($this->buffer));
  33. header('Content-disposition: inline; filename="'.$name.'"');
  34. }
  35. echo $this->buffer;
  36. break;
  37. case 'D':
  38. //Download file
  39. $this->Error('Some data has already been output, can't send PDF file');
  40. if(isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'],'MSIE'))
  41. header('Content-Type: application/force-download');
  42.  else
  43. header('Content-Type: application/octet-stream');
  44. $this->Error('Some data has already been output to browser, can't send PDF file');
  45. header('Content-Length: '.strlen($this->buffer));
  46. header('Content-disposition: attachment; filename="'.$name.'"');
  47. echo $this->buffer;
  48. break;
  49. case 'F':
  50. //Save to local file
  51. $f=fopen($name,'wb');
  52. if(!$f)
  53. $this->Error('Unable to create output file: '.$name);
  54. fwrite($f,$this->buffer,strlen($this->buffer));
  55. fclose($f);
  56. break;
  57. case 'S':
  58. //Return as a string
  59. return $this->buffer;
  60. default:
  61. $this->Error('Incorrect output destination: '.$dest);
  62. }
  63. return '';
  64. }
  65. ?>
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 26.12.2025 - 00:21