
This sample class needs the SilentResultHandler.java file.
/* 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; import java.io.File; import org.apache.log4j.ConsoleAppender; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.log4j.SimpleLayout; 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 a silent result handler. * The SilentResultHandler returns true or false, depending on whether the files were different. */ public class CompareTwoFilesWithSilentHandler { public static void main( String[] args ) { if (args == null || args.length != 2) { System.out.println( "Usage: CompareTwoFilesWithCustomHandler <Folder1> <Folder2> or <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(); // Configure Log Output Logger logger = Logger.getRootLogger(); logger.addAppender( new ConsoleAppender( new SimpleLayout() ) ); logger.setLevel( Level.toLevel( configuration.getString( PDFCProperty.LOG_LEVEL ) ) ); IResultHandler resultHandler = new SilentResultHandler( ); // Compare PDF files (new BatchRunner( configuration, resultHandler )).runComparison( referenceFile, currentFile ); // Create Custom Result Handler to use it's additional functionality SilentResultHandler silentResultHandler = (SilentResultHandler)resultHandler; logger.info( "files identical: " + silentResultHandler.isFilesIdentical( 0 ) ); } }