Hi Team,
I am encountering an error while comparing two PDF files using the Aspose Library. However, comparing DOCX files works fine without any issues.
The error message is as follows:
Exception in thread “main” com.aspose.words.UnsupportedFileFormatException: PDF format is not supported on this platform. Use .NET Standard or .NET 4.6.1 or greater version of Aspose.Words for loading PDF documents.
I am currently using the following JAR file: “aspose-words-24.9-jdk17.jar”
Code:
public class DocumentComparisonAspose {
public static void main(String[] args) throws Exception {
// Load the original and revised documents
Document original = new Document("./src/main/resources/doc_v1.pdf");
Document revised = new Document("./src/main/resources/doc_v2_pdf.pdf");
// Perform comparison
compareDocuments(original, revised);
}
public static void compareDocuments(Document original, Document revised) throws Exception {
// Specify the author of changes
String author = "User";
// Compare documents
//original.compare(revised, author, new java.util.Date());
CompareOptions options = new CompareOptions();
options.setIgnoreFormatting(true); // Ignore formatting changes
options.setIgnoreCaseChanges(true); // Ignore case changes
options.setIgnoreTables(true); // Ignore table differences
original.compare(revised, "AuthorName", new java.util.Date(), options);
RevisionOptions revisionOptions = original.getLayoutOptions().getRevisionOptions();
revisionOptions.setInsertedTextColor(RevisionColor.DARK_YELLOW); // Color for insertions
revisionOptions.setDeletedTextColor(RevisionColor.RED); // Color for deletions
revisionOptions.setRevisedPropertiesColor(RevisionColor.DARK_YELLOW);
// Customize revision display options (e.g., color coding)
// Save the comparison result
original.save("OutputAspose.pdf");
System.out.println("Comparison completed. Result saved.");
}
}
Error:
Exception in thread "main" com.aspose.words.UnsupportedFileFormatException: Pdf format is not supported on this platform. Use .NET Standard or .NET 4.6.1 or greater version of Aspose.Words for loading Pdf documents.
at com.aspose.words.zzYK1.zzW8u(Unknown Source)
at com.aspose.words.Document.zzYQ9(Unknown Source)
at com.aspose.words.Document.zzZy(Unknown Source)
at com.aspose.words.Document.<init>(Unknown Source)
at com.aspose.words.Document.<init>(Unknown Source)
at com.standalone.my_Aspose.DocumentComparisonAspose.main(DocumentComparisonAspose.java:9)