Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comparison output readability (Ability to generate two diff documents) #59

Open
AbhiAuto opened this issue Sep 13, 2019 · 26 comments
Open
Labels
enhancement unlikely It's unlikely that this feature will be included

Comments

@AbhiAuto
Copy link

We have tried to compare two PDF files, and output came in the below format. It seems like we cannot read the difference from the output. Is there any other way we can make it more simpler and easy to understand?

image

@finsterwalder
Copy link
Collaborator

What do you want/expect?
Yes, it's hard to read.
But here is what pdfcompare does: It compares pdf pages pixel by pixel.
It shows pixel, that are missing in red and pixels that are there in addition in green.
When text is "moved", it quickly results in a lot of green and red, like in your example.
There is no easy way to detect a move and show that in any meaningful way, I think.

You could probably add a feature, that only shows the green or red.
What I usually do, when I have a big difference, like the one above is: I look at the two pdfs side by side. ;-)

@AbhiAuto
Copy link
Author

@finsterwalder Thanks for your suggestions :)

I was just checking if we have a solution for getting two outputs one in green and other in red or to get a single output.

However as you mentioned, I will try to add the feature or try to find a different solution. If those didn't work I will go for the final suggestion which you have mentioned. I have to look at the two PDF files side by side :)

One more question : Can we generate the output only with the difference into a Excel sheet or a word file ?

@HETU029
Copy link

HETU029 commented Sep 17, 2019

I have not found any solution for PDF comparison result in single color. When will You add a feature, that only shows the any one color.

@finsterwalder
Copy link
Collaborator

finsterwalder commented Sep 17, 2019 via email

@finsterwalder finsterwalder changed the title Comparison output readability Comparison output readability (Ability to generate two diff documents) Nov 19, 2019
@finsterwalder finsterwalder added enhancement unlikely It's unlikely that this feature will be included labels Nov 19, 2019
@finsterwalder
Copy link
Collaborator

I added the ability to customize the color of diff outputs. So you could run two comparisons with different coloring. Making one color something like gray or white, might give you the effect you are looking for.
(There is not "do not change the color" option, though.)

@shahmit
Copy link

shahmit commented Jun 23, 2020

Is it possible to get the result file side by side instead of overlapping, something like what this site shows-
https://www.diffchecker.com/diff

@finsterwalder
Copy link
Collaborator

PdfCompare has a very simplistic GUI, that can show two files side by side.
Right now you can choose to view the expected or the actual PDF next to the compare result and switch between those.

Feel free to code something that generates two PDFs with different color markers.
something like:
new PdfComparator(file1, file2).withEnvironment(new SimpleEnvironment().setActualColor(Color.BLACK))
new PdfComparator(file1, file2).withEnvironment(new SimpleEnvironment().setExpectedColor(Color.BLACK))

And show those files.

I will most likely not work on something like this in the near future.

And I think diffchecker.com works completely different, since it seams to extract text from the PDF and does not do a pixel comparison.

@shahmit
Copy link

shahmit commented Jun 24, 2020 via email

@finsterwalder
Copy link
Collaborator

I'm not sure I understand what you mean.
With "side by side", I assume you mean the PdfCompare UI?
And which "2 documents" do you mean exactly?

@v3g3t4x
Copy link

v3g3t4x commented Jul 19, 2020

check pdfcompare into my github. I added an interesting feature. For two pdf I generate one pdf where in each page you'll have on left page of pdf1 and on right a page of pdf2 with difference. check branch horizontal_compare (@finsterwalder may be an interesting feature to merge into your project).

@nilimapradipm
Copy link

nilimapradipm commented Mar 12, 2021

check pdfcompare into my github. I added an interesting feature. For two pdf I generate one pdf where in each page you'll have on left page of pdf1 and on right a page of pdf2 with difference. check branch horizontal_compare (@finsterwalder may be an interesting feature to merge into your project).

is this implemented? side by side compariosn ?

@gastendonk
Copy link
Contributor

is this implemented? side by side compariosn ?

I think it is. See class DisplayMain.

@nilimapradipm
Copy link

is this implemented? side by side compariosn ?

I think it is. See class DisplayMain.

