0

I have a jar file to convert Crystal Report into PDF, i was already run it on console and its succeed.

When i run it on console.

D:\report>java -jar PrintResumePDF.jar
The PDF is created!!.

But when i try to run in with exec in PHP, its not giving any result in the output. Even though the PDF file is created or converting process is success.

Here my PHP code:

<?php 
   exec("java -jar PrintResumePDF.jar 2>&1", $return);
   print_r($return);
?>

The Output of java/jar : The PDF is created!! not printed on PHP, its just blank page. Sorry for my broken english, please help me.

0

1 Answer 1

2

Hopefully this is a useful answer to you, but I can't replicate this on PHP7.2 with any arbitrary commands which produce output, so your PHP code at least is likely to be correct.

Eg this code:

<?php
// Stderr
exec("curl --aaa 2>&1", $return1);
print_r($return1);
// Stdout
exec("echo hello", $return2);
print_r($return2);

Outputs this:

$ php foo.php 

Array
(
    [0] => curl: option --aaa: is unknown
    [1] => curl: try 'curl --help' or 'curl --manual' for more information
)
Array
(
    [0] => hello
)

I can only suggest checking any relevant logs and/or redirecting the output to a temp file, because if the command executes correctly, then it is plainly either not printing anything from this execution environment, or you're dropping the output elsewhere.

Sign up to request clarification or add additional context in comments.

1 Comment

thx i understand right now with your explanation, the problem is i must echo the exec, thx for your helping man

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.