self hosted, pdf in invoice email bad

I have a self hosted local system with ubuntu and following the forum, I have it working and sending the attachment but the attachment is bad (only 204 bytes), the link works fine and no logo.
can anyone help?
frank

Have you seen this info:

https://github.com/invoiceninja/invoiceninja/blob/master/docs/configure.rst#phantomjs

Note: we seem to be having trouble with our docs page so I’ve sent the docs on GitHub

Yes I have seen this, this ‘phantomjs test.pjs’ works with “page.open(http://192.168.1.174/view/0eq3df82ygfbwnncbt2ywpefncddvxd7?pahntomjs=true’, ‘GET’, ‘’, function (status) {” in the test.pjs file.

I tested with the $phantomjsLink = $link . “?phantomjs=true”; //&phantomjs_secret={$phantomjsSecret}"; line in the invoice.php. did not work

frank

I’m not sure, you may want to try debugging the code to see what’s being returned by PhantomJS.

laravel_error.log
[2018-07-19 14:09:25] production.ERROR: PhantomJS - Invalid response http://192.168.1.174/view/n0homgmdftxmsvwlje6cdoulddsyujl9?phantomjs=true: {“context”:“PHP”,“user_id”:1,“account_id”:1,“user_name”:“Frank Crowder”,“method”:“PUT”,“user_agent”:“Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0”,“locale”:“en”,“ip”:“192.168.1.172”,“count”:25,“is_console”:“no”,“is_api”:“no”,“db_server”:“mysql”,“url”:“invoices/8”} []

phantomjs test.pjs now returns this:
{
“body”: “”,
“bodySize”: 416,
“contentType”: “text/html; charset=UTF-8”,
“headers”: [
{
“name”: “Date”,
“value”: “Thu, 19 Jul 2018 15:12:52 GMT”
},
{
“name”: “Server”,
“value”: “Apache/2.4.18 (Ubuntu)”
},
{
“name”: “Cache-Control”,
“value”: “no-cache, private”
},
{
“name”: “Location”,
“value”: “http://192.168.1.174/client/session_expired
},
{
“name”: “Set-Cookie”,
“value”: “XSRF-TOKEN=eyJpdiI6Im9Rb2MwNHordVdsTWJ6WVVxM3I5cnc9PSIsInZhbHVlIjoid0dRU0NmYXFialI5MktwcWREOTNvU0E0QlFLTHoxZmc1bFJPMTU2UkVOT1oyUStVYlpJZTlTdjZRc1g3UThYNkRXRUxzc1k1UXpPZ0FWNkdrd3VZUXc9PSIsIm1hYyI6IjQ4Y2MyMGE4ZDRmYjI4OTAxMWM2Y2Q5NmVhNTcxZTkwYWNmYmIzYWQ1OGU0ZDY3ZTRiOTViYmUzZWNhZGU1YTEifQ%3D%3D; expires=Thu, 19-Jul-2018 23:12:53 GMT; Max-Age=28800; path=/\nninja_session=eyJpdiI6IlZwQmNscFlTNlpxbWdpRnpacnZScVE9PSIsInZhbHVlIjoic0RMQXNDenN0Q1J2OTBWdkNKcGYwejZGTzI5Q1ZxM3RcL2YxZ2hjYnFacEFrQzF2VXdzUXhJWEJLZklGYkdVQmtsQ2ZVaGZnQkVKbHlLbWJpWVBPUWtBPT0iLCJtYWMiOiIwZDYyOGVhMjM3MTNlZjY3NjZjNTY1OTlhNTFkZTUwNDU5ZDE3Y2ZlMGNjY2M0NDhjY2M4NWYyZGYyZDZjNjdlIn0%3D; path=/; HttpOnly”
},
{
“name”: “Content-Length”,
“value”: “416”
},
{
“name”: “Keep-Alive”,
“value”: “timeout=5, max=100”
},
{
“name”: “Connection”,
“value”: “Keep-Alive”
},
{
“name”: “Content-Type”,
“value”: “text/html; charset=UTF-8”
}
],
“id”: 1,
“redirectURL”: “http://192.168.1.174/client/session_expired”,
“stage”: “start”,
“status”: 302,
“statusText”: “Found”,
“time”: “2018-07-19T15:12:53.042Z”,
“url”: “http://192.168.1.174/view/nxvrfleq9dpjio3huqo6auiulmtyquxt?phantomjs=true”,
“console”: []

Not sure what to do now, I may try a clean install of ubuntu and then invoice ninja and see if that works.

frank

Thanks, that’s helpful!

Try setting PHANTOMJS_SECRET to a random value in the .env file

ok, got the phantomjs test.pjs to work again.
now back to the email not having the pdf

log:
[2018-07-19 15:55:33] production.ERROR: PhantomJS - Invalid response http://192.168.1.174/view/vg40xgv552ypdhzx92lcfbilfihx9wnn?phantomjs=true&phantomjs_secret=pkahijjmgifbj58fvjgeciylhwoyeenl: {“context”:“PHP”,“user_id”:1,“account_id”:1,“user_name”:“Frank Crowder”,“method”:“PUT”,“user_agent”:“Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0”,“locale”:“en”,“ip”:“192.168.1.172”,“count”:29,“is_console”:“no”,“is_api”:“no”,“db_server”:“mysql”,“url”:“invoices/9”} []

output from phantomjs test.pjs

{
“body”: “”,
“bodySize”: 158260,
“contentType”: “text/html; charset=UTF-8”,
“headers”: [
{
“name”: “Date”,
“value”: “Thu, 19 Jul 2018 15:59:04 GMT”
},
{
“name”: “Server”,
“value”: “Apache/2.4.18 (Ubuntu)”
},
{
“name”: “Cache-Control”,
“value”: “no-cache, private”
},
{
“name”: “Set-Cookie”,
“value”: “XSRF-TOKEN=eyJpdiI6IkxkMmNxcCtGRDJlV1J5c1BHMkVRcGc9PSIsInZhbHVlIjoiQ2tNbVRGXC82OUJrd0h1R2VwRnlXTTVINlNuREExcTZNQWJielI4eHNOZ0lxU0dnYmNVYk9xWTQ5a2RrRytvd1pRdGhVbmY2YnNoWnN2bHRoaFVadkVRPT0iLCJtYWMiOiJlYmUxYWVhNjcxN2U0NmQ5OTZiNTMwZWI4ZWZkZGM5Y2RlY2RlYWRkMjUzNWY3ZWYzOTY5MjQzYTI1ZWY4OWU0In0%3D; expires=Thu, 19-Jul-2018 23:59:04 GMT; Max-Age=28800; path=/\nninja_session=eyJpdiI6InRqOHBHd3E5Sm1GWWxWMm0wUG1OeFE9PSIsInZhbHVlIjoiMkY0REp4Vmkzd1ozOEJabjlXQVNrK1ZNR1B6TWh6S3VHXC9Ld3lqcHNGTFRudWl3WWM3dlJxZlBhUmNpWVdPckdseXVheWhha1FpRkgza2w5akxNZk5RPT0iLCJtYWMiOiIxNjM3NzQ3MmZhMzMwMDcyNzQ3YjQ2ZWQyMjU1NjQwZmU4MDY5NTdhODJlYjZhMGVjZjAwODBkMWRhYWQ1NzI4In0%3D; path=/; HttpOnly”
},
{
“name”: “Vary”,
“value”: “Accept-Encoding”
},
{
“name”: “Content-Encoding”,
“value”: “gzip”
},
{
“name”: “Keep-Alive”,
“value”: “timeout=5, max=100”
},
{
“name”: “Connection”,
“value”: “Keep-Alive”
},
{
“name”: “Transfer-Encoding”,
“value”: “chunked”
},
{
“name”: “Content-Type”,
“value”: “text/html; charset=UTF-8”
}
],
“id”: 1,
“redirectURL”: null,
“stage”: “start”,
“status”: 200,
“statusText”: “OK”,
“time”: “2018-07-19T15:59:04.670Z”,
“url”: “http://192.168.1.174/view/vg40xgv552ypdhzx92lcfbilfihx9wnn?phantomjs=true&phantomjs_secret=pkahijjmgifbj58fvjgeciylhwoyeenl”,
“content”: “<head></head><body>data:application/pdf;base64,JVBERi0xLjMKJf////…cut to save space…////lRU9GCg==</body>”,
“console”: []
}

I’m not sure, the response from the script looks correct.

It’s possible it’s related to using an IP rather than a hostname?

what I did was installed on windows and it works, do not know what was wrong with the ubuntu system but that is ok.
I now have another ? about custom fields. I added a custom field to invoices and it shows on the invoice form but does not show on the invoice pdf. any ideas?

I am trying to add a Ship To: field on the printed or pdf invoice.

Thank You
frank

Just a random thought, but were you by any chance using the phantomjs installed through apt?

I think I was. and got the Ship To: to work, not clean but will do the job.

Thank You for your help

I think that might have been part of the problem. The build that’s in the apt repositories is pretty much trash. I had a similar issues with emails not sending, and it turns out even just phantomjs --version would cause an error.

Something to try: Run apt purge phantomjs to get rid of the bad version. Then you can try grabbing the precompiled binary of 2.1.1 from http://phantomjs.org/download.html. Extract the tarball, then move the binary in /phantomjs2.1.1-linux-x86_64/bin/ to /usr/bin, set the permissions to 775 (555 would probably work as well, since you really only need read/execute), and point to that in your .env.

If for some reason that doesn’t work, I have the dev build of 2.1.3 that they had up before Ariya suspended development. I’ve been using it without any apparent issues, so I could get that to you if you wanted to try it.