honkmaster Posted May 28, 2014 Share Posted May 28, 2014 Hi I'm stuck with an issue i can't work out. I'm using php and TCPDF to create a pdf label. The user uses a simple form and selects the colour the label needs to be. Problem I have got is no matter what I post TCPDF does not pick up the colour variable. In the below code the SetFillColour works if i put RGB or CMYK info in direct but not if I post it so $pdf->SetFillColor(219, 200, 19); works but if i post from a form $pdf->SetFillColor($getcolour); it does not??? Any ideas or help would be grateful, Cheers $getcolour = $_POST['colour'];// Format Store ID Block $pdf->StartTransform(); $pdf->SetFont('Helvetica', 'B', 40); $pdf->setCellPaddings(0, 0, 0, 0); $txt = $storeid; $pdf->SetXY(1,49); $pdf->Rotate(90); $pdf->SetFillColor($getcolour); $pdf->MultiCell(48, 0, $txt."n", 0, 'C', 1, 1, '' ,'', true); $pdf->StopTransform(); Link to comment Share on other sites More sharing options...
Ingolme Posted May 28, 2014 Share Posted May 28, 2014 Have you checked what parameters the SetFillColor() method accepts? Check what value $getcolour has and make sure it's what you expected it to be. Link to comment Share on other sites More sharing options...
honkmaster Posted May 28, 2014 Author Share Posted May 28, 2014 Set fill expect the following SetFillColor(219, 200, 19) for RGB or SetFillColor(0, 50, 50, 0) for CMYK I have posted both from form as $pdf->SetFillColor($getcolour); neither work? Cheers for reply Link to comment Share on other sites More sharing options...
justsomeguy Posted May 28, 2014 Share Posted May 28, 2014 Are you saying that you are submitting something like the string "219, 200, 19" and expecting that to work? In that case you are sending the function a single string parameter, when it expects 3 number parameters. That is not the same thing. Split up the string into individual values, figure out whether you have 3 or 4, validate them, and then call the appropriate function with the values. Link to comment Share on other sites More sharing options...
honkmaster Posted May 28, 2014 Author Share Posted May 28, 2014 Ok, if I'm posting 219, 200 19 how do I split that into 3 values from the one post? Cheers Link to comment Share on other sites More sharing options...
justsomeguy Posted May 28, 2014 Share Posted May 28, 2014 You can use explode to split it:http://www.php.net/manual/en/function.explode.phpThen you can use trim to remove any spaces, and intval to convert each value to an integer. Link to comment Share on other sites More sharing options...
honkmaster Posted May 29, 2014 Author Share Posted May 29, 2014 Worked a treat, thanks very much for help and pointing me in the right direction, Cheers Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now