Package com.itextpdf.testutils
Class CompareTool
- java.lang.Object
-
- com.itextpdf.testutils.CompareTool
-
public class CompareTool extends Object
Helper class for tests: uses ghostscript to compare PDFs at a pixel level.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
CompareTool.CompareResult
-
Constructor Summary
Constructors Constructor Description CompareTool()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
compare(String outPdf, String cmpPdf, String outPath, String differenceImagePrefix)
String
compare(String outPdf, String cmpPdf, String outPath, String differenceImagePrefix, Map<Integer,List<Rectangle>> ignoredAreas)
boolean
compareArrays(PdfArray outArray, PdfArray cmpArray)
boolean
compareBooleans(PdfBoolean outBoolean, PdfBoolean cmpBoolean)
String
compareByContent(String outPdf, String cmpPdf, String outPath, String differenceImagePrefix)
String
compareByContent(String outPdf, String cmpPdf, String outPath, String differenceImagePrefix, Map<Integer,List<Rectangle>> ignoredAreas)
protected String
compareByContent(String outPath, String differenceImagePrefix, Map<Integer,List<Rectangle>> ignoredAreas)
boolean
compareContentStreamsByParsing(PdfObject outObj, PdfObject cmpObj)
boolean
compareContentStreamsByParsing(PdfObject outObj, PdfObject cmpObj, PdfDictionary outResources, PdfDictionary cmpResources)
boolean
compareDictionaries(PdfDictionary outDict, PdfDictionary cmpDict)
String
compareDocumentInfo(String outPdf, String cmpPdf)
String
compareLinks(String outPdf, String cmpPdf)
boolean
compareLiterals(PdfLiteral outLiteral, PdfLiteral cmpLiteral)
boolean
compareNames(PdfName outName, PdfName cmpName)
boolean
compareNumbers(PdfNumber outNumber, PdfNumber cmpNumber)
boolean
compareStreams(PRStream outStream, PRStream cmpStream)
boolean
compareStrings(PdfString outString, PdfString cmpString)
String
compareTagStructures(String outPdf, String cmpPdf)
boolean
compareXmls(byte[] xml1, byte[] xml2)
boolean
compareXmls(String xml1, String xml2)
String
compareXmp(byte[] xmp1, byte[] xmp2)
String
compareXmp(byte[] xmp1, byte[] xmp2, boolean ignoreDateAndProducerProperties)
String
compareXmp(String outPdf, String cmpPdf)
String
compareXmp(String outPdf, String cmpPdf, boolean ignoreDateAndProducerProperties)
String
getXmlReportName()
CompareTool
setCompareByContentErrorsLimit(int compareByContentMaxErrorCount)
Sets the maximum errors count which will be returned as the result of the comparison.CompareTool
setFloatAbsoluteError(float error)
Sets the absolute error parameter which will be used in floating point numbers comparison.CompareTool
setFloatRelativeError(float error)
Sets the relative error parameter which will be used in floating point numbers comparison.void
setGenerateCompareByContentXmlReport(boolean generateCompareByContentXmlReport)
void
setXmlReportName(String xmlReportName)
-
-
-
Method Detail
-
compare
public String compare(String outPdf, String cmpPdf, String outPath, String differenceImagePrefix, Map<Integer,List<Rectangle>> ignoredAreas) throws IOException, InterruptedException, DocumentException
-
compare
public String compare(String outPdf, String cmpPdf, String outPath, String differenceImagePrefix) throws IOException, InterruptedException, DocumentException
-
setCompareByContentErrorsLimit
public CompareTool setCompareByContentErrorsLimit(int compareByContentMaxErrorCount)
Sets the maximum errors count which will be returned as the result of the comparison.- Parameters:
compareByContentMaxErrorCount
- the errors count.- Returns:
- Returns this.
-
setGenerateCompareByContentXmlReport
public void setGenerateCompareByContentXmlReport(boolean generateCompareByContentXmlReport)
-
setFloatAbsoluteError
public CompareTool setFloatAbsoluteError(float error)
Sets the absolute error parameter which will be used in floating point numbers comparison.- Parameters:
error
- the epsilon new value.- Returns:
- Returns this.
-
setFloatRelativeError
public CompareTool setFloatRelativeError(float error)
Sets the relative error parameter which will be used in floating point numbers comparison.- Parameters:
error
- the epsilon new value.- Returns:
- Returns this.
-
getXmlReportName
public String getXmlReportName()
-
setXmlReportName
public void setXmlReportName(String xmlReportName)
-
compareByContent
protected String compareByContent(String outPath, String differenceImagePrefix, Map<Integer,List<Rectangle>> ignoredAreas) throws DocumentException, InterruptedException, IOException
-
compareByContent
public String compareByContent(String outPdf, String cmpPdf, String outPath, String differenceImagePrefix, Map<Integer,List<Rectangle>> ignoredAreas) throws DocumentException, InterruptedException, IOException
-
compareByContent
public String compareByContent(String outPdf, String cmpPdf, String outPath, String differenceImagePrefix) throws DocumentException, InterruptedException, IOException
-
compareDictionaries
public boolean compareDictionaries(PdfDictionary outDict, PdfDictionary cmpDict) throws IOException
- Throws:
IOException
-
compareContentStreamsByParsing
public boolean compareContentStreamsByParsing(PdfObject outObj, PdfObject cmpObj) throws IOException
- Throws:
IOException
-
compareContentStreamsByParsing
public boolean compareContentStreamsByParsing(PdfObject outObj, PdfObject cmpObj, PdfDictionary outResources, PdfDictionary cmpResources) throws IOException
- Throws:
IOException
-
compareStreams
public boolean compareStreams(PRStream outStream, PRStream cmpStream) throws IOException
- Throws:
IOException
-
compareArrays
public boolean compareArrays(PdfArray outArray, PdfArray cmpArray) throws IOException
- Throws:
IOException
-
compareLiterals
public boolean compareLiterals(PdfLiteral outLiteral, PdfLiteral cmpLiteral)
-
compareBooleans
public boolean compareBooleans(PdfBoolean outBoolean, PdfBoolean cmpBoolean)
-
compareXmp
public String compareXmp(byte[] xmp1, byte[] xmp2)
-
compareXmp
public String compareXmp(byte[] xmp1, byte[] xmp2, boolean ignoreDateAndProducerProperties)
-
compareXmp
public String compareXmp(String outPdf, String cmpPdf, boolean ignoreDateAndProducerProperties)
-
compareXmls
public boolean compareXmls(byte[] xml1, byte[] xml2) throws ParserConfigurationException, SAXException, IOException
-
compareDocumentInfo
public String compareDocumentInfo(String outPdf, String cmpPdf) throws IOException
- Throws:
IOException
-
compareLinks
public String compareLinks(String outPdf, String cmpPdf) throws IOException
- Throws:
IOException
-
compareTagStructures
public String compareTagStructures(String outPdf, String cmpPdf) throws IOException, ParserConfigurationException, SAXException
-
compareXmls
public boolean compareXmls(String xml1, String xml2) throws ParserConfigurationException, SAXException, IOException
-
-