1

I had worked on converting file format to .afb file using FOP service. (Code smaple below)

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.sax.SAXResult;
import javax.xml.transform.stream.StreamSource;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FopFactory;

public class FopService 
{

public FopService() throws FOPException, TransformerException, IOException
{
    FopFactory fopFactory = FopFactory.newInstance();  
    OutputStream out = new BufferedOutputStream(new FileOutputStream(new File("E/myfile.X")));
    try{
    Fop fop = fopFactory.newFop(MimeConstants.MIME_FOP_IF, out);
    TransformerFactory factory = TransformerFactory.newInstance();
    Transformer transformer = factory.newTransformer(); // identity transformer
    Source src = new StreamSource(new File("E/ResultAFP.afp"));
    Result res = new SAXResult(fop.getDefaultHandler());
    transformer.transform(src, res);
  }
  finally {
      //Clean-up
    out.close();
  }
  }
}  

Now i need to print this .afp file on a printer.Any java api for it?? Explain the steps.

Abhi jaZz
  • 11
  • 3
  • You won't be able to print AFPDS files directly. It's not a page description language that printers handle natively (as opposition to lower level ones like PS or IPDS). – user18428 Nov 30 '15 at 11:40
  • I am talking about Advanced Function Presentation(apf format files). – Abhi jaZz Nov 30 '15 at 12:02
  • Me too. AFPDS = Advanced function printing data stream (ie. .afp printable files) – user18428 Nov 30 '15 at 15:30
  • I did not say it cannot be printed (it is in fact its main purpose : to be printed). It is a high level page description language that has to be converted to some lower level one (usually IPDS for AFP) by a RIP software. BTW : It happens to be a format I know quite well, i wrote parsers and generators for it.Your best try,in an office setup, is to try and automate an afp viewer program to print your file – user18428 Dec 01 '15 at 12:48
  • Can you elaborate in detail how to print afp file ?can it be done in java too? – Abhi jaZz Dec 02 '15 at 15:01
  • Hi oualid-jabnoune, can you help me in converting afp to pdf. – Abhi jaZz Dec 07 '15 at 08:00

0 Answers0