[FX.php List] [OFF] Saving a PDF file to a Server

Ernest Cunningham ernest.cunningham at gmail.com
Wed Oct 8 16:45:07 MDT 2008


Kia Ora Roger,

There must be a writable  folder on the windows machine the clients  
are remotely logging into (are they using Terminal Services to connect  
to a terminal server and then FileMaker Pro to the FM Server?). Just  
do an if statement when creating the path to save the pdf.

if ( Abs(Get ( SystemPlatform )) = 1 ; "Do Somethign for Mac ;  
"Otherwise do something for Windows" )

You can then setup the shares to automatically mount on the machine on  
startup and use something like Get ( HostIPAddress ) in your path calc  
above.


There are a dozen ways I can think to solve this such as saving to a  
scriptable folder and have the applescript on mac and VBS in windows  
do the saving to the network drive including mounting the volume for  
you if not already mounted.

Not sure what blackbelt is but as long as you can link to the another  
page like the one I am writing now for ya, then I would look at  
storing the pdf in a container field then linking to it. So in your  
website you link to a page like this getPDF.php?uid=yourUID and then  
that will produce the pdf to the user.

Here is some code I just rustled up as a base for you to work with. I  
have not tested it but it should work (i think lol).


'<?php
define("DEBUG",  
false);                                                         // by  
setting DEBUG to true, you can look at some of what FX.php is doing
include_once($_SERVER['DOCUMENT_ROOT'] . "/FX/FX.php");
include_once($_SERVER['DOCUMENT_ROOT'] . "/FX/image_proxy.php");				
include_once($_SERVER['DOCUMENT_ROOT'] . "/FX/server_data.php");


//
// Set variables.
$uid = $_REQUEST['uid'];			// the UID of the record you wanna pull  
your pdf from. linked to like his /getPDF.php?uid=yourUID
$layout = 'Your Search Layout' ;

//
// Setup Search.
$pdfGetQuery = new FX($serverIP, $webCompanionPort, $dataSourceType);
$pdfGetQuery->SetDBData($database, $layout);
$pdfGetQuery->SetDBUserPass ($webUN, $webPW);
$pdfGetQuery->AddDBParam('Your UID Field', $uid);
$searchResults = $pdfGetQuery->FMFind();				// Find the record you  
want the pdf from.

$record = each ($searchResults['data']) ;
$value = $record['value'] ;
$key = $record['key'] ;


//
// Here is where you get the pdf file....

// Create the link to pdf file
$pdfFileLink = "http://".$webUN.":".$webPW."@127.0.0.1:80". 
$value['PDF'][0];

// Here is where we want to save the pdf.
$pdfSaveLink = $_SERVER['DOCUMENT_ROOT']."/yourwebsite/savedpdf/". 
$value['PDF Name'][0].".pdf";

// Now save the pdf from the container field to our save folder
copy($pdfFileLink,$pdfSaveLink);

// Ok now point this page to saved pdf
header("Cache-Control: public");
header("Content-Description: File Transfer");
header('Content-disposition: attachment;  
filename='.basename($pdfSaveLink));
header("Content-Type: application/pdf");
header("Content-Transfer-Encoding: binary");
header('Content-Length: '. filesize($pdfSaveLink));
readfile($pdfSaveLink);
?>'



You will need to put your own specifics like user and password in etc  
and your website save directory or what not.

Ok so I am a part time php hack, but you know as a kiwi we are from  
the "Can Do" mould and will learn to do anything lol.
I have attached this code in a file with this email but I am not sure  
what this list tolerates so may not be attached when it reaches you  
but I also pasted the code in this email.

So with that said if anybody else on this list knows of a better way  
or simpler way to do this then please share :D


Kind regards,

Ernest Cunningham

__________________________________________________________

   FileMaker Database Developer
   Nelson,  New Zealand

   Ernest Cunningham
   Mobile: +64-21-40 66 75
   Web Site: www.ging.co.nz
__________________________________________________________




On 9/10/2008, at 2:07 AM, Roger Moffat wrote:

>
> On Oct 8, 2008, at 12:37 AM, Roger Moffat wrote:
>
>> I "think" I have it running OK now. Using your hint of Get  
>> (Temporary Path ) which showed me just exactly what the format of a  
>> path that FileMaker was expecting to see looked like, I've got the  
>> Database now writing out the file onto the FM Server machine into a  
>> folder there (not the temp folder now) and then put an automator  
>> action onto that folder to copy the file from there to the Mac with  
>> the Web Publishing Engine and Apache server on it. This seems to  
>> work.
>>
>> (Perhaps with more trial and error I could figure out how to write  
>> it directly to the Apache server machine assuming it was mounted as  
>> an afp volume on the FM Server machine) but it's very late now.
>>
>> I tried the container field suggestion, and that worked too within  
>> the database, but since I'm actually using BlackBelt for the web  
>> stuff I couldn't figure out how to get that called as a link on a  
>> page to see the PDF file.
>>
>> From one Kiwi (in Michigan) to another
>>
>> Thanks!!!!!!
>
> Well I spoke too soon - the light of day has revealed why it worked  
> last night, but now wouldn't work this morning...
>
> It only works if the computer I have the database open in FileMaker  
> Pro from is also connected to the database server by AFP. If I'm not  
> connected by FileSharing to the FM Server computer, then I can't  
> write the PDF file out to that machine.
>
> I can't write it to the temppath since I get told there aren't  
> enough permissions - that folder us UID 305, and when viewed in the  
> Finder and is unreadable by the Admin user of the computer.
>
> For the remote Windows users it seems like all they can do is  
> generate the PDF file and then handle a dialog box that lets them  
> save the PDF file to THEIR computer.
>
> It seems like such an everyday thing to be able to have the FM  
> Server generate a PDF file which can then be saved onto that server  
> automatically, but unless I'm missing something I'm completely  
> stumped.
>
>
> Roger
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list

-------------- next part --------------
Skipped content of type multipart/mixed


More information about the FX.php_List mailing list