Package com.inet.pdfc
Class PDFComparer
java.lang.Object
com.inet.pdfc.PDFComparer
This is the main entry point when using i-net PDFC API. The PDFComparer can compare two files or folders and allows
the user to add presenters to show the result.
Typical Usage:
File referenceFile = new File( args[0] ); // first document file File currentFile = new File( args[1] ); // second document file IProfile profile = new DefaultProfile(); profile.putObject( PDFCProperty.CONTINUOUS_COMPARE, Boolean.TRUE ); new PDFComparer().setProfile( profile ).addPresenter( new ConsolePresenter() ).compare( referenceFile, currentFile );
- Since:
- i-net PDFC 3.0
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddPresenter
(BasePresenter presenter) Adds a Presenter to thisPDFComparer
.
A presenter is responsible to 'present' the comparison result, like print found differences on the console or create difference images.void
batchCompare
(DirectoryPdfSource directory1, DirectoryPdfSource directory2) Compare the two given directories, always comparingPdfSources
with the same name.void
batchCompare
(File directory1, File directory2) Compare the two given directories, always comparing document files with the same name.Compare the two given documents located anywhere.Compare the two given PDF-Files located on the file system.compareAsync
(PdfSource document1, PdfSource document2) Asynchronously compares the two given documents.Returns the keys of all compare modes that are available to the application.Returns the keys of all filters that are available to the application.Return the exceptions that occurred during the comparison which have not led to an interruption of the comparison.protected boolean
Defines whether the comparer creates theTextInfoImpl
data for theResultModel
as well.setProfile
(IProfile profile) Set the profile to use with thisPDFComparer
.
The profile determines which elements must be compared, how large the tolerance must be and other options.setProfile
(String profileID) Set the profile to use with thisPDFComparer
.
The profile determines which elements must be compared, how large the tolerance must be and other options.
It's recommended to check whether the profile is available first by callingDefaultProfileID.getAvailableProfileIDs()
.setSettings
(Settings settings) Defines the visibility for difference option.void
setVisibleDifferences
(DiffGroup.GroupType... differenceType) Deprecated.void
setVisibleHighlights
(String... filterType) Deprecated.As of i-net PDFC 4.3, usesetSettings(Settings setting)
instead
-
Constructor Details
-
PDFComparer
Creates an empty comparer instance. CallsetProfile(IProfile)
to configure the comparer,addPresenter(BasePresenter)
to add output modules and start the comparison withcompare(File, File)
orbatchCompare(File, File)
- Throws:
RuntimeException
- A runtime exception will be thrown here if and only if there is no valid license which grants API permissions.com.inet.pdfc.generator.InvalidLicenseException
- thrown in case there is no license for i-net PDFC or, if the license is insufficient for the API.- Since:
- i-net PDFC 3.0
-
-
Method Details
-
setProfile
Set the profile to use with thisPDFComparer
.
The profile determines which elements must be compared, how large the tolerance must be and other options.- Parameters:
profile
- the profile to use, must not be null.- Returns:
- this
PDFComparer
, allowing additional methods to be called in a chain. - Since:
- i-net PDFC 4.0
-
setProfile
Set the profile to use with thisPDFComparer
.
The profile determines which elements must be compared, how large the tolerance must be and other options.
It's recommended to check whether the profile is available first by callingDefaultProfileID.getAvailableProfileIDs()
. All Available default profiles can be listed byDefaultProfileID.getAvailableProfileIDs()
.- Parameters:
profileID
- the ID or name of the profile to be used. Please note, that the names of default profiles are localized, so use their ID instead.- Returns:
- this
PDFComparer
, allowing additional methods to be called in a chain. - Throws:
IllegalArgumentException
- thrown if no such profile could be found either by ID or name.- Since:
- i-net PDFC 4.0
- See Also:
-
addPresenter
Adds a Presenter to thisPDFComparer
.
A presenter is responsible to 'present' the comparison result, like print found differences on the console or create difference images.- Parameters:
presenter
- the presenter to add, must not be null.- Returns:
- this
PDFComparer
, allowing additional methods to be called in a chain. - Since:
- i-net PDFC 3.0
- See Also:
-
compare
Compare the two given PDF-Files located on the file system.
This method is blocking! UsecompareAsync(PdfSource, PdfSource)
for a non-blocking comparison.- Parameters:
document1
- the first document to compare, make sure to have reader plugin for the type of documentdocument2
- the second document to compare, make sure to have reader plugin for the type of document- Returns:
- a
ResultModel
containing result-information about the comparison. - Throws:
PdfcException
- when comparison faced an errorIllegalArgumentException
- in case document cannot be accessed or is a directory- Since:
- i-net PDFC 3.0
-
compare
Compare the two given documents located anywhere.
This method is blocking! UsecompareAsync(PdfSource, PdfSource)
for a non-blocking comparison.- Parameters:
pdf1
- the first document to compare, make sure to have reader plugin for the type of documentpdf2
- the second document to compare, make sure to have reader plugin for the type of document- Returns:
- a
ResultModel
containing result-information about the comparison. - Throws:
PdfcException
- in case of an internal exception- Since:
- i-net PDFC 3.0
-
batchCompare
Compare the two given directories, always comparing document files with the same name.
This method is blocking! UsecompareAsync(PdfSource, PdfSource)
for a non-blocking comparison.- Parameters:
directory1
- the first directory to use, must be a directory.directory2
- the second directory to use, must be a directory.- Throws:
IllegalArgumentException
- thrown in case the directory is not readable or not a directory- Since:
- i-net PDFC 3.0
-
batchCompare
Compare the two given directories, always comparingPdfSources
with the same name.- Parameters:
directory1
- the first directory to use, must not be null.directory2
- the second directory to use, must not be null.- Since:
- i-net PDFC 3.0
-
isCreateTextSelectionData
protected boolean isCreateTextSelectionData()Defines whether the comparer creates theTextInfoImpl
data for theResultModel
as well. This data may require a large amount of memory depending on the text size. It should only be enabled if the protected method getTextInfos() of theResultPage
s is used! Otherwise it's a waste of performance and memory.- Returns:
- returns
false
by default - Since:
- i-net PDFC 3.2
-
setVisibleDifferences
Deprecated.As of i-net PDFC 4.3, usesetSettings(Settings setting)
insteadDefines which differences types will be visible in the comparison output. This method will forward the settings to theResultModel.setVisible(boolean, VisibilitySetting...)
method.
Please note, that the setting forDiffGroup.GroupType.Sync
will be ignored here, as they are internal and to not map to a real differences type.- Parameters:
differenceType
- the types to set visible; any type which is not in this list will be hidden- Since:
- i-net PDFC 3.2
-
setVisibleHighlights
Deprecated.As of i-net PDFC 4.3, usesetSettings(Settings setting)
insteadDefines for which filter types highlights are visible. There will be no highlights for inactive filters or filters not mentioned in this list. So, by default, all highlights are deactivated- Parameters:
filterType
- the filters to activate the highlights for.- Since:
- i-net PDFC 4
-
setSettings
Defines the visibility for difference option. For example can be set the visibility for filter highlights or difference group types. Default are all highlights for inactive filters or filters not mentioned in this list. So, by default, all highlights are deactivated Default are all public difference group types visible.- Parameters:
settings
- the filters to activate the highlights for.- Returns:
- this
PDFComparer
, allowing additional methods to be called in a chain. - Since:
- i-net PDFC 4.3
-
compareAsync
Asynchronously compares the two given documents.- Parameters:
document1
- the first document to compare, make sure to have reader plugin for the type of documentdocument2
- the second document to compare, make sure to have reader plugin for the type of document- Returns:
- a worker object to wait for the result or to cancel the process
- Throws:
IllegalStateException
- if the same comparer is used to start several async comparisons- Since:
- 4.0
-
getAvailableCompareModeKeys
Returns the keys of all compare modes that are available to the application. The returned values can be used as values for thePDFCProperty.CONTINUOUS_COMPARE
property.
Compare algorithms are plugins an thus can be removed or deactivated.- Returns:
- the keys of all compare modes that are available to the application
- Since:
- 4.0
-
getAvailableFilterKeys
Returns the keys of all filters that are available to the application. The returned values can be used as values for thePDFCProperty.FILTERS
property.
Filters are plugins an thus can be removed or deactivated. It's recommended to check for valid filters when modifying a profile.d- Returns:
- the keys of all filters that are available to the application
- Since:
- 4.0
-
getPresenterExceptions
Return the exceptions that occurred during the comparison which have not led to an interruption of the comparison.- Returns:
- all exception in the presenters
- Since:
- 5.0
-
setSettings(Settings setting)
instead