Autor Zprva
maniakum
Profil
Ahoj,

Pomoc knihovny MPDF si vytvm PDF soubor. Generovn funguje v podku, ale pokud nastavm, e ho nechci uloit na serveru, ale u klienta, tak se mi soubor njak zmrv a nejde otevt, m i jinou velikost. To sam je pokud soubor ulom na serveru a chci ho silou pomoc header sthnout.

include("mpdf/mpdf.php");
      $mpdf = new mPDF('cp1250','A4');
      $mpdf->allow_charset_conversion=true;  // Set by default to TRUE
      $mpdf->charset_in='windows-1250'; 
      $mpdf->useOnlyCoreFonts = true;
      $mpdf->SetDisplayMode('fullpage');
      $mpdf->SetAutoFont(0);   
      
      // CSS soubor
      $stylesheet = file_get_contents('css/pdf.css');
      // faktura v HTML (PHP, atd.)
      $html = file_get_contents($html_pobocky);
     // $paticka = utf8_encode('');
      $mpdf->defaultfooterfontsize = 12; 
      $mpdf->defaultfooterfontstyle = "calibri"; 
      $mpdf->defaultfooterline = 0;
      $mpdf->SetHTMLFooter('
      <p align="right">
      <img src="images/logo.png" width="150px">
      </p>
      ');
    
      $mpdf->WriteHTML($stylesheet,0);
      $mpdf->WriteHTML($html_pobocky,2);
       $mpdf->debug=true;
      //$odkaz = mb_substr($_GET['odkaz'], 8, -5);
      //$name = $_GET["jmeno_souboru"];
      $mpdf->Output($filename); // download     */
      
     
if (file_exists($filename)) {
   header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="downloaded.pdf"');
readfile($filename.'.pdf');
}           

toto je pokud to ukldm na serveru a chci vynutit sthnut. Pokud zmnm

$mpdf->Output($filename, "D");

tak jak pou v dokumentaci MPDF, aby se soubor pmo stahoval, tak je to to sam, soubor nelze otevt. Pedpokldm, e mm nkde nco patn nastaven. V em by mohl bt problm?
Taps
Profil
maniakum:
take PDF ani neoteve ? jak tedy v e ti generovn funguje v podku ?
maniakum
Profil
Taps:
Acrobat mi ekne, e je pokozen. Pokud si vytvom PDF odkazem na soubor, ve kterm mm toto:

require("mpdf/mpdf.php");
$mpdf = new mPDF('cp1250','A4');
$mpdf->allow_charset_conversion=true;  // Set by default to TRUE
$mpdf->charset_in='windows-1250'; 
$mpdf->useOnlyCoreFonts = true;
$mpdf->SetDisplayMode('fullpage');
$mpdf->SetAutoFont(0);

// CSS soubor
$stylesheet = file_get_contents('css/pdf.css');
// faktura v HTML (PHP, atd.)
$html = file_get_contents($_GET["odkaz"]);
$paticka = utf8_encode('');
$mpdf->defaultfooterfontsize = 12; 
$mpdf->defaultfooterfontstyle = "calibri"; 
$mpdf->defaultfooterline = 0;
$mpdf->SetHTMLFooter('
<p align="right">
<img src="images/logo.png" width="150px">
</p>
');

$mpdf->WriteHTML($stylesheet,0);
$mpdf->WriteHTML($html,2);
//$odkaz = mb_substr($_GET['odkaz'], 8, -5);
$name = $_GET["jmeno_souboru"];
$mpdf->Output($name,"D"); // download

Tak se mi PDF sthne a je to v podku. Nebo pokud to v tom samm souboru jako mm data nechm uloit na server, tak je to taky v podku. Pokud PDF generuji pmo ve zdrojovm souboru a nechm to sthnout, tak nejde otevt a m vt velikost.
maniakum
Profil
Jet doplnm, e na hostingu mi to funguje, proto si myslm, e mm nkde nco patn nastaveno v konfiguraci serveru. Jen pesn netum co mm hledat.


Pi zpracovn BB znaek dolo k samovolnmu sern celho pspvku. Pardon.
Tak jet dal indicie, pokud chci, aby mi to automaticky PDF sthlo, tak obsah PDF souboru je toto:

[pre]
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=cp-1250">
<meta http-equiv="Content-language" content="cs">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<title>
</title>
<link href="css/style.css" rel="stylesheet" type="text/css">

<script type="text/javascript" src="jquery.js"></script>
<script type='text/javascript' src='jquery.autocomplete.js'></script>
<link rel="stylesheet" type="text/css" href="jquery.autocomplete.css" />
<script type="text/javascript" language="javascript" src="chainedselects.js"></script>
<script type="text/javascript" language="javascript" src="config.js"></script>
<script type="text/javascript" src="jquery.jqplot.min.js"></script>
<script type="text/javascript" src="plugins/jqplot.barRenderer.min.js"></script>
<script type="text/javascript" src="plugins/jqplot.categoryAxisRenderer.min.js"></script>
<script type="text/javascript" src="plugins/jqplot.pointLabels.min.js"></script>
<script type="text/javascript" src="plugins/jqplot.canvasTextRenderer.min.js"></script>
...
[/pre]
pak teprve je pdf

[pre]
%PDF-1.4
%
3 0 obj
<</Type /Page
/Parent 1 0 R
/MediaBox [0 0 595.280 841.890]
/TrimBox [0.000 0.000 595.280 841.890]
/Resources 2 0 R
/Group << /Type /Group /S /Transparency /CS /DeviceRGB >>
/Contents 4 0 R>>
endobj
4 0 obj
<</Filter /FlateDecode /Length 8156>>
stream
x]q·_

!x‘*bd)rEZ±D‰©eU%•Cd™…!ƒ`tƒA«[,KB=g0=3*ʲ$o)_–nz,±q2U‡k¬=8tE™/]PCn }tG·U;®»·7}^/o Ъ¶/†®¶,·S7i&q•&•[?c }}¦e1zl»y€ں‡&ǪqvUYe†TMzߪIlʶzCY +y*‹¦tMoF©tmSC<aqvTZG8µp¶:RHEH9]HiHiHiN˜©–&s•nN9_r޺9q#q#9a~6Z†sʴXnN9_r޺9q#q#9a~6Z†s þ9|•sy”٬”٬”„‘h©z,A9rN9oݶ8‘8‘Ҷ0?R-9U
E;”9|•sy”٬”٬”„‘h©7;ݶr9usJGJGJsHmT7•fN9µz«”y)•:R¶VhNucWnN9µz«”٬”٬”„‘ht®oteo>‡¶
o2 ?䢵+9_0"ξ.Ծ4ξ4ξ4'̳lfUn}+ƴmal‹n»—y‡f?fS~µ‰t;q‘F|f˜Ϫ¬4j.»wEڬ4¬q?d˜a$± Yc0lvrƒ»
Y';:µ¦g]cxEԶ_™3V;aټ:&Bƒ®™/"{swop:x$µ7&޹x߹S‰¶/5€$‹“-‰v{˜O— $‡}ٻRޯ9™'wZa43xo™xi}m#—6v$-t…U[iv=3
¶¦™3o<}>‘>‘>‘‰*>‘>‘>‘sDDDF©™™>®Od®Od®Od®Od®Od®Od.Df0—›±±wf1—ϲw쫽6*+bwŶ;3•{g]̺6Go=Ҷf*a}!›.©†!e„l›¦†…|}—f”~0g] ʬK3—3™?y(¦˜ձMVfw=Fp D"=>1›$·ٻ.+L:4µQ0Fj'l4‹¬3˳'~vO¦jq,E>·iWG“c·U_txvC1•4™@ܾ`]9c5±`K+s.'\¬4fUeNQ׹U$ҭ›&ƒr3•hf« i2nyyUsžϬ±z»¶-©'˜<Pe g 6>-fj9U]]TUdgd‰o†hO
_¬ukA*Hʮvn~g:’O,vicw&Q‘|b±;*Hf”>®2~i{¬A.\M$l‰'#“I=bn2K•Q$|e––QT5? <:˜VC=-_•O$”IJ·¦F—O†<O»:yµ‚ZD"“}h>©“V,h/
¶vu‰D,~#D"¬jS•M$Tk†>M Wev©?.›ozKM6‘H4›r8»Ue ;+›MMU“"·soTlˆD®5I·}‘PU‘`•›7[4±ˢr*© 8iɴ"q"iQ·[+a›#.H‹?o;#D"Q·ӵWED"/’•Hu‡®®9ƒ·µ’]©›¦CV*Ұ'© ¬ .›h֮|
>$›x-Lm6‘kt hyάl24XgecSwµ84_pj®i~\-erˆ„mm_«mGwµנRC9D"/#PµuҹC$X®’–;M†bvͽ C$|•4_!=0L=7:l —E d>»KkbE,rg“j—G-•»ɨ·$Av•ˆ/q
O`r#?ˆ?6gKy_·|u·9[;۰'dQs¶¬†6)N`ùڤK–e†6)N`ùڤK†6)N`ùڤK–…6)N`ùڤK’…6)N`ùڤK–K…6)N`ùڤK…6)N`ùڤK–6!'aGmR%b <BwV`ùڤKµl'b6¬ͮ~AwiF|UDJ4R^/߬@0IHZp‚ƒ{‚I"G‚€#<˜L9’b`’‘ ˆu“DG/8™%˜$r$78 |-($‘#A‘n« & µ@3_b G€C=`‡‚@G·=, ’f¬[7wJ¶e!Bl%c!B4Dȹ"$z,F=”‡aI—D ‡!m¶†’±(!P&"v›\=&„JE„
‚K„Cˆ8I@pIXz(g .~C z,"g«C\X z,X+b(X†v&[g+;n%[~;C09 MpIP z¬‚v_‚K‡jcL7·\=T+ˆk‡`r•“’ZAX;“‹—D
!˜o#$zV=|S%Cµ‚±v&[.«B‚†W=T+„~C;± V`Qĭk‡dr^]d¶»yVE—®’y-
‚K‡jCL+G\=T+ˆj‡dr^'’ZAP;$“ —D
‡!™'$zV=|7%Cµ‚vH&› .‰DµC29Kp Xz¬’W=T+„k•?
0q«}}arVZ±g¬d‹/];"L2\=V+„jG„Y"‚Kj…Cˆ09+CpIXz&gf.‰«Bµ#¬
%cµBvD˜!$z¬V=Ԯ“R—D
‡arV‚7
arV!A
±B+†®>nh‡`®«©‰•?c¬d‹o‡v&±+"n•DLcVE*‰!˜
¬8UZµC0Xqq«>&j‡`r+(Vi}L>V`Qĭ˜‚}¬ˆ[1Q;“±B+"n•DL[ ¬8UZµƒ bVE*i’LM%® _›KUT”~_[•»¶)†•붯rU®8›(g«9a®6ZSs#4E5/A]G*+9o]:)) #µ2Sµ‘ P)«S[74~4~4'̬FpNUa8_.)«S[74~4~4'̬FpN••99|•sy”٬”٬”„‘h©t}usj©[5TH©‘Ru¶ZFsˢ]ѶZ}usjV)•)) #µ2STtrpN9_r޺9q#q#9a~6Z†sնr9usJGJGJsHm T;M«SW9·nNiHiHiN˜©–Q%®k‹fB/:_ |U_U•UO4'_–u•»¶/»h%pR•i‹TG!••QHe%p•iU﹵(«2ƤN#J‘`+|•®֤®&Re—®lѴgUE]*s5*TuuX0U‹*[©v‹#5Q»+ڲc™TYE"]&'P—“ƒ«‰®];Rn–†"UJMkF1\“«X
‰G*V!ְ¶.*t.“Hgl…*m…@_‹]…Cչiµ†˜™HU™3gGe[TS‘’%‰tJ–$&w&X„d:Tg—F®\~*Y’P'}61\Kť!VjM.tcXK^[g—FzuviQµ«X«ܺ‰”®>v‘—|tDCVq•¶•«{n|µ?]6*t±ڨ42wK†+®·¶Z+µFm–g U[QWµ–kP«rh‹fNF‘.X•CY®«Co"‘{{ٱhG#/R6Ui!¬¶o®j,H}¶ay^jrˆDzbͤ®‘w€s{,d‰\;^›Tx%›xHflVշ®nS]UT}K`j H™f~‹3·9TYD׮=j N–9—E,2SK;+;\‘•PUoR n"lU;v^u\_M4r‰„LZwxz›E®,-/"t•\b‘KHwPG‰5ggM€SOgNe’R»*:
ls±h‹9EbTCw'aGmR%b‹1Cw'aGmR%bKCw'aGmR%b Bw'aGmR%b›ڰ6)m±ER;tj+aGmR%bKBw'aGmR%b ^Bw'aGmR%b:Bw'aGmR%Z4C1˜€: lXQ›‚</—˜Zˆ•h»r_ `’‘ ˆ•“DG/x˜,'˜$r$18}|
5$‘#™A >«… &J
_p2_b Gr€C
W€L9’€f‘`’


jako by si to PDFko do sebe nathne celou generovanou strnku namsto toho, aby na to neahalo a zobrazilo se to v prohlei. jakto?
Taps
Profil
maniakum:
na zkouku zkus odstranit toto
$mpdf->allow_charset_conversion=true;  // Set by default to TRUE
$mpdf->charset_in='windows-1250'; 
Kajman
Profil
Ve file_exists a readfile mte jin soubory. Tak bych zkusil vypnout debug (teba pe nco na vstup).

Vae odpov

Mohlo by se hodit


Prosm pouvejte diakritiku a interpunkci.

Ochrana proti spamu. Napite prosm slo dv-sta tyicet-sedm: