CanMan2004 Posted January 9, 2007 Share Posted January 9, 2007 Hi allI have a PDF creater, using the standard PHP functions.Part of my code that im trying to work with looks like[code]$color = "#57575A";$string = str_replace("#","",$color);$red = hexdec(substr($string,0,2)) / 255;$green = hexdec(substr($string,2,2)) / 255;$blue = hexdec(substr($string,4,2)) / 255; pdf_setrgbcolor_fill($pdf, $red, $green, $blue); pdf_setfont($pdf, $fontone, 27);pdf_show_xy($pdf, $details, 150, 50);[/code]Does anyone know how I can get that text to allign to the right of the page and not the left side of the page.Does that make sense?ThanksEd Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 9, 2007 Share Posted January 9, 2007 It's the first function on the documentation's comments.http://us2.php.net/manual/en/function.pdf-show-xy.php Quote Link to comment Share on other sites More sharing options...
magic2goodil Posted January 9, 2007 Share Posted January 9, 2007 i was going to say maybe something like:[code]$textflow = PDF_create_textflow($pdf, $thetext, "fontname=Tahoma fontsize=9 align=right");[/code]$pdf being your pdf instance, $thetext being some text :) Quote Link to comment Share on other sites More sharing options...
CanMan2004 Posted January 9, 2007 Author Share Posted January 9, 2007 magic2goodilwhen I try your suggestion, I getCall to undefined function: pdf_create_textflow()Any ideas? Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 9, 2007 Share Posted January 9, 2007 Yeah, you could try the one I suggested. :) Quote Link to comment Share on other sites More sharing options...
CanMan2004 Posted January 9, 2007 Author Share Posted January 9, 2007 Hi jesiroseI tried that, but isnt that just for positioning, so 30px from the left and 40px from the bottom? I want to make the text go to right align, the reason is, because im pulling in content and need it to sit on the right and be able to expand Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 9, 2007 Share Posted January 9, 2007 you're positioning it right here:pdf_show_xy($pdf, $details, 150, 50);The function is exactly the same, but it starts on the right. Quote Link to comment Share on other sites More sharing options...
magic2goodil Posted January 9, 2007 Share Posted January 9, 2007 HEre maybe this link will help..Perhaps you can write your code to html first and then use this script utility to make it to pdf..PErhaps it will keep your right alignment..http://sourceforge.net/projects/html2fpdf Quote Link to comment Share on other sites More sharing options...
CanMan2004 Posted January 9, 2007 Author Share Posted January 9, 2007 sorry jesirose, im confused, at the moment, when I usepdf_show_xy($pdf, $details, 150, 50);it runs any text from the left to the right, I cant see how im supposed to alter this so text runs from right to left of the page.Or am I being thick!thanks magic2goo, I used to use that, but there is so many pages needed to run it, my pdf files are quite simple Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 9, 2007 Share Posted January 9, 2007 On the page I linked to is a function!http://us2.php.net/manual/en/function.pdf-show-xy.php#59630Copy and paste that function into your code, then call it like you would the regular one. Quote Link to comment Share on other sites More sharing options...
magic2goodil Posted January 9, 2007 Share Posted January 9, 2007 [quote author=jesirose link=topic=121596.msg500389#msg500389 date=1168316679]On the page I linked to is a function!http://us2.php.net/manual/en/function.pdf-show-xy.php#59630Copy and paste that function into your code, then call it like you would the regular one.[/quote]*hides cuz jesirose is getting angrrrry* You wont like her when she's angry! *sees her turn green**runs*:P Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 9, 2007 Share Posted January 9, 2007 I prefer to turn blue, it's prettier Quote Link to comment Share on other sites More sharing options...
CanMan2004 Posted January 9, 2007 Author Share Posted January 9, 2007 Hi magic2goodil & jesiroseOkay, I managed to get it to print a word onto a PDF, but the text still runs from left to right and not right to left, I used the following[CODE]function pdf_show_xy_right(&$pdf, $text, $right, $bottom) { $fontname = pdf_get_parameter($pdf, "fontname", 0); $font = pdf_findfont($pdf, "Helvetica-Bold", "host", 0); $size = pdf_get_value($pdf, "fontsize", 0); $width = pdf_stringwidth($pdf, $text, $font, $size); pdf_show_xy($pdf, $text, $right-$width, $bottom);}pdf_show_xy_right($pdf, "Hello World", 100, 100);[/CODE]Do you know how to switch it to run from right to left? Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 9, 2007 Share Posted January 9, 2007 Wait, right align, or right to left like arabic? Quote Link to comment Share on other sites More sharing options...
CanMan2004 Posted January 9, 2007 Author Share Posted January 9, 2007 right align, so the text is the right way around but the text is aligned to the right of the page and the text runs from the right hand side to the left hand side, like Hello world test one Another hello world test twoDoes that make sense? Quote Link to comment Share on other sites More sharing options...
magic2goodil Posted January 9, 2007 Share Posted January 9, 2007 Sorry, but I don't know enough about php pdf output to help you man.. Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 9, 2007 Share Posted January 9, 2007 Okay I don't know that much about pdf, but before you had x 150, y 50. Why did you use 100, 100 for the right align one. Shouldn't the $right be > 150? Like, 400 maybe? Sorry, that function looks okay to me. Good luck. 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.