Processing Create .SFF file Format (Structured Fax Format)
It will create from pdf file --> tiff file --> sff file. Important for tiff file, it will only width = 1728 . If you are not use this width, It may not work. Use Library
1. Use iText for create PDF File --> download
2. Use JAI (Java Advance Imaging) For Convert PDF to TIFF File --> download
3. Use mms-computing (mmsc) For Convert TIFF to SFF File --> download
Step Create SFF File
1. Create PDF File.
Example
String filename = "pdfTest.pdf";
Rectangle rectangler = new Rectangle(1728,2292);
Document document = new Document(rectangler);
PdfWriter.getInstance(document, new FileOutputStream(filename));
document.open();
document.add(new Paragraph("Hello World",new Font(Font.BOLD,75)));
document.close();
String filename = "pdfTest.pdf";
Rectangle rectangler = new Rectangle(1728,2292);
Document document = new Document(rectangler);
PdfWriter.getInstance(document, new FileOutputStream(filename));
document.open();
document.add(new Paragraph("Hello World",new Font(Font.BOLD,75)));
document.close();
2. Convert PDF to TIFF File.
Example
PdfDecoder decoder = new PdfDecoder();
decoder.openPdfArray(bai);
decoder.setSize(100, 100);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
if (decoder.isFileViewable()) {
try {
for (int i = 0; i < decoder.getPageCount(); i++) {
int pageNumber = i + 1;
BufferedImage imageTemp = decoder.getPageAsImage(pageNumber);
BufferedImage image = new Binarization(50).filter(imageTemp);
TIFFEncodeParam tiff = new TIFFEncodeParam();
OutputStream outp = (new FileOutputStream("tiffTest.tiff"));
ImageEncoder encoder = com.sun.media.jai.codec.ImageCodec.createImageEncoder("tiff", outp, tiff);
encoder.encode(image);
outp.close();
}
} finally {
if (baos != null) {
baos.flush();
baos.close();
}
}
}
decoder.closePdfFile();
3. Convert TIFF to SFF File. I use open TIFF File and save to SFF File. You can find it by see at uk.co.mmscomputing.application.imageviewer.ImageTab class --> Method save and open.