@@ -217,7 +217,7 @@ public virtual CompareTool.CompareResult CompareByCatalog(PdfDocument outDocumen
217
217
/// By default, pages are treated as special objects and if they are met in the process of comparison, then they are
218
218
/// not checked as objects, but rather simply checked that they has same page numbers in both documents.
219
219
/// This behaviour is intended for the
220
- /// <see cref="CompareByContent(System.String, System.String, System.Collections.Generic.IDictionary{K, V} )"/>
220
+ /// <see cref="CompareByContent(System.String, System.String, System.String )"/>
221
221
/// set of methods, because in them documents are compared in page by page basis. Thus, we don't need to check if pages
222
222
/// are of the same content when they are met in comparison process, we are sure that we will compare their content or
223
223
/// we have already compared them.
@@ -396,6 +396,52 @@ public virtual String CompareVisually(String outPdf, String cmpPdf, String outPa
396
396
return CompareVisually ( outPath , differenceImagePrefix , ignoredAreas ) ;
397
397
}
398
398
399
+ /// <summary>
400
+ /// Compares two PDF documents by content starting from page dictionaries and then recursively comparing
401
+ /// corresponding objects which are referenced from them.
402
+ /// </summary>
403
+ /// <remarks>
404
+ /// Compares two PDF documents by content starting from page dictionaries and then recursively comparing
405
+ /// corresponding objects which are referenced from them. You can roughly imagine it as depth-first traversal
406
+ /// of the two trees that represent pdf objects structure of the documents.
407
+ /// <p>
408
+ /// Unlike
409
+ /// <see cref="CompareByCatalog(iText.Kernel.Pdf.PdfDocument, iText.Kernel.Pdf.PdfDocument)"/>
410
+ /// this method performs content comparison page by page
411
+ /// and doesn't compare the tag structure, acroforms and all other things that doesn't belong to specific pages.
412
+ /// <br />
413
+ /// When comparison by content is finished, if any differences were found, visual comparison is automatically started.
414
+ /// For more info see
415
+ /// <see cref="CompareVisually(System.String, System.String, System.String, System.String)"/>
416
+ /// .
417
+ /// For this overload, differenceImagePrefix value is generated using diff_%outPdfFileName%_ format.
418
+ /// <p>
419
+ /// For more explanations about what is outPdf and cmpPdf see last paragraph of the
420
+ /// <see cref="CompareTool"/>
421
+ /// class description.
422
+ /// </remarks>
423
+ /// <param name="outPdf">the absolute path to the output file, which is to be compared to cmp-file.</param>
424
+ /// <param name="cmpPdf">the absolute path to the cmp-file, which is to be compared to output file.</param>
425
+ /// <param name="outPath">the absolute path to the folder, which will be used to store image files for visual comparison.
426
+ /// </param>
427
+ /// <returns>
428
+ /// string containing text report of the encountered content differences and also list of the pages that are
429
+ /// visually different, or null if there are no content and therefore no visual differences.
430
+ /// </returns>
431
+ /// <exception cref="System.Exception">
432
+ /// if the current thread is interrupted by another thread while it is waiting
433
+ /// for ghostscript or imagemagic processes, then the wait is ended and an
434
+ /// <see cref="System.Exception"/>
435
+ /// is thrown.
436
+ /// </exception>
437
+ /// <exception cref="System.IO.IOException">
438
+ /// is thrown if any of the input files are missing or any of the auxiliary files
439
+ /// that are created during comparison process wasn't possible to be created.
440
+ /// </exception>
441
+ public virtual String CompareByContent ( String outPdf , String cmpPdf , String outPath ) {
442
+ return CompareByContent ( outPdf , cmpPdf , outPath , null , null , null , null ) ;
443
+ }
444
+
399
445
/// <summary>
400
446
/// Compares two PDF documents by content starting from page dictionaries and then recursively comparing
401
447
/// corresponding objects which are referenced from them.
@@ -429,8 +475,16 @@ public virtual String CompareVisually(String outPdf, String cmpPdf, String outPa
429
475
/// string containing text report of the encountered content differences and also list of the pages that are
430
476
/// visually different, or null if there are no content and therefore no visual differences.
431
477
/// </returns>
432
- /// <exception cref="System.Exception"/>
433
- /// <exception cref="System.IO.IOException"/>
478
+ /// <exception cref="System.Exception">
479
+ /// if the current thread is interrupted by another thread while it is waiting
480
+ /// for ghostscript or imagemagic processes, then the wait is ended and an
481
+ /// <see cref="System.Exception"/>
482
+ /// is thrown.
483
+ /// </exception>
484
+ /// <exception cref="System.IO.IOException">
485
+ /// is thrown if any of the input files are missing or any of the auxiliary files
486
+ /// that are created during comparison process wasn't possible to be created.
487
+ /// </exception>
434
488
public virtual String CompareByContent ( String outPdf , String cmpPdf , String outPath , String differenceImagePrefix
435
489
) {
436
490
return CompareByContent ( outPdf , cmpPdf , outPath , differenceImagePrefix , null , null , null ) ;
@@ -560,8 +614,16 @@ public virtual String CompareByContent(String outPdf, String cmpPdf, String outP
560
614
/// string containing text report of the encountered content differences and also list of the pages that are
561
615
/// visually different, or null if there are no content and therefore no visual differences.
562
616
/// </returns>
563
- /// <exception cref="System.Exception"/>
564
- /// <exception cref="System.IO.IOException"/>
617
+ /// <exception cref="System.Exception">
618
+ /// if the current thread is interrupted by another thread while it is waiting
619
+ /// for ghostscript or imagemagic processes, then the wait is ended and an
620
+ /// <see cref="System.Exception"/>
621
+ /// is thrown.
622
+ /// </exception>
623
+ /// <exception cref="System.IO.IOException">
624
+ /// is thrown if any of the input files are missing or any of the auxiliary files
625
+ /// that are created during comparison process wasn't possible to be created.
626
+ /// </exception>
565
627
public virtual String CompareByContent ( String outPdf , String cmpPdf , String outPath , String differenceImagePrefix
566
628
, IDictionary < int , IList < Rectangle > > ignoredAreas , byte [ ] outPass , byte [ ] cmpPass ) {
567
629
Init ( outPdf , cmpPdf ) ;
@@ -937,6 +999,14 @@ private String CompareVisually(String outPath, String differenceImagePrefix, IDi
937
999
if ( ! outPath . EndsWith ( "/" ) ) {
938
1000
outPath = outPath + "/" ;
939
1001
}
1002
+ if ( differenceImagePrefix == null ) {
1003
+ String fileBasedPrefix = "" ;
1004
+ if ( outPdfName != null ) {
1005
+ // should always be initialized by this moment
1006
+ fileBasedPrefix = outPdfName + "_" ;
1007
+ }
1008
+ differenceImagePrefix = "diff_" + fileBasedPrefix ;
1009
+ }
940
1010
PrepareOutputDirs ( outPath , differenceImagePrefix ) ;
941
1011
System . Console . Out . WriteLine ( "Comparing visually.........." ) ;
942
1012
if ( ignoredAreas != null && ! ignoredAreas . IsEmpty ( ) ) {
@@ -1209,7 +1279,6 @@ private void LoadPagesFromReader(PdfDocument doc, IList<PdfDictionary> pages, IL
1209
1279
}
1210
1280
}
1211
1281
1212
- /// <exception cref="System.IO.IOException"/>
1213
1282
private void CompareDocumentsEncryption ( PdfDocument outDocument , PdfDocument cmpDocument , CompareTool . CompareResult
1214
1283
compareResult ) {
1215
1284
PdfDictionary outEncrypt = outDocument . GetTrailer ( ) . GetAsDictionary ( PdfName . Encrypt ) ;
0 commit comments