suttercain Posted September 11, 2007 Share Posted September 11, 2007 If so can some please show me an example? I would like to use CSS but will use the <font> tag if mandatory. Thanks. Quote Link to comment Share on other sites More sharing options...
Barand Posted September 11, 2007 Share Posted September 11, 2007 $output = sprintf ('<span style="background-color:%s ; color:%s">%s</span>', '#000', '#FF0', 'sample text'); Quote Link to comment Share on other sites More sharing options...
suttercain Posted September 11, 2007 Author Share Posted September 11, 2007 Thanks Barrand, My idea fell flat. I am using the sprintf to output text to a PDF document. I was hoping the color would change the text in the document. It instead printed the entire as a string. I even tried changing the color via the font tag: $pdf = new PDF_Label('5160', 'in', 1, 2); $pdf->Open(); $pdf->AddPage(); $sql = mysql_query("SELECT firmTitle, attendee FROM attendees") or die(mysql_error()); while ($row = mysql_fetch_array($sql)) { // Print labels $trialNerror = "<font color='red'>".strtoupper($row['attendee'])."</font>"; $pdf->Add_PDF_Label(sprintf("%s\n%s\n", $trialNerror, $row['firmTitle'])); } $pdf->Output(); No luck. Anyone know if there is a PHP function to set the font size/text? I don't think there is, but it would be cool. SC Quote Link to comment Share on other sites More sharing options...
suttercain Posted September 11, 2007 Author Share Posted September 11, 2007 I take it this is impossible? SC Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted September 11, 2007 Share Posted September 11, 2007 What are you using to write to PDF? I'm only familiar with FPDF (www.fpdf.org), which allows you to do practically anything with PDFs, fonts, colors, etc. Quote Link to comment Share on other sites More sharing options...
suttercain Posted September 11, 2007 Author Share Posted September 11, 2007 Hi bluesky, yeah I got that working with the FPDF calss as well as the extender PDF_Label.php My problem is I am not able to output two different font sizes even when using the two different functions... <?php $pdf = new PDF_Label('5160', 'in', 1, 2); $pdf->Open(); $pdf->AddPage(); $pdf->SetFont('Arial','B',12); $pdfsm = new PDF_Label('5160', 'in', 1, 2); $pdfsm->Open(); $pdfsm->AddPage(); $pdfsm->SetFont('Arial','B',12); $sql = mysql_query("SELECT firmTitle, attendee FROM attendees") or die(mysql_error()); while ($row = mysql_fetch_array($sql)) { // Print labels $trialNerror = strtoupper($row['attendee']); $pdf->Add_PDF_Label(sprintf("%s\n", $trialNerror)); $pdfsm->Add_PDF_Label(sprintf("%s", $row['firmTitle'])); } $pdf->Output(); $pdfsm->Output(); ?> When I run the above code, only the $pdf->Output(); shows up. If I remove the $pdf->Output(); the $pdfsm->Output(); will show. Any suggestions? Thanks. Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted September 11, 2007 Share Posted September 11, 2007 well, you can't output() to the browser twice as each time output() sends headers and each file is unique. Why not combine both into one PDF? Quote Link to comment Share on other sites More sharing options...
suttercain Posted September 11, 2007 Author Share Posted September 11, 2007 I am not too familer with classes and would not know how to do this. I do know that I need the $row['attendee'] result to be a bigger font than the $row['FirmTitle'] result. I just have no idea how to do this. If you know it would be greatly appreciated. Thanks. SC Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted September 11, 2007 Share Posted September 11, 2007 Are you trying to create labels with attendee in large letters over firm title under attendee in smaller letters? If so, I don't think you're going to get there with this class. The way you are heading, you will end up with a page of labels with attendee name and another page with firm title. This class isn't too flexible. Quote Link to comment Share on other sites More sharing options...
suttercain Posted September 11, 2007 Author Share Posted September 11, 2007 This is the current code I am using which outputs fine, but both lines of text are the same font size... $pdf = new PDF_Label('5160', 'in', 1, 2); $pdf->Open(); $pdf->AddPage(); $pdf->SetTextColor(0,0,0); $pdf->SetFont('Arial','B',12); $sql = mysql_query("SELECT firmTitle, attendee FROM attendees") or die(mysql_error()); while ($row = mysql_fetch_array($sql)) { // Print labels $pdf->Add_PDF_Label(sprintf("%s\n%s\n", $row['attendee'], $row['firmTitle'])); } $pdf->Output(); ?> Quote Link to comment Share on other sites More sharing options...
suttercain Posted September 11, 2007 Author Share Posted September 11, 2007 Darn... just got your message. Okay. Maybe I will just Uppercase the attendee and UCwords the Firm Title. Thanks for your help though. SC Quote Link to comment Share on other sites More sharing options...
Barand Posted September 11, 2007 Share Posted September 11, 2007 Change Add_PDF_Label method to accept 2 arguments, line1, line2. Output the first in whatever size you want for that and output 2nd in other size Quote Link to comment Share on other sites More sharing options...
suttercain Posted September 11, 2007 Author Share Posted September 11, 2007 Hi Barrand, Thanks for the advice. I have been playing with the function within the class and can't seem to grasp it. function Add_PDF_Label($texte) { // We are in a new page, then we must add a page if (($this->_COUNTX ==0) and ($this->_COUNTY==0)) { $this->AddPage(); } $_PosX = $this->_Margin_Left+($this->_COUNTX*($this->_Width+$this->_X_Space)); $_PosY = $this->_Margin_Top+($this->_COUNTY*($this->_Height+$this->_Y_Space)); $this->SetXY($_PosX+3, $_PosY+3); $this->MultiCell($this->_Width, $this->_Line_Height, $texte); $this->_COUNTY++; if ($this->_COUNTY == $this->_Y_Number) { // End of column reached, we start a new one $this->_COUNTX++; $this->_COUNTY=0; } if ($this->_COUNTX == $this->_X_Number) { // Page full, we start a new one $this->_COUNTX=0; $this->_COUNTY=0; } } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.