RE: [PHP] html or php to pdf whith pdflib?

From: Date: Sat, 20 Dec 2003 22:01:37 +0000
Subject: RE: [PHP] html or php to pdf whith pdflib?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-173071@lists.php.net to get a copy of this message
i use htmldoc, which converts html to pdf, saves trying to render lines and borders in a pdflib how painful. On Sat, 2003-12-20 at 10:20, Chris wrote: > Hi Reicardo, > This can't be done by using the pdf_* functions in php without reading the > whole source file, parsing the HTML and then working the $x and $y for each > line. > > There are some alternatives. If you don't really care to much about > formatting you could try this: > > $pdf = pdf_new(); > > pdf_open_file($pdf); > pdf_begin_page($pdf, 595, 842); > $font = pdf_findfont($pdf, "Times-Roman", "winansi", 0); > if ($font) { > pdf_setfont($pdf, $font, 10); > }else{ > die("Font Error"); > } > pdf_set_value($pdf, "textrendering", 1); > PDF_show_wraped($pdf,strip_tags(implode("",file($filename))), 50,750,500); > > pdf_end_page($pdf); > pdf_close($pdf); > > $data = pdf_get_buffer($pdf); > > header("Content-type: application/pdf"); > header("Content-disposition: inline; filename=test.pdf"); > header("Content-length: " . strlen($data)); > echo $data; > > > > function PDF_show_wraped(&$pdf, $text, $left, $top, $width){ > $fontsize = pdf_get_value($pdf,'leading'); > $length = pdf_stringwidth($pdf,$text); > $textHeight = ceil($length/$width)*$fontsize; > $h_align='left'; > while(pdf_show_boxed($pdf,$text, > $left,$top,$width,$textHeight,$h_align,'blind') > 1){ > $textHeight += $fontsize; > } > $top-=$textHeight; > pdf_show_boxed($pdf,$text,$left,$top,$width,$textHeight,$h_align); > return $top-$textHeight; > } > > Of course you would need to do something about page wrapping but that should > be quite easy. > > > Also you could exec() an external programme like txt2pdf > (<http://www.codecuts.com/mainpage.asp?WebPageID=156>). I > have seen a > html2pdf as well but can't remember where right now. > > > > Chris > > > -----Original Message----- > > From: E. Ricardo Santos [mailto:eddyrshot@hotmail.com] > > Sent: 20 December 2003 02:22 > > To: php-general@lists.php.net > > Subject: [PHP] html or php to pdf whith pdflib? > > > > Hello, somebody knows like turning a file HTML or php to pdf > > by means of pdflib but without having to write line to line? > > > > > > > > that is, a file already existing php or HTML, can be turned > > with pdflib? > > > > > > > > This I ask it because to where it studies pdflib, exit pdf > > is due to write line by line and coordinate by coordinate. > > A pdf already created can also be mattered and to combine > > it with the new exit. But what I did not find he is all > > this is the particularitity that I raise. > > > > > > > > I hope has explained to me correctly > > > > -- > > PHP General Mailing List (http://www.php.net/) To > > unsubscribe, visit: http://www.php.net/unsub.php > > > > > >

« previous php.general (#173071) next »