
/* i-net software provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This programming example assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. i-net software support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. © i-net software 2011 */ //package samples; package samples; import java.io.File; import org.apache.log4j.ConsoleAppender; import org.apache.log4j.Logger; import org.apache.log4j.SimpleLayout; import com.inet.pdfc.results.ConsoleResultHandler; import com.inet.pdfc.config.ConfigurationFactory; import com.inet.pdfc.config.IConfiguration; import com.inet.pdfc.config.PDFCProperty; import com.inet.pdfc.results.IResultHandler; import com.inet.pdfc.runner.BatchRunner; /** * This sample demonstrates how you can compare two PDF files with the default result handler. */ public class CompareTwoFilesWithDefaultHandler { public static void main( String[] args ) { if (args == null || args.length != 2) { System.out.println( "Usage: CompareTwoFilesWithDefaultHandler <PDF-File1> <PDF-File2>" ); System.exit(1); } File referenceFile = new File( args[0] ); // first PDF file File currentFile = new File( args[1] ); // second PDF file // Configure i-net PDFC IConfiguration configuration = ConfigurationFactory.getConfiguration(); configuration.putObject( PDFCProperty.CREATE_DIFFIMAGES, Boolean.TRUE ); // create PNG image for each page of the PDF file with differences configuration.putObject( PDFCProperty.CREATE_ORIGIMAGES, Boolean.TRUE ); // create PNG image for each page with the original content // Configure Log Output Logger logger = Logger.getRootLogger(); logger.addAppender( new ConsoleAppender( new SimpleLayout() ) ); IResultHandler resultHandler = new ConsoleResultHandler( configuration ); // Compare PDF files (new BatchRunner( configuration, resultHandler )).runComparison( referenceFile, currentFile ); } }