Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

2 Stron V   1 2 >  
Reply to this topicStart new topic
> [PHP]Przeglądarka nie wczytuje pdf
pawel06281990
post 19.02.2022, 19:18:11
Post #1





Grupa: Zarejestrowani
Postów: 298
Pomógł: 0
Dołączył: 10.01.2014

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


Witam,

Tworze plik pdf z mpdf ale kiedy chce wygenerować testowy pdf to przeglądarka daje komunikat błędu "Nie udało się wczytać dokumentu PDF."


Tak wygląda mój plik testowy pdf wedle producenta

  1.  
  2. // Require composer autoload
  3. require_once __DIR__ . '/vendor/autoload.php';
  4. // Create an instance of the class:
  5. $mpdf = new \Mpdf\Mpdf(['mode' => 'utf-8',
  6. 'tempDir' => __DIR__ . '/log/'
  7. ]);
  8.  
  9. $html ='Hello World';
  10.  
  11. // Write some HTML code:
  12. $mpdf->WriteHTML($html);
  13.  
  14. // Output a PDF file directly to the browser
  15. $mpdf->Output();


Dla czego tak się dzieje nawet jak dodam na początku pliku ob_start(); to nic to niedaje.
Go to the top of the page
+Quote Post
trueblue
post 19.02.2022, 19:24:30
Post #2





Grupa: Zarejestrowani
Postów: 6 767
Pomógł: 1824
Dołączył: 11.03.2014

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


Usuń ostatnią linijkę i sprawdź błędy.


--------------------
Go to the top of the page
+Quote Post
pawel06281990
post 19.02.2022, 19:31:41
Post #3





Grupa: Zarejestrowani
Postów: 298
Pomógł: 0
Dołączył: 10.01.2014

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


Cytat(trueblue @ 19.02.2022, 19:24:30 ) *
Usuń ostatnią linijkę i sprawdź błędy.


Jak usunąłem ostatnia linijkę

  1. $mpdf->Output();


To pokazuje, że nic niema w pliku a wpliku jest Hello World
Go to the top of the page
+Quote Post
dublinka
post 19.02.2022, 19:36:38
Post #4





Grupa: Zarejestrowani
Postów: 594
Pomógł: 66
Dołączył: 22.02.2008
Skąd: Dublin

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


  1. require_once __DIR__ . '/vendor/autoload.php';
  2.  
  3. $mpdf = new \Mpdf\Mpdf();
  4. $mpdf->WriteHTML('<h1>Hello world!</h1>');
  5. $mpdf->Output();


--------------------
Go to the top of the page
+Quote Post
pawel06281990
post 19.02.2022, 19:45:33
Post #5





Grupa: Zarejestrowani
Postów: 298
Pomógł: 0
Dołączył: 10.01.2014

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


Cytat(dublinka @ 19.02.2022, 19:36:38 ) *
  1. require_once __DIR__ . '/vendor/autoload.php';
  2.  
  3. $mpdf = new \Mpdf\Mpdf();
  4. $mpdf->WriteHTML('<h1>Hello world!</h1>');
  5. $mpdf->Output();


W ten sposób dostaje błąd

  1. Fatal error: Uncaught Mpdf\MpdfException: Temporary files directory "/home/twoj-host/web/test.twoj-host.eu/public_html/wp-content/plugins/zamow_msze/inc/generator1/vendor/mpdf/mpdf/src/Config/../../tmp/mpdf" is not writable in /home/twoj-host/web/test.twoj-host.eu/public_html/wp-content/plugins/zamow_msze/inc/generator1/vendor/mpdf/mpdf/src/Cache.php:21 Stack trace: #0 /home/twoj-host/web/test.twoj-host.eu/public_html/wp-content/plugins/zamow_msze/inc/generator1/vendor/mpdf/mpdf/src/ServiceFactory.php(56): Mpdf\Cache->__construct() #1 /home/twoj-host/web/test.twoj-host.eu/public_html/wp-content/plugins/zamow_msze/inc/generator1/vendor/mpdf/mpdf/src/Mpdf.php(1066): Mpdf\ServiceFactory->getServices() #2 /home/twoj-host/web/test.twoj-host.eu/public_html/wp-content/plugins/zamow_msze/inc/generator1/test.php(5): Mpdf\Mpdf->__construct() #3 /home/twoj-host/web/test.twoj-host.eu/public_html/wp-content/plugins/zamow_msze/zamow_msze.php(113): include_once('/home/twoj-host...') #4 /home/twoj-host/web/test.twoj-host.eu/public_html/w in /home/twoj-host/web/test.twoj-host.eu/public_html/wp-content/plugins/zamow_msze/inc/generator1/vendor/mpdf/mpdf/src/Cache.php on line 21


