← servoy magazine

[Tip] Faxing from within Servoy

  • Tips

by Jan Aleman
Servoy

To fax from within Servoy there are a quite few options: specialised fax software, fax gateways, special hardware, web services, fax beans, etc. Probably the easiest is an email to fax service. I found one at:

http://www.interfax.net

They offer a free developer account. You can email plain text but also a pdf. Create a pdf in Servoy and email it to the service. For example to email the current record of the current form you can use the following method:

//print the current form as pdf into a variable
var success = plugins.pdf_output.startMetaPrintJob()
if (success)
{
   controller.print(true,false,plugins.pdf_output.getPDFPrinter());
}
var thePdf = plugins.pdf_output.endMetaPrintJob()
//email it to the fax service
var attachment1 = plugins.mail.createBinaryAttachment('fax.pdf',thePdf);
var succes = plugins.mail.sendMail('+31842242422@fax.tc',
'jaleman@servoy.com', "Here's a fax", '',null,null,new Array(attachment1));
if (!succes)
{
   plugins.dialogs.showWarningDialog('Alert','Failed to send fax','OK');
}

Replace +31842242422 with the fax number you want to fax to. Replace jaleman@servoy.com with the email that is registered with interfax. If you implement this in a solution you'd obviously have the fax number come out of a (related) field.

Isn't Servoy amazing? You can implement faxing in your solution in less than 5 minutes!

NOTE: This tip uses the Pdf printer plugin by Rumora, if you don't have it yet you can download it here:
http://forum.servoy.com/download.php?id=383
(the link above will only work if you are logged in to the forum)

Comments (1)

Stef Compeers
Great tip, Jan! We had it working in less than 15 minutes!