Trying to run wkhtmltopdf from within PHP, on Windows.
While on Linux, the same command used to run perfectly, on Windows I've been getting:
The input line is too long
I've found some answers and this workaround worked for me too:
Placing my command within a temporary .bat file, executing it and removing it afterwards.
For example:
$myLongCMD = '"C:\program files (x86)\wkhtmltopdf\wkhtmltopdf.exe" -d 600 --margin-bottom 24 --margin-left 0 --margin-right 0 --margin-top 13 --orientation Landscape --page-size A4 "E:\www\tmp\1003832673.html" --footer-html "E:\www\tmp\1957525255.html" --footer-html "E:\www\tmp\2038722390.html" "E:\www\tmp\2082679417.html" --footer-html "E:\www\tmp\2038722390.html" "E:\www\tmp\output.pdf"';
$tmpf = 'D:\\www\\myfile.bat';
$tmpp = fopen($tmpf,'w');
fwrite($tmpp, $myLongCMD);
fclose($tmpp);
$descriptors = array(
0 => array("pipe", "r"), // stdin
1 => array("pipe", "w"), // stdout
2 => array('pipe', 'a') // stderr - Open this as 'Append' as stream_get_contents gets blocked infinitely and the process never ends just as Luceo (many thanks to him) mentions here: http://www.php.net/manual/en/function.proc-open.php
);
$proc=proc_open('"'.$tmpf.'"', $descriptors, $pipes);
fwrite($pipes[0],$input);
fclose($pipes[0]);
$stdout=stream_get_contents($pipes[1]);
fclose($pipes[1]);
$stderr=stream_get_contents($pipes[2]);
fclose($pipes[2]);
$rtn=proc_close($proc);
@unlink($tmpf);
System config:
PHP ver 5.3.9 , Apache 2.4.9, Windows 2008 x64
miercuri, 28 mai 2014
vineri, 18 octombrie 2013
The FREE 2013 Bench Games!
7 days remaining of the FREE 2013 Bench Games . FREE access to 600+ tests on Brainbench.com
http://www.brainbench.com/xml/bb/landing/offer/home/promotion.xml?contentId=3049#.UmEGXFPwzF1
http://www.brainbench.com/xml/bb/landing/offer/home/promotion.xml?contentId=3049#.UmEGXFPwzF1
joi, 18 iulie 2013
Installing typo3 on windows. try 281039
Reasons for which i hate typo3:
It's the millionth try for me to install typo3 on windows. I think i've managed a couple of times, but then i backed up because of the difficulty in using it.
This time i think i have a new version (dated 2013), so there are NEW installation problems.
Here is a sample: excerpt from the installation instructions that came with it:
On Windows Vista or Windows 7 create a symbolic link named typo3_src
pointing to the source package:
mklink /D C:\<dir>\typo3_src-4.6.0 C:\<dir>\example.com\typo3_src
Well, how can i put this..? NO!
It just doesn't work like that because the syntax is vice-versa:
MKLINK /D Link Target
/D Creates a directory symbolic link. Default is a file
symbolic link.
Link specifies the new symbolic link name.
Target specifies the path (relative or absolute) that the new link
refers to.
How can one release such a package when this kind of basic information is wrong? I can't even get past the installation point, having this in mind, what kind of problems can one expect when inside?
Just a side-note, it's the third try only today. Cause i've tried different packages and i just couldn't get it to work.
It's the millionth try for me to install typo3 on windows. I think i've managed a couple of times, but then i backed up because of the difficulty in using it.
This time i think i have a new version (dated 2013), so there are NEW installation problems.
Here is a sample: excerpt from the installation instructions that came with it:
On Windows Vista or Windows 7 create a symbolic link named typo3_src
pointing to the source package:
mklink /D C:\<dir>\typo3_src-4.6.0 C:\<dir>\example.com\typo3_src
Well, how can i put this..? NO!
It just doesn't work like that because the syntax is vice-versa:
MKLINK /D Link Target
/D Creates a directory symbolic link. Default is a file
symbolic link.
Link specifies the new symbolic link name.
Target specifies the path (relative or absolute) that the new link
refers to.
How can one release such a package when this kind of basic information is wrong? I can't even get past the installation point, having this in mind, what kind of problems can one expect when inside?
Just a side-note, it's the third try only today. Cause i've tried different packages and i just couldn't get it to work.
luni, 1 iulie 2013
How to include a php file in typo3
From your typo3 backend, choose from the left menu: Web/Template/Setup section or Web /Template/ Your extension / Setup
And add the following line (change the path to your corresponding file) in the 'setup' section of your template record:
config.includeLibrary = fileadmin/lib/file.inc.php
You can read more here:
http://typo3.org/documentation/document-library/references/doc_core_tsref/current/
And add the following line (change the path to your corresponding file) in the 'setup' section of your template record:
config.includeLibrary = fileadmin/lib/file.inc.php
You can read more here:
http://typo3.org/documentation/document-library/references/doc_core_tsref/current/
vineri, 17 mai 2013
Cannot install windows chkdsk /f error ?
In short, the problem may be in BIOS:
Go into BIOS and change the AHCI mode of your HDD to Compatible or IDE.
I've just spent a couple of hours wiping my HD, formatting and reformatting in NTFS/whatever my hard disk with GParted, while all the time, the problem was in BIOS, the mode of the hard drive was set to AHCI , and changing it to 'Compatible' solved it. It seems that Windows (XP in my case) doesn't have/load drivers for this HDD mode.
Go into BIOS and change the AHCI mode of your HDD to Compatible or IDE.
I've just spent a couple of hours wiping my HD, formatting and reformatting in NTFS/whatever my hard disk with GParted, while all the time, the problem was in BIOS, the mode of the hard drive was set to AHCI , and changing it to 'Compatible' solved it. It seems that Windows (XP in my case) doesn't have/load drivers for this HDD mode.
vineri, 3 mai 2013
A boy and his Atom: this is a historical step + the end of Moore's Law
I urge anyone having anything to do with technology to watch the two movies:
http://www.research.ibm.com/articles/madewithatoms.shtml
This will be the millenium's breakthrough plus the end of Moore's Law.
http://www.research.ibm.com/articles/madewithatoms.shtml
This will be the millenium's breakthrough plus the end of Moore's Law.
vineri, 26 aprilie 2013
Find all points within radius from latitude and longitude given (from given point)
I had to use these formulas for a few times now, and the DB performance has to suffer when doing these kinds of searches.
However, i've just recently found a less accurate method, which has a great performance improvement on the database searches, the errors (unwanted results, or false positives) are neglectable in my case.
The SQL:
SELECT * FROM interest locations WHERE latitude BETWEEN @minLatitude AND @maxLatitude AND longitude BETWEEN @minLongitude AND @maxLongitude
The idea is to create a box, or, thinking planar - a square. Imagining the earth be plane (a plane map), the query above searches for all points (latitudes and longitudes) within the square the circumscribes our given radius cirlce.
The minimum and maximum latitudes, we calculate as starting (center) latitude plus/minus result of given radius divided by 111 (111 is the distance of one degree of latitude in Km):
@minLatitude = givenLatitude - givenRadius / 111
The minimum and maximum longitudes, we calculate as starting (center) longitude plus/minus result of given radius divided by 78, or if you want to be more exact, the corresponding DeltaLongitude depending on the given Latitude (0 => 111.320, 15 => 107.551, 30 => 96.486, 45 => 78.847, 60 => 55.800, 75 => 28.902, 90 => 0.0001)
@minLongitude = givenLongitude - givenRadius / longitudesArray[floor(abs(givenLatitude)/15)*15]
The funny name that somebody gave it was: 'thinking inside the box' (more info here: http://stackoverflow.com/questions/1006654/fastest-way-to-find-distance-between-two-lat-long-points , respect to Binary Worrier :).
Surface of circumscribed square / surface of circle = 1.27 (ca. 27% more surface returned [false positives])
Greatest distance error: for 50Km - 20Km, for 100Km - 40Km, for 200Km - 82Km.
The given SQL has great performance improvments, especially because it can use indexes on the latitude or longitude columns, unlike the cosines formula, which does not allow for the database engines to use indexes.
However, i've just recently found a less accurate method, which has a great performance improvement on the database searches, the errors (unwanted results, or false positives) are neglectable in my case.
The SQL:
SELECT * FROM interest locations WHERE latitude BETWEEN @minLatitude AND @maxLatitude AND longitude BETWEEN @minLongitude AND @maxLongitude
The idea is to create a box, or, thinking planar - a square. Imagining the earth be plane (a plane map), the query above searches for all points (latitudes and longitudes) within the square the circumscribes our given radius cirlce.
The minimum and maximum latitudes, we calculate as starting (center) latitude plus/minus result of given radius divided by 111 (111 is the distance of one degree of latitude in Km):
@minLatitude = givenLatitude - givenRadius / 111
The minimum and maximum longitudes, we calculate as starting (center) longitude plus/minus result of given radius divided by 78, or if you want to be more exact, the corresponding DeltaLongitude depending on the given Latitude (0 => 111.320, 15 => 107.551, 30 => 96.486, 45 => 78.847, 60 => 55.800, 75 => 28.902, 90 => 0.0001)
@minLongitude = givenLongitude - givenRadius / longitudesArray[floor(abs(givenLatitude)/15)*15]
The funny name that somebody gave it was: 'thinking inside the box' (more info here: http://stackoverflow.com/questions/1006654/fastest-way-to-find-distance-between-two-lat-long-points , respect to Binary Worrier :).
Surface of circumscribed square / surface of circle = 1.27 (ca. 27% more surface returned [false positives])
Greatest distance error: for 50Km - 20Km, for 100Km - 40Km, for 200Km - 82Km.
The given SQL has great performance improvments, especially because it can use indexes on the latitude or longitude columns, unlike the cosines formula, which does not allow for the database engines to use indexes.
Abonați-vă la:
Postări (Atom)