You might want to compare the title or other document information of two PDF documents. Use the following methods:
// Comparing document properties:
.haveSameAuthor()
.haveSameCreationDate()
.haveSameCreator()
.haveSameKeywords()
.haveSameLanguageInfo()
.haveSameModificationDate()
.haveSameProducer()
.haveSameProperties()
.haveSameProperty(String)
.haveSameSubject()
.haveSameTitle()
As an example of comparing any document property we compare the “author”:
@Test public void haveSameAuthor() throws Exception { String filenameTest = "documentUnderTest.pdf"; String filenameReference = "reference.pdf"; AssertThat.document(filenameTest) .and(filenameReference) .haveSameAuthor() ; }
Custom properties can be compared using the method haveSameProperty(..)
:
@Test public void haveSameCustomProperty() throws Exception { String filenameTest = "documentUnderTest.pdf"; String filenameReference = "reference.pdf"; AssertThat.document(filenameTest) .and(filenameReference) .haveSameProperty("Company") .haveSameProperty("SourceModified") ; }
Of course, you can use this method to compare all standard properties.
If you want to compare all properties of two documents, you
can use the general method haveSameProperties()
:
@Test public void haveSameProperties_AllProperties() throws Exception { String filenameTest = "documentUnderTest.pdf"; String filenameReference = "reference.pdf"; AssertThat.document(filenameTest) .and(filenameReference) .haveSameProperties() ; }