Installing phpwkhtmltopdf by mikehaertl - php

I've spent hours on this problem and still got nothing. I'm quite a noob when it comes to installing something rather than double clicking may that's why i'm stuck.
What i want to do is to develop a web service which takes a url and returns an image file of the screen shot of that url.
I found out that i can do this doing the following steps:
Using wkhtmltopdf to convert my html files to pdf
And then converting this pdf to image using php imagic library.
I'm still on the first step. I downloaded an executable for wkhtmltopdf from some website and by using the following lines in command line, i successfully created a pdf:
\"C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltopdf\" --page-width 300 --page-height 225 \"$url\" $dir\\$tempName.pdf &
But now i wanted to make this as a web service online but this lines just run on cmd, not on a shared hosting server. What to do know? I've also seen phpwkhtmltopdf but i don't understand the installation phase as disscused Here.

Related

Browsershot won't save or write my pdf -> For some reason Chrome did not write

Looking for brilliant mind to help me fix my problem. I have inherited a Laravel v5.3 project, and the project should be able to pass CV's from html to .pdf. They have been using spatie/browsershot for that task. But for some reason the package won't write the damn file.
I have been looking at the html passed to the function, and it all checks out. So I went to the guide on Github and put this line of code into the codefile as the only one left in the function.
Browsershot::html('<h1>Hello world!!</h1>')->save('example.pdf');
No matter what I do, I get this error message:
Spatie \ Browsershot \ Exceptions \ CouldNotTakeBrowsershot
For some reason Chrome did not write a file at `example.pdf`.
I have also tried giving an absolute path for Browsershot to save the file at. But no matter. I have looked up many different guides the past two weeks, but nothing seems to work atm. Puppeteer is also installed locally.
I'm running a Windows 10 machine btw, with latest updates, if that matters.
I had the same issue in a PHP project. Installing the puppeteer package worked for me.
npm install puppeteer

How to use PHPMailer via Composer on FTP

i have started making my own site where i want to use PHPMailer!.First of all i installed PHPMailer via Composer(cmd) on my desktop then used localhost to run my page where the PHPMailer was running just fine.I then tried to just transfer my page files and files that were generated in there from PHPMailer (those are:vendor directory ,composer.json,composer.lock) to FTP.When i tried running it on live page it didn't work and threw Error:
Fatal error: require(): Failed opening required '/www/sites/0/site25740/public_html/vendor/composer/ClassLoader.php'
(include_path='.:/usr/share/php:/usr/local/zend/share/ZendFramework/library') in
/www/sites/0/site25740/public_html/vendor/composer/autoload_real.php on line 12
I think that my problem is that i generated those files into my desktop directory and therefore they are not working on live page.
Is there any way to maybe generate those files on my FTP server or maybe changing the structure of those files to work on live page?
You need to use SSH not FTP.
Once you SSH into your server, you can run the composer install command to install dependencies the same as you have on your desktop.
[Edit] An FYI - Yes, we can upload the vendor folder. Composer is a deployment tool. Uploading a vendor folder is NOT using a deployment tool.
If I am deploying 100 applications - and uploading 50mb of dependencies 100 times from a branch office on a cable/dsl ... how fast & efficient is that? If we offload that 50mb download to the server, how fast is that?
We have an option to do deployments wrong, or to do deployments properly.
I do not condone doing it wrong. It's clearly an option, however it is wrong.

Can you run PHPUnit if you just download it from Github and link to it in your script

Ive got some custom Selenium scripts working in a similar way that you might use cURL (theirs a ton of js encryption being done on the POST data on the 3rd party site so it actually more complex to reverse engineer them and use cURL), for these Selenium scripts to work they require PHPUnit, ive gone around trying to install it via the Command line / Pear, but for the life of me cant get it to work.
I noticed you can download all the files as a .zip from the Github page would i run into trouble if i just downloaded them placed them in the same folder as my selenium scripts and linked them up correctly via require() ?

Installing an open inviter