Ze nie może znaleźć folderu na zapisywanie logów ten folder tworze sam podając nazwę folderu.

Ten post edytował pawel06281990 19.02.2022, 19:47:27
Go to the top of the page
+Quote Post
trueblue
post 19.02.2022, 19:49:42
Post #6





Grupa: Zarejestrowani
Postów: 6 767
Pomógł: 1824
Dołączył: 11.03.2014

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


Cytat(pawel06281990 @ 19.02.2022, 19:31:41 ) *
To pokazuje, że nic niema w pliku a wpliku jest Hello World

Gdzie nic nie ma i w jakim pliku jest "Hello World, skoro nie wygenerowałeś PDFa?


--------------------
Go to the top of the page
+Quote Post
pawel06281990
post 19.02.2022, 19:55:40
Post #7





Grupa: Zarejestrowani
Postów: 298
Pomógł: 0
Dołączył: 10.01.2014

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


Cytat(trueblue @ 19.02.2022, 19:49:42 ) *
Gdzie nic nie ma i w jakim pliku jest "Hello World, skoro nie wygenerowałeś PDFa?


Tak wygląda mój plik

Plik nazwałem test.php
  1. // Require composer autoload
  2. require_once __DIR__ . '/vendor/autoload.php';
  3. // Create an instance of the class:
  4. $mpdf = new \Mpdf\Mpdf(['mode' => 'utf-8',
  5. 'tempDir' => __DIR__ . '/log/'
  6. ]);
  7.  
  8. $mpdf->AddPage('','E');
  9. $mpdf->SetHTMLHeader();
  10. $mpdf->AddPage();
  11. $mpdf->SetHTMLFooter();
  12. $mpdf->WriteHTML('Hello World');
  13.  
  14. // Output a PDF file directly to the browser
  15. $mpdf->Output();


I kiedy chce wygenerować pdf dostaje błąd o treści Nie udało się wczytać dokumentu PDF.

A jak usunąłem
  1. $mpdf->Output();


To nie generowało mi czystego pdf'a
Go to the top of the page
+Quote Post
trueblue
post 19.02.2022, 19:57:07
Post #8





Grupa: Zarejestrowani
Postów: 6 767
Pomógł: 1824
Dołączył: 11.03.2014

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


Cytat(pawel06281990 @ 19.02.2022, 19:55:40 ) *
A jak usunąłem
  1. $mpdf->Output();

To nie generowało mi czystego pdf'a

A jaki był wynik skryptu PHP? Nie dostałeś żadnych błędów?


--------------------
Go to the top of the page
+Quote Post
pawel06281990
post 19.02.2022, 19:59:36
Post #9





Grupa: Zarejestrowani
Postów: 298
Pomógł: 0
Dołączył: 10.01.2014

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


Jak sprawdzałem var_dump(); to było null nic mi nie wyświetliło żadnego błędu
Go to the top of the page
+Quote Post
trueblue
post 19.02.2022, 20:01:40
Post #10





Grupa: Zarejestrowani
Postów: 6 767
Pomógł: 1824
Dołączył: 11.03.2014

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


Czy możesz po prostu uruchomić ostatnio cytowany skrypt, dokładnie w takiej postaci jak wkleiłeś, ale bez ostatniej linijki i podać jego wynik?


--------------------
Go to the top of the page
+Quote Post
pawel06281990
post 19.02.2022, 20:06:54
Post #11





Grupa: Zarejestrowani
Postów: 298
Pomógł: 0
Dołączył: 10.01.2014

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


To mówię ze nic nie dostaje żadnego wyniku.

Takie coś dostaje bez ostatniej lini



Go to the top of the page
+Quote Post
trueblue
post 19.02.2022, 20:08:06
Post #12





Grupa: Zarejestrowani
Postów: 6 767
Pomógł: 1824
Dołączył: 11.03.2014

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


I ten skrypt wygenerował tekst o wordpressie?


--------------------
Go to the top of the page
+Quote Post
pawel06281990
post 19.02.2022, 20:27:49
Post #13





Grupa: Zarejestrowani
Postów: 298
Pomógł: 0
Dołączył: 10.01.2014

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


Nie ja pracuję na wordpressie bo tworze wtyczką i potrzebuje generowanie pdf
Go to the top of the page
+Quote Post
trueblue
post 19.02.2022, 21:06:22
Post #14





