Skip to content

Keep your images after translating a PDF. Only works on Linux for now.

Notifications You must be signed in to change notification settings

FabricioTeran/KeepPDFImages

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Keep your images after translating a PDF

  • Efficient Program for Cutting rectangles with difference operation between 2 PDFs and paste them on a third PDF
  • Only works on Linux for now.

Table of Contents

How It Works:

A global overview of the program:

  • Take all the arguments from the terminal.
  • Create /orig, /modif, and /pdf folders on the current directory with fs::create_dir().
  • Convert the 1st and 2nd PDF to png images using gs (GhostScript) called from Command::new API and saving it in /orig and /modif respectively with pdfutil::pdf2imgs().
  • Compare /orig and /modif images with complicated image operations using imagemagick and saving the result images as PDFs containing the difference and all of their background transparent on /pdf with imagick::mask_and_alpha().
  • Then merge all the .pdf files in /pdf in only one PDF using pdftk with pdfutil::merge_pdf().
  • Overlay the generated PDF on the 3rd PDF using qpdf with pdfutil::overlay_pdf.
  • All the data generated by the commands is parsed and validated by the program.

Dependencies:

This software was tested on:

  • ImageMagick 6.9.11-60 Q16 x86_64 2021-01-25 https://imagemagick.org
  • qpdf 10.6.3
  • pdftk port to java 3.2.2
  • gs (it's included with pdftk or qpdf, if not, install it manually)

If you have problems installing an old version of a command, read this

Usage:

Run the program with:

  • cargo run -- --p1 ./path/orig.pdf --p2 ./path/modif.pdf --tr ./path/trans.pdf
  • p1 : The path to the original PDF.
  • p2 : The path to the modified PDF with the drawn rectangles.
  • tr : The path to the translated PDF.
  • The output folder is saved in the same directory that the command was invoked.

You can draw the rectangles with any PDF editing program (some examples: Sejda PDF Editor, Adobe Acrobat, or online editors), choose a color that contrast with the background (it's recommended to choose a different color than the text color), some examples of the original and modified PDFs:

one two

About

Keep your images after translating a PDF. Only works on Linux for now.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages