vinay varanasi

Greenhorn
+ Follow
since Apr 29, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by vinay varanasi

The problem is that the documents in this project are eforms stored and retereived from IBM's content manager. They cannot be permanently encrypted during creation since it is against the client specification. I have browsed through some forums and found issues with using encryption in iText for disabling both print and save before display in browser via adobe acrobat reader.

Since these pdf documents are sensitive documents embedded with digital signatures trying any form of conversions leading to corruption could become a problem. Since these forms are to be made available to the end users who pays per view of these documents.

Server side viewer is viewed here as a safer option. This is what I have implemented earlier but paid licences becomes an issue.
11 years ago
My project requirement is to disable print and save options when displaying pdf document. when the document opens in adobe acrobat pdf reader via a browser disabling the buttons is not possible. Adobe itself provides free to use API for customising server side pdf reader where one can customize all the buttons in the viewer but none of the methods provided in the API work.

I have successfully implemented the server side custom pdf viewers provided by ICESOFT technologies and jPDF by Crionics but our client is not ready to spend for licencing.


I am looking for any open source server side pdf viewer solution where i can disable the print and save options.
11 years ago
I want to convert display a PDF document with is available to me in byte array format to a video output stream that I can display using quicktime plugin on my browser.

Please suggest some API available for such conversion.
11 years ago
Hey
I have been using the followinf code to ftp my files for the past 4 months and it has been working fine.

The ftp works fine as long as the band width is high enough based on the file size.

I have also put a success check based on the file size.

You can use the putFile(<file name> method to initiate FTP.


See if the following code helps.
==========================================================================
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.net.URLConnection;
import java.text.SimpleDateFormat;
import java.util.StringTokenizer;
import java.util.*;
import sun.net.TelnetInputStream;
import sun.net.ftp.FtpClient;
import sun.net.www.protocol.http.HttpURLConnection;
import sun.security.x509.IssuerAlternativeNameExtension;
import java.io.*;

public class FtpToServer extends FtpClient
{
public static int BUFFER_SIZE = 10240;
private static FtpClient m_client;
private static String host = "";
private static String user = "";
private static String password = "";
private static String targetDataDir = "";
private static String targetResultsDir = "";
private static String sourceDir = "";
private static String sourceFile = "";
public static char SEPARATOR = '/';
public String targetFile = "";
public String ftpStartTime="";
public String ftpEndTime="";
public String servletStartTime="";
public String servletEndTime="";



private String getUniqueId()
{
String strUniqueId = "";
Date date = new Date();
SimpleDateFormat simpledateformat = new SimpleDateFormat("yyyyMMddhhmmssSSSSSS");
strUniqueId = simpledateformat.format(date)+(int)(Math.ceil(Math.random()*1000));
return strUniqueId;
}

public String getCurrentDateTime()
{
Date date = new Date();
SimpleDateFormat simpledateformat = new SimpleDateFormat("hhmmssSSSSSS");
String datetime = simpledateformat.format(date);
datetime = datetime.substring(0,2)+":"+datetime.substring(2,4)+":"+datetime.substring(4,6)+"."+datetime.substring(6);
return datetime;
}

private String getUniqueFolderId()
{
String strUniueId = getUniqueId();
String strDateId = "";
String strTimeId = "";
String strFolderId = null;
strDateId = strUniueId.substring(0,7) + SEPARATOR;
strTimeId = strUniueId.substring(8,9) + SEPARATOR;
strFolderId = strDateId + strTimeId + strUniueId ;
return strFolderId;
}

public FtpToServer(StringBuffer dCSVFile,StringBuffer rCSVFIle) throws IOException
{
//Properties p = new Properties();
//p.load(new FileInputStream("ScrutiNet.properties"));
host=ScrutinetConstants.TARGETMACHINE;
user=ScrutinetConstants.USER;
password=ScrutinetConstants.PASSWORD;
targetDataDir=ScrutinetConstants.TARGETROOTDIRECTORYDATA;
targetResultsDir=ScrutinetConstants.TARGETROOTDIRECTORYRESULTS;
ftpStartTime = getCurrentDateTime();
//System.out.println(host);
m_client = new FtpClient(host,21);
//System.out.println(user + " " + password);
m_client.login(user, password);
//System.out.println("User " + usder + " login OK");
//System.out.println("hello " + m_client.welcomeMsg);
//System.out.println("Calling Ftp of Data CSV");
m_client.cd(targetDataDir);
m_client.binary();
//System.out.println("Calling first put CSV");
putFile(dCSVFile);
//System.out.println("After Calling first put CSV");


//System.out.println("Calling Ftp of Results CSV");
m_client.cd(targetResultsDir);
putFile(rCSVFIle);
ftpEndTime = getCurrentDateTime();
}

protected void disconnect()
{
if (m_client != null)
{
try
{
m_client.closeServer();
}
catch (IOException ex)
{
ex.printStackTrace();
}
m_client = null;
}
}

protected void putFile(StringBuffer sbFileNameToSend)
{
if (sourceFile.length() == 0)
{
//System.out.println("Please enter file name");
}
byte[] buffer = new byte[BUFFER_SIZE];
try
{
File f = new File(sbFileNameToSend.toString());
int size = (int) f.length();
//System.out.println("Entering FTP");
FileInputStream in = new FileInputStream(sbFileNameToSend.toString());
OutputStream out = m_client.put(sbFileNameToSend.substring(sbFileNameToSend.lastIndexOf("\\")+1));
int counter = 0;
while (true)
{
int bytes = in.read(buffer);
if (bytes < 0) break;
out.write(buffer, 0, bytes);
counter += bytes;
}
System.out.println("FTP Done");
out.close();
in.close();
}
catch (Exception ex)
{
ex.printStackTrace();
System.out.println("Error in FTP: " + ex.toString());
}
}
}
11 years ago
Have you tried the File.list() option?
you can use the URI constructor for specifying the location of the files on the server.
11 years ago
Thanks,
I ran the code in debugger mode and foud out that one of the outputstreams was redundant and it was holding up the file from deletion.

I have also come accross apache's class "FileDeleteStrategy" which provides the facility of forced delete. It is contained in the org.apache.commons.io package.
11 years ago
Hi,
I have a problem with deleting CSV files from my system using the Delete method of File Class.

The problem is that while some times the files get deleted some times it fails.

I have to clean up a certain directory after copying the files to a new loaction.

for some CSV files this works fine while it fails for certain files especially if it is a 0 KB file

Is there any way to force a delete using java other than File.delete(); method. I have also tried File.deleteOnExit() method but it was of no help.
Thanks
11 years ago
yes a parenthesis was used accidentally instad of a brace the code is fine. do change that.

you Should use the match brace function of your editor to avoid this kinds of problems in future.
11 years ago



EDIT by mw: Left enough of the code for a "hint," but removed solution.
[ December 12, 2006: Message edited by: marc weber ]
11 years ago