Regarding ...
brew install popper
If errors below, you should try command above, yourself, on command line ...
";
$x.=shell_exec('brew install poppler 2> huh.jnk');
if (file_exists('huhjunk.jnk')) {
$x.=file_get_contents('huhjnk.jnk');
unlink('huh.jnk');
}
echo "
" . $x . "
";
} else if (PHP_OS =='WINNT' || PHP_OS =='WIN32' || PHP_OS =='Windows') {
$x="Regarding ...
sudo apt-get update
sudo apt-get install poppler-utils
If errors below, you should try commands above, yourself, on command line ...
";
$x.=shell_exec('sudo apt-get update');
$x.=shell_exec('sudo apt-get install poppler-utils');
echo "
" . $x . "
";
}
}
exit;
}
$filepath='';
$rest="";
$restfrom="";
$restto="
... or ...
";
function rsearch($folder, $pattern, $size) { // thanks, anyway, to https://stackoverflow.com/questions/17160696/php-glob-scan-in-subfolders-for-a-file
$didea='';
if (PHP_OS == "Darwin") {
//file_put_contents("x.ksh", "find " . $folder . " -type f -name \"" . $pattern . "\" 2> /dev/null -exec wc -c {} + | egrep '^ " . $size . " ' | sed '/ " . $size . " /s///g'");
if ($folder == DIRECTORY_SEPARATOR) {
$didea=shell_exec("find \$HOME/Downloads -type f -name \"" . $pattern . "\" 2> /dev/null -exec wc -c {} + | egrep '^ " . $size . " ' | sed '/ " . $size . " /s///g'");
//file_put_contents("xx.ksh", $didea);
if ($didea != '') { return $didea; }
$didea=shell_exec("find " . dirname(__FILE__) . DIRECTORY_SEPARATOR . " -type f -name \"" . $pattern . "\" 2> /dev/null -exec wc -c {} + | egrep '^ " . $size . " ' | sed '/ " . $size . " /s///g'");
//file_put_contents("xxx.ksh", $didea);
if ($didea != '') { return $didea; }
}
return shell_exec("find " . $folder . " -type f -name \"" . $pattern . "\" 2> /dev/null -exec wc -c {} + | egrep '^ " . $size . " ' | sed '/ " . $size . " /s///g'");
}
//$iti = new RecursiveDirectoryIterator($folder);
//foreach (new RecursiveIteratorIterator($iti) as $file) {
//foreach (glob($folder . $pattern) as $file) {
// if (strpos($file , $pattern) !== false && filesize($file) == $size) {
// return $file;
// }
//}
return '';
}
if (isset($_GET['filename']) && isset($_GET['filesize']) && !isset($_GET['filepath'])) {
if (file_exists(str_replace('+',' ',urldecode($_GET['filename'])))) {
if (filesize(str_replace('+',' ',urldecode($_GET['filename']))) == $_GET['filesize']) {
$filepath=dirname(__FILE__) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode($_GET['filename']));
}
}
if ($filepath == '') {
$filepath = rsearch(DIRECTORY_SEPARATOR, str_replace('+',' ',urldecode($_GET['filename'])), $_GET['filesize']);
}
echo "";
exit;
} else if (isset($_GET['filename']) && isset($_GET['filesize']) && $_GET['filepath'] == '') {
if (file_exists(str_replace('+',' ',urldecode($_GET['filename'])))) {
if (filesize(str_replace('+',' ',urldecode($_GET['filename']))) == $_GET['filesize']) {
$filepath=dirname(__FILE__) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode($_GET['filename']));
}
}
if ($filepath == '') {
$filepath = rsearch(DIRECTORY_SEPARATOR, str_replace('+',' ',urldecode($_GET['filename'])), $_GET['filesize']);
}
echo "";
exit;
} else if (isset($_GET['filename']) && isset($_GET['filesize']) && isset($_GET['filepath'])) {
$anyextrac='';
if (substr(str_replace('+',' ',urldecode($_GET['filepath'])), -1, 1) != DIRECTORY_SEPARATOR) {
$anyextrac=DIRECTORY_SEPARATOR;
}
echo "";
exit;
}
$proposedtable="
var dmode='ltor';
var lastpath='', lastfilename='';
function woit(ioo) {
var wo=null;
if (ioo.src.indexOf('data:') == 0) {
wo=window.open('', '_blank');
wo.document.write('');
wo.document.title=ioo.title;
} else {
window.open(ioo.src, '_blank');
}
}
function checkf() {
if (document.getElementById('justputpdffilename').innerHTML != '') {
document.getElementById('justputpdffilename').title=document.getElementById('justputpdffilename').innerHTML;
document.getElementById('justputpdffilename').innerHTML='';
if (document.getElementById('thewords').value.trim() == '' || document.getElementById('thewords').value == lastfilename) {
document.getElementById('thewords').value=document.getElementById('justputpdffilename').title;
lastfilename=document.getElementById('justputpdffilename').title;
}
if (document.getElementById('justputpdfpath').innerHTML == '' && document.getElementById('justputpdfpath').title == '') {
if (document.getElementById('justputpdffilesize').innerHTML != '') {
//alert('am going away to look for filename=' + lastfilename + ' of size ' + document.getElementById('justputpdffilesize').innerHTML);
document.getElementById('justputpdfpath').title=' ';
//var xx=prompt(document.URL.split('?')[0].split('#')[0] + '?filepath=&filesize=' + document.getElementById('justputpdffilesize').innerHTML + '&filename=' + encodeURIComponent(lastfilename), document.URL.split('?')[0].split('#')[0] + '?filepath=&filesize=' + document.getElementById('justputpdffilesize').innerHTML + '&filename=' + encodeURIComponent(lastfilename));
document.getElementById('path').style.cursor='progress';
document.getElementById('gifif').src='./php_calls_pdfimages.php?filepath=&filesize=' + document.getElementById('justputpdffilesize').innerHTML + '&filename=' + encodeURIComponent(lastfilename);
}
}
}
if (document.getElementById('justputpdfpath').innerHTML != '') {
document.getElementById('justputpdfpath').title=document.getElementById('justputpdfpath').innerHTML;
document.getElementById('justputpdfpath').innerHTML='';
if (document.getElementById('justputpdfpath').title.indexOf('/') != -1) {
if (document.getElementById('justputpdfpath').title.slice(-1) != '/') {
document.getElementById('justputpdfpath').title+='/';
}
} else {
if (document.getElementById('justputpdfpath').title.slice(-1) != String.fromCharCode(92)) {
document.getElementById('justputpdfpath').title+=String.fromCharCode(92);
}
}
if (document.getElementById('path').value.trim() == '' || document.getElementById('path').value == lastpath) {
document.getElementById('path').value=document.getElementById('justputpdfpath').title;
lastpath=document.getElementById('justputpdfpath').title;
}
}
if (document.getElementById('path').value != '') {
document.getElementById('path').style.cursor='pointer';
}
}
function iifopen(iois) {
if (iois != null) {
var aconto = (iois.contentWindow || iois.contentDocument);
if (aconto.document) { aconto = aconto.document; }
if (aconto != null) {
//alert(1);
if (aconto.getElementById('distyle')) {
aconto.getElementById('distyle').innerHTML+='';
aconto.getElementById('files').accept='.pdf';
aconto.getElementById('files').multiple=false;
aconto.getElementById('files').style.border='5px solid yellow';
arect=aconto.getElementById('files').getBoundingClientRect();
//alert(2);
//aconto.getElementById('files').click();
}
}
}
}
function toggle() {
if (dmode == 'ltor') {
dmode='ttob';
document.getElementById('smode').innerHTML='⬇';
document.getElementById('mydflex').style.display='none';
document.getElementById('mytable').style.display='none';
document.getElementById('mytabletwo').style.display='table';
} else if (dmode == 'ttob') {
dmode='fill';
document.getElementById('smode').innerHTML='➡';
document.getElementById('mydflex').style.display='none';
document.getElementById('mytabletwo').style.display='none';
document.getElementById('mytable').style.display='table';
} else {
dmode='ltor';
document.getElementById('smode').innerHTML='↘';
document.getElementById('mytable').style.display='none';
document.getElementById('mytabletwo').style.display='none';
document.getElementById('mydflex').style.display='block';
}
}
setInterval(checkf, 1000);
Extract the Images Within a PDF File via Pdfimages
RJM Programming ➡ April, 2023
";
$outp='ideas';
$pathp='.' . DIRECTORY_SEPARATOR;
if (isset($_GET['inpath'])) {
if (trim(str_replace('+',' ',urldecode($_GET['inpath']))) != '') {
$pathp=str_replace('+',' ',urldecode($_GET['inpath']));
if (substr(strrev($pathp),0,1) != DIRECTORY_SEPARATOR) {
$pathp.=DIRECTORY_SEPARATOR;
}
}
} else if (isset($_POST['inpath'])) {
if (trim(str_replace('+',' ',urldecode($_POST['inpath']))) != '') {
$pathp=str_replace('+',' ',urldecode($_POST['inpath']));
if (substr(strrev($pathp),0,1) != DIRECTORY_SEPARATOR) {
$pathp.=DIRECTORY_SEPARATOR;
}
}
}
if (isset($_GET['outprefix'])) {
$outp=str_replace('+',' ',urldecode($_GET['outprefix']));
if (trim($outp) == "") { $outp='ideas'; }
} else if (isset($_POST['outprefix'])) {
$outp=str_replace('+',' ',urldecode($_POST['outprefix']));
if (trim($outp) == "") { $outp='ideas'; }
}
if (isset($_GET['convertthis'])) {
$infile='"' . $pathp . str_replace('+',' ',urldecode($_GET['convertthis'])) . '"';
} else if (isset($_POST['convertthis'])) {
$infile='"' . $pathp . str_replace('+',' ',urldecode($_POST['convertthis'])) . '"';
} else if (strpos(('' . $_SERVER['SERVER_NAME']), "localhost") === false) {
echo "
" . str_replace(explode('>', explode('', explode("', '', explode('', explode("
";
echo str_replace($rest, $restto, $proposedtable);
//exit;
} else {
echo "
var lastpath='', lastfilename='';
function checkf() {
if (document.getElementById('justputpdffilename').innerHTML != '') {
document.getElementById('justputpdffilename').title=document.getElementById('justputpdffilename').innerHTML;
document.getElementById('justputpdffilename').innerHTML='';
if (document.getElementById('thewords').value.trim() == '' || document.getElementById('thewords').value == lastfilename) {
document.getElementById('thewords').value=document.getElementById('justputpdffilename').title;
lastfilename=document.getElementById('justputpdffilename').title;
}
if (document.getElementById('justputpdfpath').innerHTML == '' && document.getElementById('justputpdfpath').title == '') {
if (document.getElementById('justputpdffilesize').innerHTML != '') {
//alert('am going away to look for filename=' + lastfilename + ' of size ' + document.getElementById('justputpdffilesize').innerHTML);
document.getElementById('justputpdfpath').title=' ';
//var xx=prompt(document.URL.split('?')[0].split('#')[0] + '?filepath=&filesize=' + document.getElementById('justputpdffilesize').innerHTML + '&filename=' + encodeURIComponent(lastfilename), document.URL.split('?')[0].split('#')[0] + '?filepath=&filesize=' + document.getElementById('justputpdffilesize').innerHTML + '&filename=' + encodeURIComponent(lastfilename));
document.getElementById('path').style.cursor='progress';
document.getElementById('gifif').src='./php_calls_pdfimages.php?filepath=&filesize=' + document.getElementById('justputpdffilesize').innerHTML + '&filename=' + encodeURIComponent(lastfilename);
}
}
}
if (document.getElementById('justputpdfpath').innerHTML != '') {
document.getElementById('justputpdfpath').title=document.getElementById('justputpdfpath').innerHTML;
document.getElementById('justputpdfpath').innerHTML='';
if (document.getElementById('justputpdfpath').title.indexOf('/') != -1) {
if (document.getElementById('justputpdfpath').title.slice(-1) != '/') {
document.getElementById('justputpdfpath').title+='/';
}
} else {
if (document.getElementById('justputpdfpath').title.slice(-1) != String.fromCharCode(92)) {
document.getElementById('justputpdfpath').title+=String.fromCharCode(92);
}
}
if (document.getElementById('path').value.trim() == '' || document.getElementById('path').value == lastpath) {
document.getElementById('path').value=document.getElementById('justputpdfpath').title;
lastpath=document.getElementById('justputpdfpath').title;
}
}
if (document.getElementById('path').value != '') {
document.getElementById('path').style.cursor='pointer';
}
}
function iifopen(iois) {
if (iois != null) {
var aconto = (iois.contentWindow || iois.contentDocument);
if (aconto.document) { aconto = aconto.document; }
if (aconto != null) {
//alert(1);
if (aconto.getElementById('distyle')) {
aconto.getElementById('distyle').innerHTML+='';
aconto.getElementById('files').accept='.pdf';
aconto.getElementById('files').multiple=false;
aconto.getElementById('files').style.border='5px solid yellow';
arect=aconto.getElementById('files').getBoundingClientRect();
//alert(2);
//aconto.getElementById('files').click();
}
}
}
}
setInterval(checkf, 1000);
... or ...
Extract the Images Within a PDF File via Pdfimages
RJM Programming - April, 2023
";
exit;
}
if (PHP_OS == "Darwin") {
$huhw=shell_exec("where pdfimages");
if (strpos($huhw, DIRECTORY_SEPARATOR) !== false) {
$proposedtable=str_replace('>', '>' . $huhw . ' -j ' . $infile . ' ' . $outp . ' -png', $proposedtable);
exec($huhw . ' -j ' . $infile . ' ' . $outp . ' -png');
} else {
if (1 == 1) {
putenv('PATH=/usr/local/bin');
$proposedtable=str_replace('>', '>pdfimages -j ' . $infile . ' ' . $outp . ' -png', $proposedtable);
exec('pdfimages -j ' . $infile . ' ' . $outp . ' -png');
} else {
$proposedtable=str_replace('>', '>/usr/local/bin/pdfimages -j ' . $infile . ' ' . $outp . ' -png', $proposedtable);
exec('/usr/local/bin/pdfimages -j ' . $infile . ' ' . $outp . ' -png');
}
}
} else if (PHP_OS =='WINNT' || PHP_OS =='WIN32' || PHP_OS =='Windows') {
$proposedtable=str_replace('>', '>pdfimages -j ' . $infile . ' ' . $outp . ' -png', $proposedtable);
exec('pdfimages -j ' . $infile . ' ' . $outp . ' -png');
}
$sofarw=0;
$vsw=0;
$padbr='';
if (isset($_GET['sw'])) {
$vsw=$_GET['sw'];
}
foreach (glob($outp . '-*') as $filename) {
$datau='data:image/' . str_replace("jpg","jpeg",strtolower(explode(".", $filename)[-1 + sizeof(explode(".", $filename))])) . ';base64,' . base64_encode(file_get_contents($filename));
$proposedtable=str_replace('', ' | ', $proposedtable);
$proposedtable=str_replace('', ' |
', $proposedtable);
list($width, $height, $type, $attr) = getimagesize($filename);
if ("$vsw" != "0" && ($sofarw + $width) > $vsw) { $padbr="
"; $sofarw=($width + 5); } else { $sofarw+=($width + 5); }
$proposedtable=str_replace('', $padbr . ' ', $proposedtable);
$padbr='';
if ($outp != strtoupper($outp)) { unlink($filename); }
}
echo str_replace($rest, $restto, $proposedtable);
exit;
?>