Save PDF file on Server

Hi

Does anyone have any notes on how saving and displaying files (PDF’s) works in different situations?

I wish to save a form as a PDf report for recall later. ( In this case saving quotes for later reference)
In Smart client it seems it will save on the client pc by default. How do I get it to always save on the windows server. Smart client may run on Windows or Mac…
Webclient seems to always save on the Server ( this make sense)… However when I display the pdf it displays on the server and not the pc running the web client.

Here is code I have at present. Any comments appreciated

// Saves pdf to file - must save on server
forms[vForm].controller.print(true,false,plugins.pdf_output.getPDFPrinter(vFolder+vFile));

//Step 2 - View Saved pdf
var vOS = application.getOSName();
if(utils.stringPatternCount(vOS, ‘Windows’) == 1) {
// Display PDF
application.executeProgram( ‘rundll32’, ‘url.dll,FileProtocolHandler’, vFFile );
}
else if(utils.stringPatternCount(vOS, ‘Mac’) == 1){
application.executeProgram(‘open’, vFFile );
}

else if(utils.stringPatternCount(vOS, ‘FreeBSD’) == 1 || utils.stringPatternCount(vOS, ‘Linux’) == 1){
application.executeProgram(‘mozilla’, vFFile );
}
else {
application.executeProgram( ‘rundll32’, ‘url.dll,FileProtocolHandler’, vFFile );
}

Hi Mark

You can use the java.awt.Desktop to open, print and edit any kind of documents.

public class Functions {
	
	boolean open (String file) throws IOException
	{
		boolean success = false;
		File myFile = new File (file);
		if (myFile.exists())
		{
			 if (Desktop.isDesktopSupported())
			 {
				Desktop.getDesktop().open(myFile);
				success = true;
			 }
			 else
				return false; 
		 }
		 return success;
	}
	
	boolean print (String file) throws IOException
	{
		boolean success = false;
		File myFile = new File(file);
		if (myFile.exists())
		{
			 if (Desktop.isDesktopSupported())
			 {
				Desktop.getDesktop().print(myFile);
				success = true;
			 }
			 else
				return false; 
		 }
		 return success;
	}
	
	boolean edit (String file) throws IOException
	{
		boolean success = false;
		File myFile = new File (file);
		if (myFile.exists())
		{
			 if (Desktop.isDesktopSupported())
			 {
				Desktop.getDesktop().open(myFile);
				success = true;
			 }
			 else
				return false; 
		 }
		 return success;
	}
}

I’ve done a very simple plugin to servoy including this functions.

Best regards. Roberto Blasco.

jfileutils.jar (5.22 KB)

Hi Roberto

Thank you for your reply. Unfortunately , because I am new to Servoy and Java, none of what you say makes any sense to me.

Surely there is some simple command as a way of directing a file save to either the server folder or the local smart clients folder.

Thanks Mark