Scripting PDF files

Pierre Sahores psahores at easynet.fr
Wed Oct 29 16:23:07 EST 2003


Le mer 29/10/2003 à 21:49, J. Landman Gay a écrit :

> On 10/29/03 2:42 PM, Mark Powell wrote:
> > 
> > http://www.activepdf.com/en/Products/WebGrabber/Start.asp
> > 
> > This would presuppose that you have HTML in your flow, which you may not
> > want to do.  And it presupposes that it can be driven from Rev, which I
> > don't yet know.  But food for thought.
> 
> If you find out if it works, let us know. Unfortunately for me, this is 
> a Windows-only solution.

Hello again, Jacque, Friends,

See below how to drive this kind of workflow in using HTMLDOC (available
as source package for OSX, Win32, and Linux) from easysoftware.com (the
CUPS printing system author), with the help of Apache and PHP :

1.- the transcript server-sided part, witch outputs the result direclty
to the client-side webbrowser, where LeTestNe is, as var, the main part
of the name of the html file witch will be ouptputed as PDF file.:

> on PDFoMaticbyMC -- (portrait)
>   global Retour,LeTestNe,MasNPE1,Lepath
>   get shell ("htmldoc --quiet --jpeg --links --webpage --portrait --size A4 -t pdf14 -f /tmp/p" & LeTestNe & ".pdf /tmp/p" & LeTestNe & ".html")
>   set httpheaders to "Content-Type: application/pdf" & cr & "Content-Length:" && the length of "lalalahitou" & cr & cr # Apache :oui ; IIS : non
>   put "<HTML><SCRIPT>window.open('wmc.php?f=/tmp/p" & LeTestNe & ".pdf');</SCRIPT></HTML>" into Retour
> end PDFoMaticbyMC
> 
> 
> on PDFoMaticbyMCLS -- (landscape)
>   global Retour,LeTestNe,Lepath
>   get shell ("htmldoc --quiet --jpeg --links --webpage --landscape --size A4 -t pdf14 -f /tmp/p" & LeTestNe & ".pdf /tmp/p" & LeTestNe & ".html")
>   set httpheaders to "Content-Type: application/pdf" & cr & "Content-Length:" && the length of "lalalahitou" & cr & cr # Apache :oui ; IIS : non
>   put "<HTML><SCRIPT>window.open('wmc.php?f=/tmp/p" & LeTestNe & ".pdf');</SCRIPT></HTML>" into Retour
> end PDFoMaticbyMCLS

2.- the php part :

> <?
> 
> $f=$HTTP_GET_VARS['f'];
> 
> #Contrôle du fichier (à ne pas oublier !)
> if (substr($f,5,4)!='p093' or strpos($f,'.php') or strpos($f,'/') or strpos($f,'\\'))
>  	{
> 	print ("<HTML><HEAD><TITLE>ERROR: File Not Found</TITLE></HEAD>".
>        	"<BODY background='/gif/fond-maison.gif'><H1>File Not Found</H1><P>".
>         "<H3>Nom de fichier incorrect.</H3>".
> 	"</BODY></HTML><BR>\n");
> 	exit;
> 	}
> if (!file_exists($f))
>  	{
> 	print ("<HTML><HEAD><TITLE>ERROR: File Not Found</TITLE></HEAD>".
>        	"<BODY background='/gif/fond-maison.gif'><H1>File Not Found</H1><P>".
>         "<H3>Le document attendu résulte d'une publication qui n'est plus
> 	disponible. Renouvelez la requête initiale pour le recharger.</H3>".
> 	"</BODY></HTML><BR>\n");
> 	exit;
> 	}
> if($HTTP_ENV_VARS['USER_AGENT']=='contype')
>  	{
>  	print ("<HTML><HEAD><TITLE>ERROR: File Not Found</TITLE></HEAD>".
>        	"<BODY background='/gif/fond-maison.gif'><H1>File Not Found</H1><P>".
>         "<H3>Pour pouvoir consulter ce document, une mise-à-jour de votre navigateur IE est nécessaire.</H3>".
> 	"</BODY></HTML><BR>\n");
> 	exit;
> 	}
> 	
> #Envoi du PDF
> header('Content-type: application/pdf');
> // header('Content-disposition: inline; filename=($f)');
> readfile($f);
> 
> #Suppression du fichier
> unlink($f);
> exit;
> 
> ?>

-- 
Bests, Pierre Sahores

100, rue de Paris
F - 77140 Nemours

psahores at easynet.fr

GSM:   +33 6 03 95 77 70
Pro:   +33 1 41 60 52 68
Dom:   +33 1 64 45 05 33
Fax:   +33 1 64 45 05 33

Inspection académique de Seine-Saint-Denis
Applications et SGBD ACID SQL (WEB et PGI)
Penser et produire "delta de productivité"


More information about the use-livecode mailing list