Sunday, December 14, 2008

Free fax server

Hylafax is a open source fax server written in java. You can configure the sources to use the fax server.

There is client written in java called as "YajHFC".

This is the sample client.


HylaFax Client
----------------



Job job = null;

String user = "test"; // -u
String host = "hyla fax server ip"; // -h
String destination = "destination number"; //
String from = empname; // -f
String killtime = "000259"; // -k
int maxdials = 12; // -T
int maxtries = 3; // -t
int priority = 127; // -P
String notifyaddr = addr; // -f
int resolution = 98; // -l, -m
Dimension pagesize; // -s
String notify = "none";
String pagechop = "default";
int chopthreshold = 3;
Vector documents = new Vector();
boolean verbose = false;
boolean from_is_set = false;

pagesize = Pagesize.A4; // default pagesize is US Letter

HylaFAXClient c = new HylaFAXClient();

try {
c.open(host);
System.out.println("Open host and returned " + c.toString());

if (c.user(user)) {
c.pass("test123");
c.admin("test123");
}

System.out.println("Check point 0:");
c.noop(); // for the heck of it

c.setPassive(true);
c.type(HylaFAXClientProtocol.TYPE_IMAGE);

c.tzone(ClientProtocol.TZONE_LOCAL);
System.out.println("Check point 1");
System.out.println("current directory is: " + c.pwd());

String filename = "/export/home/" + fileName; // where your file located

FileInputStream file = new FileInputStream(filename);
String remote_filename = c.putTemporary(file);

documents.addElement(remote_filename);

job = c.createJob(); // start a new job

// set job properties
job.setFromUser(from);

job.setKilltime(killtime);
job.setMaximumDials(maxdials);
job.setMaximumTries(maxtries);
job.setPriority(priority);
job.setDialstring(destination);
job.setVerticalResolution(resolution);
job.setPageDimension(pagesize);
job.setNotifyType(notify);
job.setChopThreshold(chopthreshold);
job.setNotifyAddress(notifyaddr);

// add documents to the job
for (int i = 0; i < documents.size(); i++) { String document = (String)documents.elementAt(i); job.addDocument(document); } c.submit(job);

No comments:

Post a Comment