Jump to content

PHP PDF Question


CanMan2004

Recommended Posts

Hi all

I 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?

Thanks

Ed
Link to comment
Share on other sites

sorry jesirose, im confused, at the moment, when I use

pdf_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
Link to comment
Share on other sites

[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#59630

Copy 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
Link to comment
Share on other sites

Hi magic2goodil & jesirose

Okay, 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?
Link to comment
Share on other sites

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 two

Does that make sense?
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.