Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
A Python package to compare files (PDF, docx, images) and generate reports in txt, html, or PDF format
PDFCompare
is a Python package designed for comparing multiple file types, including PDF, DOCX, and scanned images. It generates detailed difference reports that can be exported in TXT, HTML, and PDF formats. The package utilizes PyMuPDF
for parsing PDFs, pytesseract
for OCR on images, and python-docx
for DOCX parsing. Additionally, it now includes advanced image preprocessing for improved OCR accuracy using OpenCV.
pytesseract
with advanced preprocessing.OpenCV
for binarization, noise removal, and other image enhancements to improve OCR accuracy.The following external dependencies are required for handling PDF parsing and OCR:
sudo apt-get update
sudo apt-get install tesseract-ocr
If you have Homebrew installed, run:
brew install tesseract
Download the Tesseract installer from the official repository here and follow the installation instructions.
sudo apt-get update
sudo apt-get install wkhtmltopdf
Using Homebrew:
brew install wkhtmltopdf
Download the Windows installer from here and install it.
To install OpenCV for image preprocessing, run:
pip install opencv-python
pdfcompare
PackageOnce all dependencies are installed, you can install pdfcompare
via pip
:
pip install pdfcompare
pdfcompare
provides an intuitive command-line interface for comparing files and generating reports.
pdfcompare file1 file2 --output txt
pdfcompare file1 file2 --output html
pdfcompare file1 file2 --output pdf
pdfcompare document1.pdf document2.docx --output html
This command compares document1.pdf
and document2.docx
, and saves the comparison result as an HTML report.
file1
, file2
: Paths to the files you want to compare.--output
: Specify the format for the report (options: txt
, html
, pdf
).The pdfcompare
package now supports advanced image preprocessing using OpenCV to improve OCR accuracy. This includes steps like binarization, noise removal, and other enhancements before performing text extraction.
pdfcompare
can be used as a Python module within your code.
from pdfcompare.cli import compare_files
file1 = "path/to/file1.pdf"
file2 = "path/to/file2.docx"
output_format = "pdf" # Choose from 'txt', 'html', or 'pdf'
compare_files(file1, file2, output_format)
from pdfcompare.file_handlers.image_handler import extract_text
text = extract_text("path/to/your/image.png")
print(text)
To run unit tests, first install the development dependencies, and then use:
python -m unittest discover tests/
git checkout -b feature/your-feature
).git commit -am 'Add new feature'
).git push origin feature/your-feature
).This project is licensed under the MIT License - see the LICENSE file for details.
extract_text
function for better maintainability.To install the latest version:
pip install pdfcompare --upgrade
FAQs
A Python package to compare files (PDF, docx, images) and generate reports in txt, html, or PDF format
We found that pdfcompare demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.