Grupa: Zarejestrowani
Postów: 6 767
Pomógł: 1824
Dołączył: 11.03.2014

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


A jeśli poproszę Cię trzeci raz o pokazanie wyniku kodu:

  1. // Require composer autoload
  2. require_once __DIR__ . '/vendor/autoload.php';
  3. // Create an instance of the class:
  4. $mpdf = new \Mpdf\Mpdf(['mode' => 'utf-8',
  5. 'tempDir' => __DIR__ . '/log/'
  6. ]);
  7.  
  8. $mpdf->AddPage('','E');
  9. $mpdf->SetHTMLHeader();
  10. $mpdf->AddPage();
  11. $mpdf->SetHTMLFooter();
  12. $mpdf->WriteHTML('Hello World');


to pokażesz, czy nie?


--------------------
Go to the top of the page
+Quote Post
pawel06281990
post 19.02.2022, 21:12:49
Post #15





Grupa: Zarejestrowani
Postów: 298
Pomógł: 0
Dołączył: 10.01.2014

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


No podał bym ci jak bym miał wynik a ja nie mam żadnego wyniku.

taki mam kod

  1. require_once __DIR__ . '/vendor/autoload.php';
  2. // Create an instance of the class:
  3. $mpdf = new \Mpdf\Mpdf(['mode' => 'utf-8',
  4. 'tempDir' => __DIR__ . '/log/'
  5. ]);
  6.  
  7. $mpdf->AddPage('','E');
  8. $mpdf->SetHTMLHeader();
  9. $mpdf->AddPage();
  10. $mpdf->SetHTMLFooter();
  11. $mpdf->WriteHTML('Hello World');
  12.  
  13. // Output a PDF file directly to the browser


I ten kod nie podaje mi wyniku tak jak pokazałem na zdjęciu pusto jest.
Go to the top of the page
+Quote Post
dublinka
post 19.02.2022, 21:20:37
Post #16





Grupa: Zarejestrowani
Postów: 594
Pomógł: 66
Dołączył: 22.02.2008
Skąd: Dublin

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


A sprawdziles to osobnym pliku nie jako część wordpressa. Odpal to w osobnym pliku


--------------------
Go to the top of the page
+Quote Post
pawel06281990
post 19.02.2022, 22:49:55
Post #17





Grupa: Zarejestrowani
Postów: 298
Pomógł: 0
Dołączył: 10.01.2014

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


Ok zaraz sprawdzie


EDIT:

Dodałem to na serwer bez wordpress'a i też jest pusta strona

tu jest link test pdf

Po paru zmianach zadziałało mi na czystym bez wordpressa a jak to samo dodaje do wordpress'a to mi nie działa.

Ten post edytował pawel06281990 19.02.2022, 21:44:35
Go to the top of the page
+Quote Post
viking
post 20.02.2022, 06:42:58
Post #18





Grupa: Zarejestrowani
Postów: 6 366
Pomógł: 1115
Dołączył: 30.08.2006

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


Uruchom podgląd źródła tego pustego pliku bo pewnie jakiś fatal error czy coś leci. Jeśli zapisujesz to otwórz normalnie w notatniku.


--------------------
Go to the top of the page
+Quote Post
pawel06281990
post 23.02.2022, 10:14:29
Post #19





Grupa: Zarejestrowani
Postów: 298
Pomógł: 0
Dołączył: 10.01.2014

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


Sprawdziłem i żadnych błędów niema.

Zadziwia mnie to Że przeglądarka Mozilla FireFox otwiera PDF normalnie a chrome i opera ma problem z otwarciem pliku pdf nawet program mi nie otwiera, ale jak zapisze na serwerze i pobiorę to otworzy mi ten plik i zawsze mam ten zawsze komunikat "Nie udało się wczytać dokumentu PDF." i nie wiem czemu a wszystko zrobiłem ok bo dodałem go inaczej oparłem o function żeby wordpress mógł sobie poradzić.
Go to the top of the page
+Quote Post
trueblue
post 23.02.2022, 10:27:30
Post #20





Grupa: Zarejestrowani
Postów: 6 767
Pomógł: 1824
Dołączył: 11.03.2014

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


Otwórz w Notatniku ten PDF i zobacz czy na początku nie dodały się jakieś błędy z PHP.


--------------------
Go to the top of the page
+Quote Post

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

 



RSS Wersja Lo-Fi Aktualny czas: 22.06.2024 - 15:08