srujana Posted June 25, 2007 Share Posted June 25, 2007 Hello, I want to output some text to pdf file using FPDF. Outputting a text is good even with multi columns.But what I need is I need that text to be formatted. Like Some text to be bold and italic etc. I can either make a multi column pdf or a html formatted page to PDF, but I want both of them.I couldnt integrate both the functions and from the forums I found someone refering HTML2PDF, but I also need multi column with it.. Please suggest me with some example.I am in need of it badly Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/57050-converting-a-htm-code-to-pdf-in-multi-column-with-fpdf/ Share on other sites More sharing options...
redarrow Posted June 25, 2007 Share Posted June 25, 2007 <?php $p = PDF_new(); /* open new PDF file; insert a file name to create the PDF on disk */ if (PDF_begin_document($p, "", "") == 0) { die("Error: " . PDF_get_errmsg($p)); } PDF_set_info($p, "Creator", "hello.php"); PDF_set_info($p, "Author", "redarrow"); PDF_set_info($p, "Title", "Hell every one it redarrow doing (PHP)!"); PDF_begin_page_ext($p, 595, 842, ""); $font = PDF_load_font($p, "Helvetica-Bold", "winansi", ""); PDF_setfont($p, $font, 24.0); PDF_set_text_pos($p, 50, 700); PDF_show($p, "Hello world it redarrow !"); PDF_continue_text($p, "(i love PHP)"); PDF_end_page_ext($p, ""); PDF_end_document($p, ""); $buf = PDF_get_buffer($p); $len = strlen($buf); header("Content-type: application/pdf"); header("Content-Length: $len"); header("Content-Disposition: inline; filename=hello.pdf"); print $buf; PDF_delete($p); ?> Link to comment https://forums.phpfreaks.com/topic/57050-converting-a-htm-code-to-pdf-in-multi-column-with-fpdf/#findComment-281853 Share on other sites More sharing options...
srujana Posted June 25, 2007 Author Share Posted June 25, 2007 I need it with FPDF. My work is 80% done but only formatting is left. Please check this link http://www.sala.pingst.se/htm/multi.php Tags like <b><u> were also printing there instead of making bold and underlined. I need multi column and also the text in a formatted way. writeHTML() can do it but it wont make multi column. Please help me in this. Link to comment https://forums.phpfreaks.com/topic/57050-converting-a-htm-code-to-pdf-in-multi-column-with-fpdf/#findComment-281862 Share on other sites More sharing options...
redarrow Posted June 25, 2007 Share Posted June 25, 2007 $pdf=new FPDF(); $pdf->AddPage(); $pdf->SetFont('Arial','B',16); $pdf->Cell(40,10,'Hello World I Am Redarrow!'); $pdf->Output('myFile.pdf', 'F'); hope this helps. read this ok. Description Sets the font used to print character strings. It is mandatory to call this method at least once before printing text or the resulting document would not be valid. The font can be either a standard one or a font added via the AddFont() method. Standard fonts use Windows encoding cp1252 (Western Europe). The method can be called before the first page is created and the font is retained from page to page. If you just wish to change the current font size, it is simpler to call SetFontSize(). Note: the font metric files must be accessible. They are searched successively in: The directory defined by the FPDF_FONTPATH constant (if this constant is defined) The font directory located in the directory containing fpdf.php (if it exists) The directories accessible through include() Example defining FPDF_FONTPATH (note the mandatory trailing slash): define('FPDF_FONTPATH','/home/www/font/'); require('fpdf.php'); If the file corresponding to the requested font is not found, the error "Could not include font metric file" is issued. Parameters family Family font. It can be either a name defined by AddFont() or one of the standard families (case insensitive): Courier (fixed-width) Helvetica or Arial (synonymous; sans serif) Times (serif) Symbol (symbolic) ZapfDingbats (symbolic) It is also possible to pass an empty string. In that case, the current family is retained. style Font style. Possible values are (case insensitive): empty string: regular B: bold I: italic U: underline or any combination. The default value is regular. Bold and italic styles do not apply to Symbol and ZapfDingbats. size Font size in points. The default value is the current size. If no size has been specified since the beginning of the document, the value taken is 12. Example //Times regular 12 $pdf->SetFont('Times'); //Arial bold 14 $pdf->SetFont('Arial','B',14); //Removes bold $pdf->SetFont(''); //Times bold, italic and underlined 14 $pdf->SetFont('Times','BIU'); See also AddFont(), SetFontSize(), Cell(), MultiCell(), Write(). Link to comment https://forums.phpfreaks.com/topic/57050-converting-a-htm-code-to-pdf-in-multi-column-with-fpdf/#findComment-281863 Share on other sites More sharing options...
srujana Posted June 25, 2007 Author Share Posted June 25, 2007 For the example you said it is possible to change to bold, italic and underlined. I got it. But I am passing all of my output(mysql output) to a text file and then by using the multicell function I am getting multi-columns where the mysql output text file is give as an input file for this function. Since all the text is passed ONCE I can either change all of my output to bold or italic or underlined.But all at once.I dont need that.I only need some of the text from the whole text to be formatted. So, I also outputted <b><u> in the text file so that the FPDF will recognise and make appropriate changes in the pdf file. writeHTML function will do it what I said.. but not with multi columns.. I need multicolumns. Hope you got me clearly. Link to comment https://forums.phpfreaks.com/topic/57050-converting-a-htm-code-to-pdf-in-multi-column-with-fpdf/#findComment-281865 Share on other sites More sharing options...
redarrow Posted June 25, 2007 Share Posted June 25, 2007 http://www.benoist.ch/coursPHP/slides/divers/slidesMiscelaneous-beamer.pdf see if this helps then. Link to comment https://forums.phpfreaks.com/topic/57050-converting-a-htm-code-to-pdf-in-multi-column-with-fpdf/#findComment-281889 Share on other sites More sharing options...
srujana Posted June 25, 2007 Author Share Posted June 25, 2007 No, The same was given there but with some extra info php can do. I gave an example for multi columns which I did for my document. Link to comment https://forums.phpfreaks.com/topic/57050-converting-a-htm-code-to-pdf-in-multi-column-with-fpdf/#findComment-281922 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.