Class CompareTool
java.lang.Object
com.itextpdf.testutils.CompareTool
Helper class for tests: uses ghostscript to compare PDFs at a pixel level.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncompare(String outPdf, String cmpPdf, String outPath, String differenceImagePrefix, Map<Integer, List<Rectangle>> ignoredAreas) booleancompareArrays(PdfArray outArray, PdfArray cmpArray) booleancompareBooleans(PdfBoolean outBoolean, PdfBoolean cmpBoolean) compareByContent(String outPdf, String cmpPdf, String outPath, String differenceImagePrefix) compareByContent(String outPdf, String cmpPdf, String outPath, String differenceImagePrefix, Map<Integer, List<Rectangle>> ignoredAreas) protected StringcompareByContent(String outPath, String differenceImagePrefix, Map<Integer, List<Rectangle>> ignoredAreas) booleancompareContentStreamsByParsing(PdfObject outObj, PdfObject cmpObj) booleancompareContentStreamsByParsing(PdfObject outObj, PdfObject cmpObj, PdfDictionary outResources, PdfDictionary cmpResources) booleancompareDictionaries(PdfDictionary outDict, PdfDictionary cmpDict) compareDocumentInfo(String outPdf, String cmpPdf) compareLinks(String outPdf, String cmpPdf) booleancompareLiterals(PdfLiteral outLiteral, PdfLiteral cmpLiteral) booleancompareNames(PdfName outName, PdfName cmpName) booleancompareNumbers(PdfNumber outNumber, PdfNumber cmpNumber) booleancompareStreams(PRStream outStream, PRStream cmpStream) booleancompareStrings(PdfString outString, PdfString cmpString) compareTagStructures(String outPdf, String cmpPdf) booleancompareXmls(byte[] xml1, byte[] xml2) booleancompareXmls(String xml1, String xml2) compareXmp(byte[] xmp1, byte[] xmp2) compareXmp(byte[] xmp1, byte[] xmp2, boolean ignoreDateAndProducerProperties) compareXmp(String outPdf, String cmpPdf) compareXmp(String outPdf, String cmpPdf, boolean ignoreDateAndProducerProperties) setCompareByContentErrorsLimit(int compareByContentMaxErrorCount) Sets the maximum errors count which will be returned as the result of the comparison.setFloatAbsoluteError(float error) Sets the absolute error parameter which will be used in floating point numbers comparison.setFloatRelativeError(float error) Sets the relative error parameter which will be used in floating point numbers comparison.voidsetGenerateCompareByContentXmlReport(boolean generateCompareByContentXmlReport) voidsetXmlReportName(String xmlReportName)
-
Constructor Details
-
CompareTool
public CompareTool()
-
-
Method Details
-
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
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
Sets the absolute error parameter which will be used in floating point numbers comparison.- Parameters:
error- the epsilon new value.- Returns:
- Returns this.
-
setFloatRelativeError
Sets the relative error parameter which will be used in floating point numbers comparison.- Parameters:
error- the epsilon new value.- Returns:
- Returns this.
-
getXmlReportName
-
setXmlReportName
-
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
- 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
- Throws:
IOException
-
compareArrays
- Throws:
IOException
-
compareNames
-
compareNumbers
-
compareStrings
-
compareLiterals
-
compareBooleans
-
compareXmp
-
compareXmp
-
compareXmp
-
compareXmp
-
compareXmls
public boolean compareXmls(byte[] xml1, byte[] xml2) throws ParserConfigurationException, SAXException, IOException -
compareDocumentInfo
- Throws:
IOException
-
compareLinks
- 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
-