Write to PDF using PHP from android device
Posted
by
Brent Mitchell
on Stack Overflow
See other posts from Stack Overflow
or by Brent Mitchell
Published on 2012-06-13T04:37:02Z
Indexed on
2012/06/13
4:39 UTC
Read the original article
Hit count: 192
I am trying to write to a pdf file on php server. I have sent variables to the server, create the pdf document, then have my phone download the document to view on device. The variables seem not to write on the php file. I have my code below
public void postData() {
try {
Calculate calc = new Calculate();
HttpClient mClient = new DefaultHttpClient();
StringBuilder sb=new StringBuilder("myurl.com/pdf.php");
HttpPost mpost = new HttpPost(sb.toString());
String value = "1234";
List nameValuepairs = new ArrayList(1);
nameValuepairs.add(new BasicNameValuePair("id",value));
mpost.setEntity(new UrlEncodedFormEntity(nameValuepairs));
} catch (UnsupportedEncodingException e) {
Log.w(" error ", e.toString());
} catch (Exception e) {
Log.w(" error ", e.toString());
}
}
And my php code to write the variable "value" onto the pdf document:
//code to reverse the string
if($_POST[] != null) {
$reversed = strrev($_POST["value"]);
$this->SetFont('Arial','u',50);
$this->Text(52,68,$reversed);
}
I am just trying to write the variable in a random spot, but the variable the if statement is always null and I do not know why. Thanks. Sorry if it is a little sloppy.
© Stack Overflow or respective owner