Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> 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
bim2
post
Post #2





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

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


Może pokaż jak go wyświetlasz? (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post
misiek172
post
Post #3





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

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


jak to jak wyswietlam? $pdf->Output();
Go to the top of the page
+Quote Post
bartg
post
Post #4





Grupa: Zarejestrowani
Postów: 226
Pomógł: 25
Dołączył: 4.07.2007
Skąd: Berlin

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


  1. <?php
  2. $pdf->Output()
  3. $result = ob_get_contents();;
  4. ?>

I zawartość $result zapisujesz do pliku (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg) .

Chyba że istnieje jakaś funkcja w tej klasie (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)

DOWN: No właśnie, istnieje (IMG:http://forum.php.pl/style_emoticons/default/biggrin.gif)

Ten post edytował bartg 30.06.2008, 14:06:53
Go to the top of the page
+Quote Post
bim2
post
Post #5





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

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


No to
$pdf -> Output($filename,$dir);
Go to the top of the page
+Quote Post
misiek172
post
Post #6





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

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


to moze jakos przerobic te funkcje Output?

Ten post edytował misiek172 30.06.2008, 15:06:25
Go to the top of the page
+Quote Post
bartg
post
Post #7





Grupa: Zarejestrowani
Postów: 226
Pomógł: 25
Dołączył: 4.07.2007
Skąd: Berlin

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


Nie rozumiem, przecież bim podał gotowe rozwiązanie.
Go to the top of the page
+Quote Post
misiek172
post
Post #8





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

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


bo nie czytal manuala, ze ta funkcja ma inna konstrukcje

http://www.fpdf.org/en/doc/output.htm

Ten post edytował misiek172 30.06.2008, 16:43:37
Go to the top of the page
+Quote Post
bim2
post
Post #9





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
misiek172
post
Post #10





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

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


a jakbym aby jednocześnie sie zapisało i wyświetlilo?
Go to the top of the page
+Quote Post
bartg
post
Post #11





Grupa: Zarejestrowani
Postów: 226
Pomógł: 25
Dołączył: 4.07.2007
Skąd: Berlin

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


Wywołać 2x funkcje Output? Możliwe że zaskoczy
Go to the top of the page
+Quote Post
misiek172
post
Post #12





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

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


nie poniewaz wyskoczy blad ze header alerdy send
Go to the top of the page
+Quote Post
bim2
post
Post #13





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

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


$this->Output('adres do pliku itd', 'F'); //To nie wysyła żadnych nagłówków...
$this->Output();
Go to the top of the page
+Quote Post

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: 25.08.2025 - 15:43