Page 1 of 1

open all those pdfs at the same time?

Posted: Wed Sep 13, 2006 6:35 am
by mlecho
hi - i did some searching about the forums (and beyond) with no luck. This all started with writing a simple script to look into directories, capture the contents of txt files and then spit out all the texts into one page , printer friendly.

Code: Select all

<head>
<script language="javascript">
function printEm(){
	setTimeout('window.print()',1000);
}
</script>
</head>
<body onLoad="javascript:printEm()">

<?php

$dir="theseDocs/";
$openDir=opendir($dir);
while(false !=($file= readdir($openDir))){
	if(!preg_match('/^\./',$file)){
	
		$readFile=fopen($dir.$file,'r');
		$contents=fread($readFile,1000);
		echo($contents."<br>");
	}
} 
?>

</body>
that worked fine, but now the next step is to do somethign similar with pdf's ...even if the "somethign" was to just open each file in a directory, into a seperate window....that could suffice. I understand that trying to write a script that woudl essentially tie all the pdf's into one printable file would be a bit crazy.

Why? our internal intranet generate weekly reports that are created in pdf...there are about 12 reoorts each week, and having to click, open, print, "back" ,click, open, print , "back" has finally taken its toll! The alternative would be if php could just send the data to the printer, and forego opening all together...but is that really possible???

Posted: Wed Sep 13, 2006 7:52 am
by Rovas
I found a similar problem on a different forum and the single solution that he found was to download them all in a directory on client machine to concatenate all pdf files in to one and print that out. He said he used the pdf related functions of PHP.

Posted: Wed Sep 13, 2006 9:15 am
by batfastad
I've not looked at PDF functions that much, but I believe with

http://www.fpdf.org/

and

http://fpdi.setasign.de/index.php?p=home

It should be possible to concatenate all the PDFs, then you can just download that file to the user and print it.
And both those tools appear to be free.


HTH

Ben