Call us on
+44 (0) 2077 545 948
Quickly and easily convert Notes to PDF. With only 2 lines of code any Notes / Domino content can be saved as PDF.
Download Now| Unzip Files From LotusScript |
|
LotusScript does not have a native class for uncompressing files to .zip format. If you are running Notes or Domino R6 (or newer), by using the ability of LotusScript to make calls to functionality that is available in the Java language via LS2J -- which is documented in Designer Help.
Sub Initialize
Dim js As JAVASESSION
Dim zipClass As JAVACLASS
Dim zipFileObject As JavaObject
Dim varFileToZip As String, varOutFilePath
As String, returnCode As String
Set js = New JAVASESSION
Set zipClass = js.GetClass("ZipFile")
Set zipFileObject = zipClass.CreateObject
varFileToZip = "c:tempdocument.doc"
varOutFilePath = "c:tempthezipfile.zip"
returnCode = zipFileObject.zipMyFile
(varFileToZip, varOutFilePath)
'Calling the zip function
If Not returnCode = "OK" Then
Print "An Error occurred"
Else
Print "Zip went OK"
End If
End Sub
In the Options of the agent I have the following: Uselsx "*javacon" 'Which lets you use Java from LotusScript Use "ZipFile" 'A Java library that holds a function to do zipping Below is the Java Library that makes it possible to zip a file. You create a Java Library in the Designer in Shared code > Script Libraries, click New Java Library, remove the few lines of code that you get as a help for getting started, and paste the code below. Save and call the library "ZipFile."
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.zip.Deflater;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
public class ZipFile {
public String zipMyFile(String fileToZip,
String zipFilePath) {
String result = "";
byte[] buffer = new byte[18024];
// Specify zip file name
String zipFileName = zipFilePath;
try {
ZipOutputStream out =
new ZipOutputStream
(new FileOutputStream(zipFileName));
// Set the compression ratio
out.setLevel
(Deflater.BEST_COMPRESSION);
System.out.println(fileToZip);
// Associate a file input stream
for the current file
FileInputStream in =
new FileInputStream(fileToZip);
// Add ZIP entry to output stream.
out.putNextEntry
(new ZipEntry(fileToZip));
// Transfer bytes from
the current file to the ZIP file
//out.write(buffer, 0, in.read(buffer));
int len;
while ((len = in.read(buffer)) > 0)
{
out.write(buffer, 0, len);
}
// Close the current entry
out.closeEntry();
// Close the current file input stream
in.close();
// Close the ZipOutPutStream
out.close();
}
catch (IllegalArgumentException iae) {
iae.printStackTrace();
return "ERROR_
ILLEGALARGUMENTSEXCEPTION";
}
catch (FileNotFoundException fnfe) {
fnfe.printStackTrace();
return "ERROR_FILENOTFOUND";
}
catch (IOException ioe)
{
ioe.printStackTrace();
return "ERROR_IOEXCEPTION";
}
return "OK";
}
}
Comments
(0)
|
| Quick And Easy Notes To PDF Conversion + Read More |
| PDF Forms For Lotus Domino: Compendia Implements DominoPDFCompendia, a Primeapple partner in Norway, has implemented a stock / fund trading application using DominoPDF for FMG, a multi-manager fund company. + Read More |
| Lotus Notes Attachments To PDFIBM Notes / Domino is an ideal platform for managing and storing a wide range of rich content, files, objects and attachments. + Read More |
| Home |
| Download |
| Case Studies |
| Testimonials |
| Contact Us |