aur1mas / wkhtmltopdf Goto Github PK
View Code? Open in Web Editor NEWWkhtmltopdf integration with PHP
Wkhtmltopdf integration with PHP
For long content; exec function hangs :-(. with a simple function call "system" works.
Code fix:
protected function _exec($cmd, $input = "")
{
$result = array('stdout' => '', 'stderr' => '', 'return' => '');
system( $cmd, &$result['stdout'] );
return $result;
}
Hi,
I have an issue with the class, and the MODE_DOWNLOAD. On Android browser, the PDF starts downloading but the browser then reports the download as failed.
The specific call of the Wkhtmltopdf object is here:
https://github.com/francoisjacquet/rosariosis/blob/mobile/functions/PDF.fnc.php#L63
François
I am trying the header with this code.
$wkhtmltopdf->setHeaderHtml('<div>This is header</div>');
but it generates error like below
WKHTMLTOPDF didn't return any data
can you help me?
The pdf download code has
header("Pragme: public");
This appears to be a mis-spelling of Pragma
i have feel this issue every time
Hi,
I am converting HTML to pdf through wkhtmltopdf library, here session is behaving very differently that if we set the session when our link is called then it works fine but our previously set session is not getting?
exec('C://"Program Files"//wkhtmltopdf.exe ' . 'http://localhost/test.php?a=351' . ' ' . $file_name . '');
Problem:
Session set in test.php is available in this page when printing the page.
But if we set the session in some previous page e.g test2.php then that value is null here in test.php
Is any idea?
Suppose i create a session -> session_1 in browser_1 window(on my pc) and
second session -> session_2 in ,other, browser_2 window(on my pc) .
so when i try to execute
exec(" Path_to_wkhtmltoimage --cookie PHPSESSID session_1 My_url Save_to_path ");
in my file.php file, present on my server, on browser_1 . It doesn't execute (instead goes into an infinte loop, i guess, returning to some error 503 after some time around 5-10 mins) .
However it works fine if i run the same command in cmd on server.
And also it works fine if i run file.php, with same command as above, on browser_2 window ,that saves the screenshot image .
similarly, if i run
exec(" Path_to_wkhtmltoimage --cookie PHPSESSID session_2 My_url Save_to_path ");
in my file.php file on my server on browser_2 . it doesn't execute. But executes correctly in browser_1.
"file.php" is attached .
file.txt
please tell me , where am i doing wrong !!
sorry for confusion , if any.
Thanks in advance.
On Line 618 instead of:
file_put_contents( $filename, $this->_render());
it should be:
file_put_contents($this->getPath() . $filename, $this->_render());
i used wkhtmltopdf in codeigniter framework. but it raises Message: Path to directory where to store files is not set
error
Hi there,
i'm trying to use your classe, but when o use it i do have this error, it create me a html file with my content but say that it do not receive any data :/
here's my code:
try {
$wkhtmltopdf = new Wkhtmltopdf(array('path' => './public/uploads/'));
$wkhtmltopdf->setTitle("Title");
$wkhtmltopdf->setHtml("
i also try with get_page_content, an url always same issue.
Thanks.
Today I had an issue where my application hung trying to create a PDF on Linux. Using strace
and /proc/*/fd
, I could see that the PHP application was blocked reading from wkhtmltopdf's stdout, and wkhtmltopdf was blocked writing to its stderr. Looking at the PHP code shows that nothing will be read from wkhtmltopdf's stderr until stdout has been read completely. I suspect the pipe buffer filled up, so that write(stderr, ...)
would not return until the buffer was consumed, but since the PHP is blocked reading stdout, the buffer will never be emptied. This wouldn't happen with every PDF since there is a buffer, but presumably longer PDFs generate more output on stderr and hit the buffer limit.
I think one solution would be to use stream_select()
to effectively read from both stdout and stderr at the same time. The input should probably be written the same way, as I'd imagine the output buffers could also fill up before the input is completely written. In my case my input is a file, so I don't know.
This may be the issue in #18, but there's not enough information to know.
line 251 is incorrect, it should be:
$command .= ($this->getTOC()) ? " toc" : "";
and put in after the "title" parameter
Hi,
I was looking for a nice way to convert some HTML pages to pdf, and your class looks like a great way to work with wkhtmltopdf. After trying a few things i got it to output a pdf file, although those were corrupt.
When generating the same pdf through the command line it would output a correct pdf file, and while comparing the two it became clear the one generated by your class had been cut off.
I then found out if i would use strlen instead of mb_strlen for the content-length headers it would output correct pdf files.
Does anyone else have the same issue?
should be chmod($this->_filename, 0777);
see http://php.net/manual/en/function.chmod.php
Hi. So far I like your revision as it is much cleaner. But I keep getting the following exception thrown:
WKHTMLTOPDF didn't return any data
I am running WAMP and have installed the Windows installer of WKHTMLTOPDF but am unsure if your script will automatically see it. Could this be the problem?
I'm using this class and the images doen't appear. The css support works very well.
I tried use absolute path and relative path but doen't work
Hi there,
I'm using this wrapper (aur1mas / Wkhtmltopdf) and works fine with pages such as google, bbc, hotmail. But when I use it with pages with graphics/charts (such as https://developers.google.com/chart/) with javascript, it doesn't show up.
If I use wkhtmltopdf from terminal it works perfect.
I'm using wkhtmltopdf-0.11.0.
Any help will be highly appreciated.
Diego
When I try to generate the PDF using Wkhtmltopdf class. It ignores CSS. And if i try to generate the PDF via terminal then only it generates PDF properly. So, what could be the problem?
Hi, i was using this php implementation, which worked almost right out of the box for me. But then i passed to the static 64bits version of wkhtmltopdf, and it juste keep on giving me supposedly server internal error. Checked lots of things, and im starting to think the headers, in download mode, are responsible.
Does anyone know if headers can crash on some servers? cause the command works really fine and get me back pdf datas.
thx
I'd like to research possibility to use wkhtmltopdf as pdf engine for SimpleInvoices which now uses html2pdf.
Now I wonder what's the relation of this project with the https://github.com/mreiferson/php-wkhtmltox ?
Sincerely,
Gour
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.