@@ -131,6 +131,10 @@ public class CompareTool {
131
131
private static final String gsParams = " -dNOPAUSE -dBATCH -sDEVICE=png16m -r150 -sOutputFile='<outputfile>' '<inputfile>'" ;
132
132
private static final String compareParams = " '<image1>' '<image2>' '<difference>'" ;
133
133
134
+ private static final String versionRegexp = "(iText\u00ae ( pdfX(FA|fa))?|iTextSharp\u2122 ) (\\ d\\ .)+\\ d(-SNAPSHOT)?" ;
135
+ private static final String versionReplacement = "iText\u00ae <version>" ;
136
+ private static final String copyrightRegexp = "\u00a9 \\ d+-\\ d+ iText Group NV" ;
137
+ private static final String copyrightReplacement = "\u00a9 <copyright years> iText Group NV" ;
134
138
135
139
private String gsExec ;
136
140
private String compareExec ;
@@ -650,7 +654,7 @@ public String compareDocumentInfo(String outPdf, String cmpPdf, byte[] outPass,
650
654
String [] outInfo = convertInfo (outDocument .getDocumentInfo ());
651
655
for (int i = 0 ; i < cmpInfo .length ; ++i ) {
652
656
if (!cmpInfo [i ].equals (outInfo [i ])){
653
- message = "Document info fail" ;
657
+ message = MessageFormatUtil . format ( "Document info fail. Expected: \" {0} \" , actual: \" {1} \" " , cmpInfo [ i ], outInfo [ i ]) ;
654
658
break ;
655
659
}
656
660
}
@@ -1614,7 +1618,7 @@ private int getExplicitDestinationPageNum(PdfArray explicitDest) {
1614
1618
}
1615
1619
1616
1620
private String [] convertInfo (PdfDocumentInfo info ) {
1617
- String [] convertedInfo = new String []{"" , "" , "" , "" };
1621
+ String [] convertedInfo = new String []{"" , "" , "" , "" , "" };
1618
1622
String infoValue = info .getTitle ();
1619
1623
if (infoValue != null )
1620
1624
convertedInfo [0 ] = infoValue ;
@@ -1627,9 +1631,16 @@ private String[] convertInfo(PdfDocumentInfo info) {
1627
1631
infoValue = info .getKeywords ();
1628
1632
if (infoValue != null )
1629
1633
convertedInfo [3 ] = infoValue ;
1634
+ infoValue = info .getProducer ();
1635
+ if (infoValue != null ) {
1636
+ convertedInfo [4 ] = convertProducerLine (infoValue );
1637
+ }
1630
1638
return convertedInfo ;
1631
1639
}
1632
1640
1641
+ private String convertProducerLine (String producer ) {
1642
+ return producer .replaceAll (versionRegexp , versionReplacement ).replaceAll (copyrightRegexp , copyrightReplacement );
1643
+ }
1633
1644
1634
1645
private class PngFileFilter implements FileFilter {
1635
1646
0 commit comments