Thanks for update. However i was thinking it is something which can be run programtically by passing two pdf & saving pdf for side by side comparison result

@v3g3t4x
Copy link

v3g3t4x commented Mar 12, 2021

Sorry for delay, yes in my version on my github is implemented the side by side compare.

@nilimapradipm
Copy link

Sorry for delay, yes in my version on my github is implemented the side by side compare.

Please can u share the class where i can call this

@v3g3t4x
Copy link

v3g3t4x commented Mar 12, 2021

Here an example on how use it...use setEnableHorizontalCompareOutput

		PdfComparator compare = new PdfComparator("input/input1.pdf", "input/input2.pdf");
		boolean flagLeftRight = true;
		compare.headerLeft = "LEFT";
		compare.headerRight = "RIGHT";

		compare.withEnvironment(new SimpleEnvironment().setActualColor(Color.red).setParallelProcessing(true)
				.setMaxImageSize(100000).setDocumentCacheSize(0).setOverallTimeout(15)
				.setExpectedColor(Color.CYAN).setAddEqualPagesToResult(true).setDPI(DPI)
				.setEnableHorizontalCompareOutput(flagLeftRight).setAllowedDiffInPercent(pixel));

		CompareResult result = compare.compare();

@nilimapradipm
Copy link

Here an example on how use it...use setEnableHorizontalCompareOutput

		PdfComparator compare = new PdfComparator("input/input1.pdf", "input/input2.pdf");
		boolean flagLeftRight = true;
		compare.headerLeft = "LEFT";
		compare.headerRight = "RIGHT";

		compare.withEnvironment(new SimpleEnvironment().setActualColor(Color.red).setParallelProcessing(true)
				.setMaxImageSize(100000).setDocumentCacheSize(0).setOverallTimeout(15)
				.setExpectedColor(Color.CYAN).setAddEqualPagesToResult(true).setDPI(DPI)
				.setEnableHorizontalCompareOutput(flagLeftRight).setAllowedDiffInPercent(pixel));

		CompareResult result = compare.compare();

thanks but m getting error for below. headerLeft is not getting listed. I am on horizontal_compare branch
compare.headerLeft = "LEFT";
compare.headerRight = "RIGHT";

@v3g3t4x
Copy link

v3g3t4x commented Mar 12, 2021

Yes sorry, my error.
You can now find the fix into horizontal_compare branch. Tell me if other error occurs.

@v3g3t4x
Copy link

v3g3t4x commented Mar 12, 2021

Pushed new code. Thanks
Pull

@LordOfStrings
Copy link

@v3g3t4x If I have a multipage PDF it compares the page and overwrites the output file, Is there a way to output multiple files for each page it compares

@v3g3t4x
Copy link

v3g3t4x commented Sep 6, 2021

Hi,
It create one PDF with multipage. Check well please and tell me if the issue is real.
But if I don't remember wrong it create one PDF with N pages.

@LordOfStrings
Copy link

@v3g3t4x it creates a single png file called comp.png rather than a pdf file and that png file is replaced over and over again fo reach comparison it does, do I need to change the format of the png file to PDF? I am using the horizontal_compare branch.

@v3g3t4x
Copy link

v3g3t4x commented Sep 6, 2021

That png it's only a tmp file, it produce a PDF too with all pages

@LordOfStrings
Copy link

LordOfStrings commented Sep 6, 2021

@v3g3t4x can you list me to the piece of code where it does the same, the only output I am getting is in the comp.png ( do I have to look in any specific folder), I searched every-folder but I don't see a pdf output anywhere.

@finsterwalder
Copy link
Collaborator

It's kinda hard to follow what exactly you are doing.
PdfCompare does not write a result Pdf, unless you tell it to do so.
For that you need to call CompareResult.writeTo(). This will store a multi page Pdf with one page per page from the original documents, marking all the differences.
There is no feature to write a single compare file for each page.

@v3g3t4x
Copy link

v3g3t4x commented Sep 13, 2021

Exactly, thanks @finsterwalder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement unlikely It's unlikely that this feature will be included
Projects
None yet
Development

No branches or pull requests

8 participants