i am moving in to the world of PHP for my company and i am having some issues. Now i have very little experience and i would love some help to get me to understand how it works.
My first problem is that i am trying to setup a sales page for my product, and i want a the open inviter script to pop up to "invite your friends to see this page for an extra free bonus" (only when the customer wants to buy my product, so there is no spamming going on here)
But for the last 5 days i have been trying and trying and i simply cant get it to work, the inviter just appears blank whatever i do.
Now i might know where the problem might be because i located it tooday, the open inviter i had was modified but i found the original and it had the requirements:
"Your server will need to have PHP5 installed with DOMDocument support and either cURL or WGET."
I found out that my hosting company supports php5 if i place a line through a .htpaccess file. but the rest like domdocuments or cURL is something i just seem to understand how it works, i have looked through hundreds of websites trying to figure this out but i cant get a simple enough explenation on what it really is and how i get it to work with my hosting.
Do anyone have an idea on how i can get my open inviter installed on my website?
Here is the installation details:
"Thank you for downloading The OpenInviter General Package. This document will guide you through the installation process.
A: Requirements:
Your server will need to have PHP5 installed with DOMDocument support and either cURL or WGET.
B: Install:
1. Extract the contents of the openinviter.tar.gz file you have just downloaded.
Note: tar -xzvf openinviter.tar.gz
2. Upload the extracted files to your webserver (subfolder is highly advised).
3. Run postinstall.php (http://yourdomain/openinviter_dir/postinstall.php)
You may encounter the following errors:
i) The cookie storing folder if not writable. (Change the cookie folder or modify it's permisions.)
ii) Php DOM extension is not installed. (Install dom extension for php)
iii) You don't have curl or wget installed. (Install curl or wget)
You may encounter the following warnings:
i) A plugin does not work properly. (Your server has either a firewall or there is a connectivity error)
Note: You have to fix all the errors or openinviter will probably not work.
Note*: You can't run postinstall.php again for 2 minutes.
Edit config.php to suit your needs.
Delete postinstall.php
Run example.php (http://yourdomain/openinviter_dir/example.php) and try to fetch your contacts.
Note: example.php is modifiable but keep in mind the structure of the file."

Why are my 3rd-party HTML to PDF tools not recognized in Drupal 6 using Print module?

I have installed Drupal 6 and have the "Printer, e-mail and PDF versions" aka "Print" module installed.
I then realized in order to generate PDF's from my html nodes that I need a third-party tool, which is fine but the Print module is not recognizing the third-party tools I have installed in the /modules/print/lib/ directory. I get the following error in the "Home › Administer › Site configuration › Printer, e-mail and PDF versions" page:
"No PDF generation tool found! Please dowload a supported PHP PDF generation tool. Check this module's INSTALL.txt for more details."
I have set 755 permissions on the folders and files for the third-party tools, as most of my other settings are set to that as well.
I have installed two of the three recommended third-party PHP PDF generating tools:
1) http://dompdf.googlecode.com/files/dompdf-0.5.1.zip
2) http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.8.3.tar.bz2
Why am I seeing the "No PDF generation tool found! Please dowload a supported PHP PDF generation tool. Check this module's INSTALL.txt for more details." error message? And why is the Print module not recognizing my third-party tools?
Hm, just tried locally and it works for me, so you should double check your setup:
The module tries to find the installed libraries via the _print_pdf_tools() function in print_pdf.admin.inc. The function searches for a specific 'key' file per possible library in two places (assuming that if that file is ther, the whole library will be there as well):
in 'sites/all/libraries'
in the directory of the print module (should be 'modules/print' in your case)
It searches those directories recursively, so it should find them in arbitrary subdirectories as well, and the actual naming of the library directories should not matter.
Taking dompdf as an example here - it will be identified by its dompdf_config.inc.php file.
So you should check:
that this file is really present in the directory where you extracted dompdf to (from your comments, this should be modules/print/lib/dompdf-0.5.1)
that it is readable for your webserver process (you said you changed the permissions - did you do this recursively, and did you adjust the owner and/or group as well?)
The 'key' files used for identifying the other two libraries would be:
tcpdf.php for TCPDF
wkhtmltopdf or wkhtmltopdf.exe for wkhtmltopdf
Just checking - did you extract the libraries from the archives?
The folder would look like /sites/all/modules/print/lib/dompdf for example
wkhtmltopdf:
(Linux) No longer requires an XServer to be running (however the X11 client libs must be installed)
I am 85% sure that Dreamhost doesn't have X11 client libs on their shared hosting; you should have got errors while trying to compile wkhtmltopdf on dreamhost. By the way, try running uname -a in SSH session to dreamhost to find out their OS.
If you did manage to make wkhtmltopdf work on your local test server (which involves compiling the source tarball you linked to), you may have some luck using a pre-compiled static binary version from http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.8.3-static.tar.bz2
dompdf
The only thing dompdf requires is fonts. Have you followed the INSTALL instructions? If yes - try running some conversion with command-line, to see which errors prevent it from functioning. You haven't provided enough information to diagnose this one.

Categories