How to compare two PDF documents

Hello Everyone,

I am using a robot framework. I am trying to compare two PDF documents. The PDFs contain the medical details including tables, points, values, dates, images, etc.
Here, the process is, that when we enter the source document of the medical information, the system generates the output as its summary. So I want to compare summary documents with their source documents.

To do this, I tried with DiffLibrary. I have tried with several codes.
Here is one of them. (I can provide other codes that I tried If you asked.)

*** Settings ***

Library SeleniumLibrary
Library DateTime
Library RequestsLibrary
Library Collections
Library String
Library DiffLibrary
Library OperatingSystem
Library BuiltIn
Library RPA.PDF

*** Test Cases ***

Compare Documents

${file1}  Open PDF     PDF_Files/SampleDoc1.pdf
close pdf
${file2}  Open PDF    PDF_Files/SampleDoc2.pdf
close pdf
Run Keyword If    ${file1}    ===     ${file2}
log to console    Both PDF documents are identical
log to console    PDF documents are different

But it doesn’t work correctly. Is there any other library to compare the two PDFs? And if I do any wrong thing here, please be kind enough to guide me. Any advice and guidance would be greatly appreciated.

“But it doesn’t work correctly” isn’t enough information for us to help you. What results are you getting? In what way does this result from what you’re expecting / need?

@robinmackaij , Sorry for the inconvenience, It’s my fault.
Here is the output.

Your using the ELSE IF incorrectly, unless you just change the first line to IF, but for the correct syntax/usage for run keyword if see

But you’ll need to add the … before the ELSE IF with the appropriate spacing, and an ‘condition’ else you’ll want to change to ELSE when you don’t want to do a conditional check thereafter and you don’t need an END statement using the keyword your currently using.

That will solve the error shown in the log provided as it is being thrown on that line.

In your first post snippet your opening the PDFs so I’m not sure what comparison your doing, nor could I answer if the open pdf keyword actually returns a value as I’ve never used that keyword but you’d need to explore those keywords for what they do and don’t do.

Hope that helps